Skip to content

Commit

Permalink
⬆️ Migrate to eslint v9
Browse files Browse the repository at this point in the history
  • Loading branch information
ENT8R committed Oct 10, 2024
1 parent ce1d5b0 commit 3b87156
Show file tree
Hide file tree
Showing 7 changed files with 570 additions and 335 deletions.
86 changes: 0 additions & 86 deletions .eslintrc

This file was deleted.

2 changes: 1 addition & 1 deletion app/js/localizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export async function init() {
try {
const { default: main } = await import(`../locales/${LANGUAGE}.json`);
STRINGS.main = main;
} catch (error) {
} catch (error) { // eslint-disable-line no-unused-vars
console.error( // eslint-disable-line no-console
new Error(`${LANGUAGE}.json does not exist, ${FALLBACK_LANGUAGE}.json is used instead`)
);
Expand Down
4 changes: 2 additions & 2 deletions app/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,8 @@ function settings() {
}

if (import.meta.env.PROD) {
console.log = () => {};
console.error = () => {};
console.log = () => {}; // eslint-disable-line no-console
console.error = () => {}; // eslint-disable-line no-console
}

await import('@github/relative-time-element');
Expand Down
2 changes: 1 addition & 1 deletion app/js/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function request(url, mediaType = MEDIA_TYPE.JSON, controller = new AbortControl
}
}).catch(error => {
if (error.name === 'AbortError') {
console.log(`Aborted request while fetching file at ${url}: ${error}`);
console.log(`Aborted request while fetching file at ${url}: ${error}`); // eslint-disable-line no-console
} else {
console.log(`Error while fetching file at ${url}: ${error}`); // eslint-disable-line no-console
}
Expand Down
100 changes: 100 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import globals from 'globals';
import js from '@eslint/js';
import jsdoc from 'eslint-plugin-jsdoc';

import stylisticJs from '@stylistic/eslint-plugin-js';

export default [
js.configs.recommended, {
plugins: {
'@stylistic/js': stylisticJs,
jsdoc: jsdoc
},
settings: {
jsdoc: {
tagNamePreference: {
returns: 'return'
}
}
},
languageOptions: {
globals: {
...globals.browser,
L: 'readonly',
__VERSION__: 'readonly',
NOTESREVIEW_API_URL: 'readonly',
OPENSTREETMAP_SERVER: 'readonly',
OPENSTREETMAP_OAUTH_CLIENT_ID: 'readonly',
OPENSTREETMAP_OAUTH_CLIENT_SECRET: 'readonly',
MAPILLARY_CLIENT_ID: 'readonly',
},
ecmaVersion: 2023,
sourceType: 'module',
},

rules: {
'@stylistic/js/semi': 'warn',
'@stylistic/js/semi-style': 'error',
'@stylistic/js/semi-spacing': 'warn',
'@stylistic/js/quotes': ['warn', 'single', {
avoidEscape: true,
allowTemplateLiterals: false,
}],
'@stylistic/js/brace-style': 'error',
'@stylistic/js/indent': ['error', 2],

'no-eval': 'error',
'no-implied-eval': 'error',

'camelcase': 'error',
'prefer-const': 'error',
'no-var': 'warn',
'prefer-arrow-callback': 'warn',
'prefer-rest-params': 'error',
'prefer-spread': 'error',
'prefer-template': 'warn',
'template-curly-spacing': 'warn',
'symbol-description': 'error',
'object-shorthand': 'warn',
'prefer-promise-reject-errors': 'error',
'prefer-destructuring': 'warn',
'prefer-numeric-literals': 'warn',

'no-new-object': 'error',
eqeqeq: ['error', 'smart'],
curly: ['error', 'all'],
'dot-location': ['error', 'property'],
'dot-notation': 'error',
'no-array-constructor': 'error',
'no-throw-literal': 'error',
'no-self-compare': 'error',
'no-useless-call': 'warn',
'spaced-comment': 'warn',
'no-multi-spaces': 'warn',
'no-new-wrappers': 'error',
'no-script-url': 'error',
'no-void': 'warn',
'vars-on-top': 'warn',
yoda: ['error', 'never'],
'require-await': 'warn',

'jsdoc/require-jsdoc': ['error', {
require: {
FunctionDeclaration: true,
MethodDefinition: false,
ClassDeclaration: false,
ArrowFunctionExpression: false,
},
}],
'jsdoc/require-returns-type': 'warn',
'jsdoc/require-description': 'warn',
'jsdoc/require-param-description': 'off',
'jsdoc/require-returns-description': 'off',

'wrap-iife': ['error', 'inside'],
'no-unused-expressions': 'error',
'no-useless-constructor': 'error',
'no-console': 'error',
'require-atomic-updates': 'warn',
},
}];
Loading

0 comments on commit 3b87156

Please sign in to comment.