Skip to content

Commit

Permalink
feat: 🔨 prep for eslint v9
Browse files Browse the repository at this point in the history
  • Loading branch information
CourtHive committed Apr 18, 2024
1 parent e2d54e6 commit cb750c9
Show file tree
Hide file tree
Showing 5 changed files with 139 additions and 329 deletions.
60 changes: 0 additions & 60 deletions .eslintrc.json

This file was deleted.

76 changes: 76 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
const typescriptEslintParser = require('@typescript-eslint/parser');
const eslintPluginSonarjs = require('eslint-plugin-sonarjs');
const { FlatCompat } = require('@eslint/eslintrc');
const globals = require('globals');
const js = require('@eslint/js');

const compat = new FlatCompat({
recommendedConfig: js.configs.recommended,
baseDirectory: __dirname,
});

module.exports = [
...compat.extends('./eslint.vite.js'),
js.configs.recommended,
...compat.extends(
'plugin:compat/recommended',
'plugin:@typescript-eslint/recommended',
'plugin:import/recommended',
'plugin:import/typescript',
'plugin:sonarjs/recommended',
'plugin:prettier/recommended',
),
{ plugins: { sonarjs: eslintPluginSonarjs } },
{
languageOptions: {
parser: typescriptEslintParser,
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
},
globals: {
...globals.node,
...globals.browser,
...globals.es6,
...globals.jest,
},
},
},
{
rules: {
'no-unused-expressions': 'off',
'@typescript-eslint/no-useless-escape': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/no-unused-vars': 'warn',
'import/no-named-as-default': 'off',
'import/no-named-as-default-member': 'off',
'import/no-unresolved': 'off',
'import/namespace': 'off',
'sonarjs/cognitive-complexity': ['off', 100],
'sonarjs/no-all-duplicated-branches': 'warn',
'sonarjs/no-collapsible-if': 'warn',
'sonarjs/no-collection-size-mischeck': 'warn',
'sonarjs/no-duplicate-string': 'warn',
'sonarjs/no-duplicated-branches': 'warn',
'sonarjs/no-empty-collection': 'warn',
'sonarjs/no-extra-arguments': 'warn',
'sonarjs/no-gratuitous-expressions': 'warn',
'sonarjs/no-identical-expressions': 'warn',
'sonarjs/no-identical-functions': 'warn',
'sonarjs/no-ignored-return': 'off',
'sonarjs/no-misleading-array-reverse': 'off',
'sonarjs/no-nested-template-literals': 'warn',
'sonarjs/no-redundant-boolean': 'warn',
'sonarjs/no-redundant-jump': 'warn',
'sonarjs/no-small-switch': 'warn',
'sonarjs/no-unused-collection': 'warn',
'sonarjs/prefer-object-literal': 'warn',
'sonarjs/prefer-single-boolean-return': 'warn',
},
},
{ ignores: ['node_modules/', 'dist/', 'coverage/', '**/scratch/', 'server/', '**/*.test.ts'] },
];
53 changes: 53 additions & 0 deletions eslint.vite.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
module.exports = {
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:import/recommended',
'plugin:sonarjs/recommended',
],
parser: '@typescript-eslint/parser',
settings: {
'import/resolver': {
node: {
paths: ['src'],
extensions: ['.js', '.ts'],
},
},
},
plugins: ['@typescript-eslint', 'sonarjs'],
rules: {
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-empty-function': 'error',
'@typescript-eslint/no-empty-interface': 'error',
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/no-unused-expressions': 'off',
'@typescript-eslint/no-unused-vars': ['error', { ignoreRestSiblings: true }],
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/no-useless-escape': 'off',
'array-callback-return': 'warn',
complexity: ['off', 25],
eqeqeq: ['warn', 'smart'],
'import/named': 'off',
'import/no-duplicates': 'error',
'import/no-unresolved': 'off',
'no-console': 'off',
'no-debugger': 'error',
'no-duplicate-imports': 0,
'no-nested-ternary': 'warn',
'no-unneeded-ternary': 'warn',
'no-unused-vars': 'off',
'sonarjs/cognitive-complexity': ['warn', 15],
'sonarjs/no-collapsible-if': 'warn',
'sonarjs/no-duplicate-string': 'warn',
'sonarjs/no-duplicated-branches': 'warn',
'sonarjs/no-ignored-return': 'off',
'sonarjs/no-nested-template-literals': 'warn',
'sonarjs/no-redundant-boolean': 'warn',
'sonarjs/no-redundant-jump': 'warn',
'sonarjs/no-small-switch': 'warn',
'sonarjs/no-unused-collection': 'warn',
'sonarjs/prefer-single-boolean-return': 'warn',
},
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,10 @@
"eslint-plugin-compat": "4.2.0",
"eslint-plugin-import": "2.29.1",
"eslint-plugin-prettier": "5.1.3",
"eslint-plugin-react": "7.34.1",
"eslint-plugin-sonarjs": "^0.25.0",
"esm": "3.2.25",
"fs-extra": "11.2.0",
"globals": "^15.0.0",
"husky": "9.0.11",
"jest": "29.7.0",
"lint-staged": "15.2.2",
Expand Down
Loading

0 comments on commit cb750c9

Please sign in to comment.