-
Notifications
You must be signed in to change notification settings - Fork 2
/
eslint.config.js
99 lines (89 loc) · 3.29 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
const eslint = require('@eslint/js')
const recommended = eslint.configs.recommended.rules
const stylistic = require('@stylistic/eslint-plugin-js')
const arcRules = require('./src/rules')
const fp = require('eslint-plugin-fp')
// TODO: re-enable eslint-plugin-import once eslint-plugin-import#2948 is fixed
// const importPlugin = require('eslint-plugin-import')
const globals = require('./globals.json')
const { node } = globals
const ecmaVersion = 13 // 2022
const off = 'off'
const err = 'error'
const s = '@stylistic/js/'
const config = {
plugins: {
recommended,
arc: arcRules,
'@stylistic/js': stylistic,
fp,
// importPlugin,
},
rules: {
// Previously on `eslint:recommended`:
...recommended,
// Disable rules from base configurations
'arrow-body-style': off,
'no-console': off,
'no-inner-declarations': off,
'no-redeclare': off,
'no-useless-escape': off,
// Enable additional rules
'global-require': off,
'handle-callback-err': err,
[s + 'linebreak-style']: [ err, 'unix' ],
'no-cond-assign': [ err, 'always' ],
// Style
[s + 'array-bracket-spacing']: [ err, 'always' ],
[s + 'arrow-spacing']: err,
[s + 'block-spacing']: err,
[s + 'brace-style']: [ err, 'stroustrup', { allowSingleLine: true } ],
[s + 'comma-dangle']: [ err, 'always-multiline' ],
[s + 'comma-spacing']: [ err, { before: false, after: true } ],
[s + 'computed-property-spacing']: err,
[s + 'eol-last']: err,
'fp/no-class': err,
[s + 'function-call-spacing']: err,
'func-style': [ err, 'declaration', { allowArrowFunctions: true } ],
[s + 'indent']: [ err, 2 ],
[s + 'key-spacing']: [ err, { beforeColon: false, mode: 'minimum' } ],
[s + 'keyword-spacing']: err,
[s + 'no-mixed-operators']: err,
[s + 'no-trailing-spaces']: err,
[s + 'object-curly-spacing']: [ err, 'always' ],
[s + 'quotes']: [ err, 'single', { allowTemplateLiterals: true, avoidEscape: true } ],
[s + 'semi']: [ err, 'never' ],
[s + 'space-before-blocks']: err,
[s + 'space-before-function-paren']: err,
[s + 'space-infix-ops']: err,
[s + 'spaced-comment']: err,
[s + 'template-curly-spacing']: err,
// Ensure filesystem safe filenames
'arc/match-regex': [ err, '^[a-z0-9-_.]+$', true ],
// Modules must resolve
// 'import/no-unresolved': [ err, { commonjs: true, amd: true } ],
},
}
const arc = [
// As of ESLint v9 flat config, *.js is assumed to be ESM, so undo that:
{
files: [ '**/*.js', '**/*.cjs' ],
languageOptions: {
ecmaVersion,
globals: node,
sourceType: 'commonjs',
},
...config,
},
{
files: [ '**/*.mjs' ],
languageOptions: {
ecmaVersion,
globals: node,
sourceType: 'module',
},
...config,
},
]
arc.globals = globals
module.exports = arc