Files
OpenList-Desktop/eslint.config.mjs

107 lines
3.3 KiB
JavaScript
Raw Normal View History

2025-06-26 15:09:20 +08:00
// @ts-check
import eslint from '@eslint/js'
import simpleImportSort from 'eslint-plugin-simple-import-sort'
import eslintPluginUnicorn from 'eslint-plugin-unicorn'
import globals from 'globals'
import tseslint from 'typescript-eslint'
export default tseslint.config(
{
files: ['./src/*.{ts,tsx,cts,mts,js,cjs,mjs}', './scripts/*.{ts,js,mjs}', './test/*.{ts,js,mjs}']
},
{
ignores: [
'**/node_modules/**',
'**/dist/**',
'vitest.workspace.mjs',
'cases/**',
'test/**',
'benchmark/**',
'webpack.config.js',
'bin/*'
]
},
eslint.configs.recommended,
...tseslint.configs.recommended,
...tseslint.configs.stylistic,
{
plugins: {
'simple-import-sort': simpleImportSort,
unicorn: eslintPluginUnicorn
},
rules: {
'simple-import-sort/imports': 'error',
'simple-import-sort/exports': 'error'
}
},
{
languageOptions: {
parserOptions: {
warnOnUnsupportedTypeScriptVersion: false
},
globals: globals.node
}
},
{
rules: {
eqeqeq: 'error',
'no-caller': 'error',
'no-constant-condition': ['error', { checkLoops: false }],
'no-eval': 'error',
'no-extra-bind': 'error',
'no-new-func': 'error',
'no-new-wrappers': 'error',
'no-throw-literal': 'error',
'no-undef-init': 'error',
'no-var': 'error',
'object-shorthand': 'error',
'prefer-const': 'error',
'prefer-object-spread': 'error',
'unicode-bom': ['error', 'never'],
// Enabled in eslint:recommended, but not applicable here
'no-extra-boolean-cast': 'off',
'no-case-declarations': 'off',
'no-cond-assign': 'off',
'no-control-regex': 'off',
'no-inner-declarations': 'off',
'no-empty': 'off',
// @typescript-eslint/eslint-plugin
'no-unused-expressions': 'off',
'@typescript-eslint/no-unused-expressions': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/class-literal-property-style': 'off',
'@typescript-eslint/consistent-indexed-object-style': 'off',
'@typescript-eslint/consistent-generic-constructors': 'off',
'@typescript-eslint/no-duplicate-enum-values': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-namespace': 'off',
'@typescript-eslint/no-non-null-asserted-optional-chain': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/no-empty-interface': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-empty-object-type': 'off', // {} is a totally useful and valid type.
'@typescript-eslint/no-require-imports': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-inferrable-types': 'off',
// Pending https://github.com/typescript-eslint/typescript-eslint/issues/4820
'@typescript-eslint/prefer-optional-chain': 'off',
'unicorn/prefer-node-protocol': 'error'
}
},
{
files: ['**/*.mjs', '**/*.mts'],
rules: {
// These globals don't exist outside of CJS files.
'no-restricted-globals': [
'error',
{ name: '__filename' },
{ name: '__dirname' },
{ name: 'require' },
{ name: 'module' },
{ name: 'exports' }
]
}
}
)