-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy patheslint.config.js
80 lines (75 loc) · 2.17 KB
/
eslint.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import globals from 'globals';
import { FlatCompat } from '@eslint/eslintrc';
import path from 'path';
import { fileURLToPath } from 'url';
import { fixupPluginRules } from '@eslint/compat';
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
import babelParser from '@babel/eslint-parser';
// mimic CommonJS variables -- not needed if using CommonJS
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname
});
function legacyPlugin(name, alias = name) {
const plugin = compat.plugins(name)[0]?.plugins?.[alias];
if (!plugin) {
throw new Error(`Unable to resolve plugin ${name} and/or alias ${alias}`);
}
return fixupPluginRules(plugin);
}
export default [
eslintPluginPrettierRecommended,
{
plugins: {
import: legacyPlugin('eslint-plugin-import', 'import')
},
files: ['**/*.js', '**/*.mjs'],
languageOptions: {
globals: {
...globals.es6,
...globals.node,
...globals.jest,
myCustomGlobal: 'readonly'
},
parser: babelParser,
parserOptions: {
ecmaVersion: 2022,
sourceType: 'module',
requireConfigFile: false,
babelOptions: {
babelrc: false,
configFile: false,
presets: ['@babel/preset-env'],
plugins: ['@babel/plugin-syntax-import-assertions']
}
}
},
rules: {
'no-console': ['warn'],
'no-useless-escape': 0,
'no-empty': 0,
'comma-dangle': 0,
'arrow-parens': ['error', 'as-needed'],
'import/prefer-default-export': 'off',
'import/no-cycle': 'off',
'no-underscore-dangle': 'off',
'no-bitwise': 'off',
'no-mixed-operators': 'off',
'max-len': ['error', { code: 130 }],
'class-methods-use-this': 'off',
'no-plusplus': 'off',
'prettier/prettier': [
'error',
{
singleQuote: true,
trailingComma: 'none',
arrowParens: 'avoid',
proseWrap: 'always',
endOfLine: 'auto'
}
]
},
ignores: ['scripts', 'examples', 'test', 'jest.config.js']
}
];