Skip to content

Commit e57967b

Browse files
stepankuzmingithub-actions[bot]
authored andcommitted
Enable e18e/prefer-includes rule
GitOrigin-RevId: 46ad18ced5dc63128ebcba53b6e7ec09897eceb4
1 parent 4cac1ff commit e57967b

34 files changed

Lines changed: 70 additions & 73 deletions

build/generate-struct-arrays.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ const arraysWithStructAccessors: ArrayWithStructAccessors[] = [];
4343
const arrayTypeEntries = new Set();
4444
const layoutCache: Record<string, {className: string; members: StructArrayMember[]; size: number; usedTypes: Set<string>}> = {};
4545

46-
// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
4746
function normalizeMembers(members: StructArrayMember[], usedTypes: Set<string | ViewType>): StructArrayMember[] {
4847
return members.map((member) => {
4948
if (usedTypes && !usedTypes.has(member.type)) {

build/generate-style-code.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ const layers = Object.keys(spec.layer.type.values).map((type) => {
231231

232232
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
233233
if (paintSpec[name].appearance) {
234-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
234+
235235
appearancePaintProperties.push({
236236
src: `paint_${type}`,
237237
srcSection: 'paint',
@@ -262,7 +262,8 @@ const layers = Object.keys(spec.layer.type.values).map((type) => {
262262
});
263263

264264
// Add -use-theme counterparts for color paint appearance properties
265-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
265+
266+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
266267
for (const prop of [...appearancePaintProperties]) {
267268
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
268269
if (prop.type === 'color') {

build/generate-typed-style-spec.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ function tsObjectDeclaration(key, properties, overrides = {}) {
113113

114114
function tsObject(properties, indent, overrides = {}) {
115115
return `{
116-
${// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
116+
${// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, indent
117117
Object.keys(properties)
118118
.flatMap(k => {
119119
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
@@ -421,7 +421,7 @@ ${tsObjectDeclaration('SelectorPropertySpecification', spec.selectorProperty)}
421421
422422
${tsObjectDeclaration('AppearanceSpecification', spec.appearance)}
423423
424-
${// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
424+
${// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access, indent
425425
spec.source.map(key => {
426426
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
427427
const sourceSpecName = tsSourceSpecificationTypeName(key);
@@ -436,14 +436,14 @@ spec.source.map(key => {
436436
}).join('\n\n')}
437437
438438
export type SourceSpecification =
439-
${// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
440-
spec.source.map(key => ` | ${tsSourceSpecificationTypeName(key)}`// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
439+
${// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access, indent
440+
spec.source.map(key => ` | ${tsSourceSpecificationTypeName(key)}`// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, indent
441441
).join('\n')};
442442
443443
export type IconsetSpecification =
444-
${// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
445-
spec.iconset.map(key => ` | ${// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
446-
tsObject(spec[key], ' ')}`// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
444+
${// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access, indent
445+
spec.iconset.map(key => ` | ${// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, indent
446+
tsObject(spec[key], ' ')}`// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, indent
447447
).join('\n')};
448448
449449
export type ModelSpecification = ${tsType(spec.model)};

eslint.config.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ export default tseslint.config(
192192

193193
// Require _devtools access inside Debug.run()
194194
{
195-
files: ['src/**/*.ts', '3d-style/**/*.ts'],
195+
files: ['src/**/*.ts', '3d-style/**/*.ts', 'modules/**/*.ts'],
196196
ignores: ['src/ui/control/devtools.ts'],
197197
rules: {
198198
'mapbox/devtools-must-use-debug-run': 'error',
@@ -229,7 +229,7 @@ export default tseslint.config(
229229
'import-x/no-restricted-paths': ['error', {
230230
zones: [{
231231
target: './src/style-spec',
232-
from: ['./src/!(style-spec)/**/*', './3d-style/**/*'],
232+
from: ['./src/!(style-spec)/**/*', './3d-style/**/*', './modules/**/*'],
233233
}],
234234
}],
235235

@@ -259,7 +259,6 @@ export default tseslint.config(
259259
'e18e/prefer-array-at': 'off',
260260
'e18e/prefer-array-some': 'off',
261261
'e18e/prefer-date-now': 'off',
262-
'e18e/prefer-includes': 'off',
263262
'e18e/prefer-object-has-own': 'off',
264263
'e18e/prefer-regex-test': 'off',
265264
'e18e/prefer-static-regex': 'off',

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@
152152
"start-debug": "run-p build-token watch-css watch-pmtiles watch-dev start-server",
153153
"prepare-release-pages": "ln -sfn $PWD/dist test/release/dist && ln -sfn $PWD/debug test/release/debug && cp debug/access_token_generated.js test/release/",
154154
"start-release": "run-s build-token build-prod build-esm-prod build-css print-release-url prepare-release-pages start-server",
155-
"lint": "eslint --cache src 3d-style test packages modules internal",
155+
"lint": "eslint --cache .",
156156
"lint-css": "stylelint 'src/css/mapbox-gl.css'",
157157
"test": "run-s lint lint-css test-typings test-unit",
158158
"test-suite": "run-s test-render test-query test-expressions",

src/data/bucket/symbol_bucket.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1075,7 +1075,7 @@ class SymbolBucket implements Bucket {
10751075
if (text) {
10761076
const fontStack = textFont.evaluate(evaluationFeature, {}, canonical).join(',');
10771077
const textAlongLine = layout.get('text-rotation-alignment') === 'map' && layout.get('symbol-placement') !== 'point';
1078-
this.allowVerticalPlacement = this.writingModes && this.writingModes.indexOf(WritingMode.vertical) >= 0;
1078+
this.allowVerticalPlacement = this.writingModes && this.writingModes.includes(WritingMode.vertical);
10791079
for (const section of text.sections) {
10801080
if (!section.image) {
10811081
const doesAllowVerticalWritingMode = allowsVerticalWritingMode(text.toString());

src/gl/context.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ class Context {
151151
}
152152

153153
// Force manual rendering for instanced draw calls having gl_InstanceID usage in the shader for PowerVR adapters
154-
this.forceManualRenderingForInstanceIDShaders = (options && !!options.forceManualRenderingForInstanceIDShaders) || (this.renderer && this.renderer.indexOf("PowerVR") !== -1);
154+
this.forceManualRenderingForInstanceIDShaders = (options && !!options.forceManualRenderingForInstanceIDShaders) || (this.renderer && this.renderer.includes("PowerVR"));
155155

156156
this.disableSymbolUBO = (options && !!options.forceDisableSymbolUBO);
157157

src/style-spec/composite.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ export default function (style: StyleSpecification): StyleSpecification {
3434
};
3535

3636
style.layers.forEach((layer) => {
37-
if (styleIDs.indexOf(layer.source) >= 0) {
37+
if (styleIDs.includes(layer.source)) {
3838
layer.source = compositeID;
3939

4040
if ('source-layer' in layer) {
41-
if (compositedSourceLayers.indexOf(layer['source-layer']) >= 0) {
41+
if (compositedSourceLayers.includes(layer['source-layer'])) {
4242
throw new Error('Conflicting source layer names');
4343
} else {
4444
compositedSourceLayers.push(layer['source-layer']);

src/style-spec/expression/definitions/in.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class In implements Expression {
6666
}
6767

6868
// Type assertions safe due to isValidNativeType checks above
69-
return (haystack as string | unknown[]).indexOf(needle as string) >= 0;
69+
return (haystack as string | unknown[]).includes(needle as string);
7070
}
7171

7272
eachChild(fn: (_: Expression) => void) {

src/style-spec/expression/definitions/index.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -617,21 +617,21 @@ CompoundExpression.register(expressions, {
617617
'filter-type-in': [
618618
BooleanType,
619619
[array(StringType)],
620-
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
621-
(ctx, [v]) => (v).value.indexOf(ctx.geometryType()) >= 0
620+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-return
621+
(ctx, [v]) => (v).value.includes(ctx.geometryType())
622622
],
623623
'filter-id-in': [
624624
BooleanType,
625625
[array(ValueType)],
626-
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
627-
(ctx, [v]) => (v).value.indexOf(ctx.id()) >= 0
626+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-return
627+
(ctx, [v]) => (v).value.includes(ctx.id())
628628
],
629629
'filter-in-small': [
630630
BooleanType,
631631
[StringType, array(ValueType)],
632632
// assumes v is an array literal
633-
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
634-
(ctx, [k, v]) => (v).value.indexOf(ctx.properties()[(k).value]) >= 0
633+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-return
634+
(ctx, [k, v]) => (v).value.includes(ctx.properties()[(k).value])
635635
],
636636
'filter-in-large': [
637637
BooleanType,

0 commit comments

Comments
 (0)