-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eslintrc.js
80 lines (67 loc) · 3.04 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
const { resolve } = require('path');
module.exports = {
// https://eslint.org/docs/user-guide/configuring#configuration-cascading-and-hierarchy
// This option interrupts the configuration hierarchy at this file
root: true,
// .eslintignore can't be extended as the same way as .eslintrc.js, so we put the common patterns here
ignorePatterns: ['dist', 'node_modules', '.eslintrc.js', 'babel.config.js'],
parser: '@typescript-eslint/parser',
parserOptions: {
// `project` and `tsconfigRootDir` needs to be re-defined in every package to pick up the correct paths
// https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/parser#configuration
// https://github.com/TypeStrong/fork-ts-checker-webpack-plugin#eslint
project: resolve(__dirname, './tsconfig.json'),
tsconfigRootDir: __dirname,
ecmaVersion: 2020, // Allows for the parsing of modern ECMAScript features
sourceType: 'module', // Allows for the use of imports
},
// Rules order is important, please avoid shuffling them
extends: [
// Base ESLint recommended rules
'eslint:recommended',
// https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin#usage
// ESLint typescript rules
'plugin:@typescript-eslint/recommended',
// consider disabling this class of rules if linting takes too long
'plugin:@typescript-eslint/recommended-requiring-type-checking',
// Needs to be after most rule sets to correctly override and avoid conflicts between ESLint and Prettier.
// So, you might need to redeclare this in a package's .eslintrc.js if you are using a new rule set such as eslint-plugin-vue.
// https://github.com/prettier/eslint-config-prettier#installation
// usage with Prettier, provided by 'eslint-config-prettier'.
'prettier',
],
plugins: [
// required to apply rules which need type information
'@typescript-eslint',
// https://github.com/typescript-eslint/typescript-eslint/issues/389#issuecomment-509292674
// Prettier has not been included as plugin to avoid performance impact
// add it as an extension for your IDE
],
globals: {
process: 'readonly',
},
rules: {
// --- Base ESLint ---
curly: 'error',
'no-else-return': ['warn', { allowElseIf: false }],
eqeqeq: 'error',
'no-alert': 'warn',
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'warn',
'no-console': [
process.env.NODE_ENV === 'production' ? 'error' : 'warn',
{ allow: ['error'] },
],
'prefer-const': 'warn',
// --- TypeScript ---
quotes: ['warn', 'single', { avoidEscape: true }],
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-unnecessary-condition': 'warn',
// Tried out '@typescript-eslint/no-magic-numbers' rule, but the number of false positives is too high
'@typescript-eslint/no-misused-promises': [
'error',
{
checksVoidReturn: false,
},
],
},
};