-
Notifications
You must be signed in to change notification settings - Fork 83
/
eslint.config.js
101 lines (97 loc) · 2.95 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
const globals = require('globals');
const {configs: eslintConfigs} = require('@eslint/js');
const eslintPluginImport = require('eslint-plugin-import');
const eslintPluginStylistic = require('@stylistic/eslint-plugin');
const config = [
{
files: ['**/*.js'],
languageOptions: {
globals: {
...globals.browser,
...globals.node,
EXIF: 'readonly',
Log: 'readonly',
Module: 'readonly',
moment: 'readonly'
}
},
plugins: {
...eslintPluginStylistic.configs['all-flat'].plugins,
import: eslintPluginImport
},
rules: {
...eslintConfigs.all.rules,
...eslintPluginImport.configs.recommended.rules,
...eslintPluginStylistic.configs['all-flat'].rules,
'capitalized-comments': 'off',
complexity: ['error', 35],
'consistent-this': 'off',
curly: 'off',
'id-length': 'off',
'line-comment-position': 'off',
'max-lines': 'off',
'max-lines-per-function': ['error', 150],
'max-params': 'off',
'max-statements': ['error', 100],
'multiline-comment-style': 'off',
'no-case-declarations': 'off',
'no-continue': 'off',
'no-global-assign': 'warn',
'no-inline-comments': 'off',
'no-lonely-if': 'off',
'no-magic-numbers': 'off',
'no-param-reassign': 'off',
'no-plusplus': 'off',
'no-unused-vars': 'warn',
'no-ternary': 'off',
'no-warning-comments': 'off',
'one-var': 'off',
'sort-keys': 'off',
'@stylistic/array-element-newline': ['error', 'consistent'],
'@stylistic/comma-dangle': ['error', 'only-multiline'],
'@stylistic/function-call-argument-newline': ['error', 'consistent'],
'@stylistic/dot-location': ['error', 'property'],
'@stylistic/indent': ['error', 2],
'@stylistic/quote-props': ['error', 'as-needed'],
'@stylistic/quotes': ['error', 'single'],
'@stylistic/padded-blocks': ['error', 'never']
}
},
{
files: ['**/*.mjs'],
languageOptions: {
globals: {
...globals.node
},
sourceType: 'module'
},
plugins: {
...eslintPluginStylistic.configs['all-flat'].plugins
},
rules: {
...eslintConfigs.all.rules,
...eslintPluginStylistic.configs['all-flat'].rules,
'func-style': 'off',
'max-lines-per-function': ['error', 100],
'no-magic-numbers': 'off',
'one-var': 'off',
'prefer-destructuring': 'off'
}
}
];
/*
* Set debug to true for testing purposes.
* Since some plugins have not yet been optimized for the flat config,
* we will be able to optimize this file in the future. It can be helpful
* to write the ESLint config to a file and compare it after changes.
*/
const debug = false;
if (debug === true) {
const FileSystem = require('fs');
FileSystem.writeFile('eslint-config-DEBUG.json', JSON.stringify(config, null, 2), (error) => {
if (error) {
throw error;
}
});
}
module.exports = config;