Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to ESLint 9 #622

Merged
merged 5 commits into from
Oct 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .eslintignore

This file was deleted.

123 changes: 0 additions & 123 deletions .eslintrc.js

This file was deleted.

145 changes: 145 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
import jsdoc from 'eslint-plugin-jsdoc';
import promise from 'eslint-plugin-promise';
import importPlugin from 'eslint-plugin-import';
import globals from 'globals';
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';
import json from 'eslint-plugin-json';

export default [
eslint.configs.recommended,
jsdoc.configs['flat/recommended'],
eslintPluginPrettierRecommended,
...tseslint.configs.recommended,
promise.configs['flat/recommended'],
importPlugin.flatConfigs.errors,
importPlugin.flatConfigs.warnings,
{
ignores: ['dist/*']
},
{
settings: {
'import/resolver': {
typescript: {
alwaysTryTypes: true
}
}
}
},
{
files: ['**/*.json'],
...json.configs['recommended']
},
{
files: ['**/*.ts'],
...importPlugin.flatConfigs.typescript,
languageOptions: {
parser: tseslint.parser
}
},
{
files: ['**/*.ts', '**/*.js'],
languageOptions: {
globals: {
...globals.browser,
...globals.es2015
}
},
rules: {
'@typescript-eslint/explicit-function-return-type': 'error',
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/no-unused-expressions': 'warn',
'@typescript-eslint/no-unused-vars': [
'error',
{ caughtErrors: 'none' }
],
'@typescript-eslint/prefer-ts-expect-error': 'error',
curly: 'error',
'import/newline-after-import': 'error',
'import/order': 'error',
'jsdoc/check-indentation': 'error',
'jsdoc/check-param-names': 'error',
'jsdoc/check-property-names': 'error',
'jsdoc/check-syntax': 'error',
'jsdoc/check-tag-names': 'error',
'jsdoc/no-types': 'error',
'jsdoc/require-description': 'warn',
'jsdoc/require-hyphen-before-param-description': 'error',
'jsdoc/require-jsdoc': 'error',
'jsdoc/require-param-description': 'warn',
//TypeScript and IntelliSense already provides us information about the function typings while hovering and
// eslint-jsdoc doesn't detect a mismatch between what's declared in the function and what's declared in
// JSDOC.
'jsdoc/require-param-type': 'off',
'jsdoc/require-returns-type': 'off',
'jsdoc/valid-types': 'off',
'padding-line-between-statements': [
'error',
// Always require blank lines after directives (like 'use-strict'), except between directives
{ blankLine: 'always', next: '*', prev: 'directive' },
{ blankLine: 'any', next: 'directive', prev: 'directive' },
// Always require blank lines after import, except between imports
{ blankLine: 'always', next: '*', prev: 'import' },
{ blankLine: 'any', next: 'import', prev: 'import' },
// Always require blank lines before and after every sequence of variable declarations and export
{
blankLine: 'always',
next: ['const', 'let', 'var', 'export'],
prev: '*'
},
{
blankLine: 'always',
next: '*',
prev: ['const', 'let', 'var', 'export']
},
{
blankLine: 'any',
next: ['const', 'let', 'var', 'export'],
prev: ['const', 'let', 'var', 'export']
},
// Always require blank lines before and after class declaration, if, do/while, switch, try
{
blankLine: 'always',
next: [
'if',
'class',
'for',
'do',
'while',
'switch',
'try'
],
prev: '*'
},
{
blankLine: 'always',
next: '*',
prev: ['if', 'class', 'for', 'do', 'while', 'switch', 'try']
},
// Always require blank lines before return statements
{ blankLine: 'always', next: 'return', prev: '*' }
],
'prefer-arrow-callback': 'error',
'prefer-template': 'error',
'promise/no-nesting': 'error',
'promise/no-return-in-finally': 'error',
'promise/prefer-await-to-callbacks': 'error',
'promise/prefer-await-to-then': 'error',
'sort-keys': [
'error',
'asc',
{ caseSensitive: false, minKeys: 2, natural: true }
],
'sort-vars': 'error'
}
},
{
files: ['*.js'],
languageOptions: {
globals: {
...globals.node
}
}
}
];
Loading
Loading