Skip to content

Commit

Permalink
Upgrade eslint to version 9 (#4869)
Browse files Browse the repository at this point in the history
* Clean up console log in unit tests

* Upgrade eslint to latest version

* Fix geocode changes

* Revet unwanted changes

* Revert change

* Fix weird build test

* Improve test to actually check something...
  • Loading branch information
HarelM authored Oct 21, 2024
1 parent 6c99b6d commit 0ffa890
Show file tree
Hide file tree
Showing 32 changed files with 479 additions and 427 deletions.
107 changes: 0 additions & 107 deletions .eslintrc.json

This file was deleted.

2 changes: 1 addition & 1 deletion build/generate-doc-images.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ async function createImage(exampleName) {
const waitTime = (exampleName.includes('3d-model') || exampleName.includes('globe')) ? 5000 : 1500;
console.log(`waiting for ${waitTime} ms`);
await new Promise(resolve => setTimeout(resolve, waitTime));
} catch (err) {
} catch {
// map.loaded() does not evaluate to true within 3 seconds, it's probably an animated example.
// In this case we take the screenshot immediately.
console.log(`Timed out waiting for map load on ${exampleName}.`);
Expand Down
2 changes: 1 addition & 1 deletion build/generate-struct-arrays.ts
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ export class ${structArrayClass} extends ${structArrayLayoutClass} {`);
output.push(
` /**
* Return the ${structTypeClass} at the given location in the array.
* @param index The index of the element.
* @param index - The index of the element.
*/
get(index: number): ${structTypeClass} {
return new ${structTypeClass}(this, index);
Expand Down
1 change: 0 additions & 1 deletion build/rollup_plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ export const plugins = (production: boolean, minified: boolean): Plugin[] => [
}),
minified && terser({
compress: {
// eslint-disable-next-line camelcase
pure_getters: true,
passes: 3
},
Expand Down
157 changes: 157 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
import typescriptEslint from '@typescript-eslint/eslint-plugin';
import stylisticTs from '@stylistic/eslint-plugin-ts'
import tsdoc from 'eslint-plugin-tsdoc';
import jest from 'eslint-plugin-jest';
import globals from 'globals';
import tsParser from '@typescript-eslint/parser';
import react from 'eslint-plugin-react';
import html from 'eslint-plugin-html';

export default [
{
ignores: ['build/*.js', 'staging/**', 'coverage/**', 'node_modules/**', 'docs/**', 'dist/**']
},
{
ignores: ['test/bench/**'],
files: ['**/*.ts', '**/*.js'],
plugins: {
'@typescript-eslint': typescriptEslint,
'@stylistic': stylisticTs,
tsdoc,
jest,
},

linterOptions: {
reportUnusedDisableDirectives: true,
},

languageOptions: {
globals: {
...Object.fromEntries(Object.entries(globals.browser).map(([key]) => [key, 'off'])),
performance: true,
},

parser: tsParser,
ecmaVersion: 5,
sourceType: 'module',

parserOptions: {
createDefaultProgram: true,
},
},

rules: {
'no-dupe-class-members': 'off',
'@typescript-eslint/no-dupe-class-members': ['error'],

'@typescript-eslint/no-unused-vars': ['warn', {
argsIgnorePattern: '^_',
}],

'@stylistic/member-delimiter-style': ['error'],
'no-useless-constructor': 'off',
'@typescript-eslint/no-useless-constructor': ['error'],
'no-undef': 'off',
'no-use-before-define': 'off',
'no-duplicate-imports': 'off',
'implicit-arrow-linebreak': 'off',
'arrow-parens': 'off',
'arrow-body-style': 'off',
'no-confusing-arrow': 'off',
'no-control-regex': 'off',
'no-invalid-this': 'off',
'no-buffer-constructor': 'off',
'array-bracket-spacing': 'error',
'consistent-return': 'off',
'global-require': 'off',
'key-spacing': 'error',
'no-eq-null': 'off',
'no-lonely-if': 'off',
'no-new': 'off',

'no-restricted-properties': [2, {
object: 'Object',
property: 'assign',
}],

'no-unused-vars': 'off',
'no-warning-comments': 'error',
'object-curly-spacing': ['error', 'never'],
'prefer-arrow-callback': 'error',

'prefer-const': ['error', {
destructuring: 'all',
}],

'prefer-template': 'error',
'prefer-spread': 'off',
quotes: 'off',
'@stylistic/quotes': ['error', 'single'],
'no-redeclare': 'off',
'@typescript-eslint/no-redeclare': ['error'],
'space-before-function-paren': 'off',
'template-curly-spacing': 'error',
'no-useless-escape': 'off',
indent: 'off',
'@stylistic/indent': ['error'],

'no-multiple-empty-lines': ['error', {
max: 1,
}],

'tsdoc/syntax': 'warn',
'jest/no-commented-out-tests': 'error',
'jest/no-disabled-tests': 'warn',
'jest/no-focused-tests': 'error',
'jest/prefer-to-contain': 'warn',
'jest/prefer-to-have-length': 'warn',
'jest/valid-expect': 'error',
'jest/prefer-to-be': 'warn',
'jest/no-alias-methods': 'warn',
'jest/no-interpolation-in-snapshots': 'warn',

'jest/no-large-snapshots': ['warn', {
maxSize: 50,
inlineMaxSize: 20,
}],

'jest/no-deprecated-functions': 'warn',
},
},
{
files: ['**/*.html'],
plugins: {
html
},
rules: {
'no-restricted-properties': 'off',
'new-cap': 'off',
'@typescript-eslint/no-unused-vars': 'off'
}
},
{
files: ['test/bench/**/*.jsx', 'test/bench/**/*.js', 'test/bench/**/*.ts'],
plugins: {
react
},
rules: {
'react/jsx-uses-vars': [2],
'no-restricted-properties': 'off'
},
languageOptions: {
globals: {
...Object.fromEntries(Object.entries(globals.browser).map(([key]) => [key, 'off'])),
performance: true,
},

parser: tsParser,
ecmaVersion: 5,
sourceType: 'module',

parserOptions: {
createDefaultProgram: true,
},
},
},

];
Loading

0 comments on commit 0ffa890

Please sign in to comment.