286 lines
12 KiB
JavaScript
286 lines
12 KiB
JavaScript
import typescriptEslintEslintPlugin from '@typescript-eslint/eslint-plugin';
|
|
import globals from 'globals';
|
|
import tsParser from '@typescript-eslint/parser';
|
|
import path from 'node:path';
|
|
import { fileURLToPath } from 'node:url';
|
|
import js from '@eslint/js';
|
|
import { FlatCompat } from '@eslint/eslintrc';
|
|
|
|
const __filename = fileURLToPath(import.meta.url);
|
|
const __dirname = path.dirname(__filename);
|
|
const compat = new FlatCompat({
|
|
baseDirectory: __dirname,
|
|
recommendedConfig: js.configs.recommended,
|
|
allConfig: js.configs.all
|
|
});
|
|
|
|
export default [
|
|
...compat.extends('eslint:recommended', 'plugin:@typescript-eslint/recommended'),
|
|
{
|
|
plugins: {
|
|
'@typescript-eslint': typescriptEslintEslintPlugin,
|
|
},
|
|
|
|
languageOptions: {
|
|
globals: {
|
|
...globals.node,
|
|
Atomics: 'readonly',
|
|
SharedArrayBuffer: 'readonly',
|
|
BigInt: true,
|
|
},
|
|
|
|
parser: tsParser,
|
|
ecmaVersion: 2022,
|
|
sourceType: 'module',
|
|
|
|
parserOptions: {
|
|
project: './tsconfig.json',
|
|
},
|
|
},
|
|
|
|
rules: {
|
|
'@typescript-eslint/no-unused-vars': 'off',
|
|
'@typescript-eslint/no-non-null-assertion': 'off',
|
|
|
|
'@typescript-eslint/no-misused-promises': [ 'error', {
|
|
checksVoidReturn: {
|
|
arguments: false,
|
|
},
|
|
}],
|
|
|
|
'@typescript-eslint/no-shadow': 'error',
|
|
'@typescript-eslint/no-use-before-define': 'error',
|
|
'accessor-pairs': 'warn',
|
|
'array-callback-return': 'warn',
|
|
'array-bracket-newline': [ 'warn', 'consistent' ],
|
|
|
|
'array-bracket-spacing': [ 'warn', 'always', {
|
|
objectsInArrays: false,
|
|
arraysInArrays: false,
|
|
}],
|
|
|
|
'arrow-spacing': 'warn',
|
|
'block-scoped-var': 'warn',
|
|
'block-spacing': [ 'warn', 'always' ],
|
|
'brace-style': [ 'warn', 'allman' ],
|
|
'callback-return': 'warn',
|
|
camelcase: 'warn',
|
|
'comma-dangle': [ 'warn', 'only-multiline' ],
|
|
|
|
'comma-spacing': [ 'warn', {
|
|
after: true,
|
|
before: false,
|
|
}],
|
|
|
|
'comma-style': 'warn',
|
|
'computed-property-spacing': [ 'warn', 'never' ],
|
|
'consistent-this': 'warn',
|
|
|
|
'dot-notation': [ 'warn', {
|
|
allowKeywords: true,
|
|
}],
|
|
|
|
'dot-location': [ 'error', 'property' ],
|
|
'eol-last': [ 'warn', 'never' ],
|
|
eqeqeq: 'error',
|
|
'func-call-spacing': 'warn',
|
|
'func-name-matching': 'warn',
|
|
'func-names': 'warn',
|
|
'func-style': 'warn',
|
|
'function-paren-newline': 'warn',
|
|
'generator-star-spacing': 'warn',
|
|
'grouped-accessor-pairs': 'warn',
|
|
'guard-for-in': 'warn',
|
|
'handle-callback-err': 'warn',
|
|
'id-blacklist': 'warn',
|
|
'id-match': 'warn',
|
|
'implicit-arrow-linebreak': 'warn',
|
|
|
|
indent: [ 'warn', 4, {
|
|
SwitchCase: 1,
|
|
VariableDeclarator: 'first',
|
|
|
|
FunctionDeclaration: {
|
|
parameters: 'first',
|
|
},
|
|
|
|
CallExpression: {
|
|
arguments: 'first',
|
|
},
|
|
|
|
ArrayExpression: 'first',
|
|
ObjectExpression: 'first',
|
|
ImportDeclaration: 'first',
|
|
}],
|
|
|
|
'init-declarations': 'warn',
|
|
quotes: [ 'error', 'single' ],
|
|
'jsx-quotes': [ 'error', 'prefer-single' ],
|
|
|
|
'key-spacing': [ 'warn', {
|
|
beforeColon: false,
|
|
afterColon: true,
|
|
align: 'value',
|
|
}],
|
|
|
|
'keyword-spacing': [ 'warn', {
|
|
after: true,
|
|
before: true,
|
|
}],
|
|
|
|
'linebreak-style': [ 'error', 'unix' ],
|
|
'lines-around-comment': 'warn',
|
|
'lines-around-directive': 'warn',
|
|
'max-classes-per-file': 'warn',
|
|
'max-nested-callbacks': 'warn',
|
|
|
|
'max-len': [ 'warn', {
|
|
code: 140,
|
|
ignoreComments: true,
|
|
ignoreStrings: true,
|
|
ignoreTemplateLiterals: true,
|
|
ignoreRegExpLiterals: true,
|
|
}],
|
|
|
|
'max-lines-per-function': [ 'warn', 140 ],
|
|
'max-depth': [ 'warn', 3 ],
|
|
'new-parens': 'warn',
|
|
'no-alert': 'warn',
|
|
'no-array-constructor': 'warn',
|
|
'no-buffer-constructor': 'warn',
|
|
'no-caller': 'warn',
|
|
'no-console': 'warn',
|
|
'no-constant-binary-expression': 'error',
|
|
'no-div-regex': 'warn',
|
|
'no-dupe-else-if': 'warn',
|
|
'no-duplicate-imports': 'warn',
|
|
'no-else-return': 'warn',
|
|
'no-empty-function': 'warn',
|
|
'no-eq-null': 'off',
|
|
'no-eval': 'warn',
|
|
'no-extend-native': 'warn',
|
|
'no-extra-bind': 'warn',
|
|
'no-extra-label': 'warn',
|
|
'no-floating-decimal': 'warn',
|
|
'no-implicit-coercion': 'warn',
|
|
'no-implicit-globals': 'warn',
|
|
'no-implied-eval': 'error',
|
|
'no-import-assign': 'warn',
|
|
'no-invalid-this': 'warn',
|
|
'no-iterator': 'warn',
|
|
'no-label-var': 'warn',
|
|
'no-lone-blocks': 'warn',
|
|
'no-lonely-if': 'warn',
|
|
'no-loop-func': 'warn',
|
|
'no-mixed-requires': 'warn',
|
|
'no-multi-assign': 'warn',
|
|
|
|
'no-multi-spaces': [ 'warn', {
|
|
ignoreEOLComments: true,
|
|
|
|
exceptions: {
|
|
ImportDeclaration: true,
|
|
},
|
|
}],
|
|
|
|
'no-multi-str': 'warn',
|
|
'no-multiple-empty-lines': 'warn',
|
|
'no-native-reassign': 'warn',
|
|
'no-negated-in-lhs': 'warn',
|
|
'no-negated-condition': 'error',
|
|
'no-nested-ternary': 'warn',
|
|
'no-new': 'warn',
|
|
'no-new-func': 'warn',
|
|
'no-new-object': 'warn',
|
|
'no-new-require': 'warn',
|
|
'no-new-wrappers': 'warn',
|
|
'no-octal-escape': 'warn',
|
|
'no-path-concat': 'warn',
|
|
'no-process-exit': 'warn',
|
|
'no-proto': 'warn',
|
|
'no-restricted-globals': 'warn',
|
|
'no-restricted-imports': 'warn',
|
|
'no-restricted-modules': 'warn',
|
|
'no-restricted-properties': 'warn',
|
|
'no-restricted-syntax': 'warn',
|
|
'no-return-assign': [ 'warn', 'except-parens' ],
|
|
'no-return-await': 'warn',
|
|
'no-script-url': 'warn',
|
|
'no-self-compare': 'warn',
|
|
'no-sequences': 'warn',
|
|
'no-setter-return': 'warn',
|
|
'no-spaced-func': 'warn',
|
|
'no-tabs': 'error',
|
|
'no-template-curly-in-string': 'error',
|
|
'no-throw-literal': 'warn',
|
|
'no-trailing-spaces': 'warn',
|
|
'no-undef-init': 'error',
|
|
'no-undefined': 'error',
|
|
'no-unmodified-loop-condition': 'warn',
|
|
'no-unneeded-ternary': 'error',
|
|
'no-unused-expressions': 'warn',
|
|
'no-useless-call': 'warn',
|
|
'no-useless-computed-key': 'warn',
|
|
'no-useless-concat': 'warn',
|
|
'no-useless-constructor': 'warn',
|
|
'no-useless-rename': 'warn',
|
|
'no-useless-return': 'warn',
|
|
'no-var': 'warn',
|
|
'no-whitespace-before-property': 'error',
|
|
'nonblock-statement-body-position': [ 'warn', 'below' ],
|
|
'object-curly-spacing': [ 'warn', 'always' ],
|
|
|
|
'object-property-newline': [ 'warn', {
|
|
allowAllPropertiesOnSameLine: true,
|
|
}],
|
|
|
|
'object-shorthand': 'warn',
|
|
'one-var-declaration-per-line': 'warn',
|
|
'operator-assignment': 'warn',
|
|
'operator-linebreak': [ 'warn', 'before' ],
|
|
'padding-line-between-statements': 'warn',
|
|
|
|
'padded-blocks': [ 'warn', {
|
|
switches: 'never',
|
|
}, {
|
|
allowSingleLineBlocks: true,
|
|
}],
|
|
|
|
'prefer-arrow-callback': 'warn',
|
|
'prefer-const': 'warn',
|
|
'prefer-destructuring': 'warn',
|
|
'prefer-exponentiation-operator': 'warn',
|
|
'prefer-numeric-literals': 'warn',
|
|
'prefer-object-spread': 'error',
|
|
'prefer-promise-reject-errors': 'warn',
|
|
'prefer-regex-literals': 'warn',
|
|
'prefer-rest-params': 'warn',
|
|
'prefer-spread': 'warn',
|
|
'require-unicode-regexp': 'warn',
|
|
'rest-spread-spacing': 'warn',
|
|
semi: 'error',
|
|
'semi-spacing': 'warn',
|
|
'semi-style': [ 'warn', 'last' ],
|
|
'space-before-blocks': 'warn',
|
|
'space-before-function-paren': [ 'error', 'always' ],
|
|
'space-in-parens': [ 'warn', 'never' ],
|
|
'spaced-comment': [ 'warn', 'always' ],
|
|
strict: 'warn',
|
|
'switch-colon-spacing': 'warn',
|
|
'symbol-description': 'warn',
|
|
'template-curly-spacing': [ 'warn', 'never' ],
|
|
'template-tag-spacing': 'warn',
|
|
'unicode-bom': [ 'warn', 'never' ],
|
|
'vars-on-top': 'warn',
|
|
'wrap-iife': 'warn',
|
|
'wrap-regex': 'error',
|
|
'yield-star-spacing': 'warn',
|
|
yoda: [ 'warn', 'never' ],
|
|
|
|
'no-warning-comments': [ 1, {
|
|
terms: [ 'todo', 'fixme' ],
|
|
location: 'anywhere',
|
|
}],
|
|
},
|
|
},
|
|
]; |