-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eslintrc.js
102 lines (100 loc) · 2.8 KB
/
.eslintrc.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
102
const globals = require('eslint-restricted-globals');
const { configs: ts } = require('@typescript-eslint/eslint-plugin');
const project = require('./project.config');
const prettier = require('./.prettierrc');
const babel = require('./.babelrc');
const aliases =
babel &&
babel.plugins &&
babel.plugins
.filter((plugin) => Array.isArray(plugin))
.filter((plugin) => plugin[0] === 'babel-plugin-module-resolver')
.map((plugin) => plugin[1] && plugin[1].alias)[0];
module.exports = {
root: true,
extends: ['standard', 'plugin:import/errors', 'prettier'],
env: {
node: true,
jest: true
},
parserOptions: {
impliedStrict: true,
sourceType: 'module'
},
plugins: ['prettier', 'jest', 'import'],
globals: {},
rules: {
/* DISABLED */
'standard/no-callback-literal': 0,
/* WARNINGS */
'no-warning-comments': [
1,
{ terms: ['xxx', 'fixme', 'todo', 'refactor'], location: 'start' }
],
'no-unused-vars': 1,
'no-console': 1,
/* ERRORS */
// Add custom globals
'no-restricted-globals': [2, 'fetch'].concat(globals),
// Prettier
'prettier/prettier': [2, prettier]
},
settings: {
'import/resolver': {
alias: {
map: Object.entries(aliases || {}),
extensions: ['json']
.concat(project.get('ext.js').split(','))
.concat(
project.get('typescript') ? project.get('ext.ts').split(',') : []
)
.filter(Boolean)
.map((x) => '.' + x)
}
}
},
overrides: [
/* JAVASCRIPT */
{
files: [`*.{${project.get('ext.js')}}`],
parser: 'babel-eslint',
plugins: ['babel'],
rules: {
'babel/no-invalid-this': 1,
'babel/semi': 1
}
},
/* TYPESCRIPT */
{
files: [`*.{${project.get('ext.ts')}}`],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
// Overrides don't allow for extends
rules: {
...ts.recommended.rules,
/* DISABLED */
'@typescript-eslint/indent': 0,
'@typescript-eslint/no-explicit-any': 0,
'@typescript-eslint/no-object-literal-type-assertion': 0,
/* WARNINGS */
'@typescript-eslint/camelcase': 1,
'@typescript-eslint/explicit-function-return-type': [
1,
{ allowExpressions: true, allowTypedFunctionExpressions: true }
],
'@typescript-eslint/no-unused-vars': [
1,
{
args: 'after-used',
argsIgnorePattern: '_.*',
ignoreRestSiblings: true
}
],
/* ERRORS */
'@typescript-eslint/interface-name-prefix': [2, 'always'],
'@typescript-eslint/no-use-before-define': [2, { functions: false }],
'@typescript-eslint/array-type': [2, 'array-simple']
}
}
]
};