1 | module.exports = {
|
2 | extends: [
|
3 | 'eslint:recommended',
|
4 | 'plugin:@typescript-eslint/recommended',
|
5 | 'prettier/@typescript-eslint',
|
6 | 'plugin:import/errors',
|
7 | 'plugin:prettier/recommended',
|
8 | 'plugin:eslint-comments/recommended',
|
9 | 'plugin:node/recommended',
|
10 | ],
|
11 | parser: '@typescript-eslint/parser',
|
12 | plugins: [
|
13 | // TODO(#37) remove this and the eslint-plugin-typescript package
|
14 | // becuase it's supposed to be replaced by @typescript-eslint
|
15 | // but IntelliJ doesn't work with @typescript-eslint for some reason
|
16 | 'typescript',
|
17 | '@typescript-eslint',
|
18 | 'import',
|
19 | 'absolute-import',
|
20 | 'json',
|
21 | 'prettier', // prettier must be last
|
22 | ],
|
23 | settings: {
|
24 | 'import/parsers': {
|
25 | '@typescript-eslint/parser': ['.ts', '.tsx'],
|
26 | },
|
27 | 'import/resolver': {
|
28 | node: {
|
29 | extensions: ['.js', '.jsx', '.ts', '.tsx', '.d.ts', '.module.scss'],
|
30 | },
|
31 |
|
32 | typescript: {
|
33 | alwaysTryTypes: true,
|
34 | // Use <root>/tsconfig.json by default. To override, use the "directory" option. See https://github.com/alexgorbatchev/eslint-import-resolver-typescript
|
35 | },
|
36 | },
|
37 | },
|
38 | rules: {
|
39 | // Replace the base rule with the typescript one so that it knows when type imports are used
|
40 | 'no-unused-vars': 'off',
|
41 | 'typescript/no-unused-vars': 'error',
|
42 | '@typescript-eslint/no-unused-vars': 'error',
|
43 |
|
44 | /* Import rules ******************************************************************/
|
45 | 'import/order': ['error', { 'newlines-between': 'always' }],
|
46 | 'no-restricted-imports': [
|
47 | 'error',
|
48 | {
|
49 | // disallow "import * from"
|
50 | patterns: ['\\*'],
|
51 | },
|
52 | ],
|
53 | 'import/no-duplicates': 'error',
|
54 | 'import/no-self-import': 'error',
|
55 | 'import/no-cycle': 'error',
|
56 |
|
57 | /* Absolute import rules ********************************************************/
|
58 | 'absolute-import/no-relative-path': 'error',
|
59 | 'absolute-import/no-unresolved': 'error',
|
60 |
|
61 | /* Explicit return types ********************************************************/
|
62 | '@typescript-eslint/explicit-function-return-type': [
|
63 | 'error',
|
64 | {
|
65 | // Allow something like `node.addEventListener('click', () => {});`
|
66 | // See https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/explicit-function-return-type.md#allowexpressions
|
67 | allowExpressions: true,
|
68 | },
|
69 | ],
|
70 |
|
71 | /* Async/await *****************************************************************/
|
72 | 'no-await-in-loop': 'error',
|
73 | 'no-return-await': 'error',
|
74 | 'require-await': 'error',
|
75 |
|
76 | /* Comments disabling Eslint **************************************************/
|
77 | 'eslint-comments/no-unused-disable': 'error',
|
78 |
|
79 | /* Node things ****************************************************************/
|
80 | // Use module.exports instead of exports directly
|
81 | 'node/exports-style': ['error', 'module.exports'],
|
82 | // Never allow using file extensions in import statements
|
83 | 'node/file-extension-in-import': ['error', 'never'],
|
84 | // Always use a global var for "console" without importing it
|
85 | 'node/prefer-global/console': ['error', 'always'],
|
86 | // Always use a global var for "process" without importing it
|
87 | 'node/prefer-global/process': ['error', 'always'],
|
88 | // Always require importing UrlSearchParams from 'url'
|
89 | 'node/prefer-global/url-search-params': ['error', 'never'],
|
90 | // Always require importing URL from 'url'
|
91 | 'node/prefer-global/url': ['error', 'never'],
|
92 | // Use async await instead of callbacks for filesystem calls
|
93 | 'node/prefer-promises/fs': ['error'],
|
94 | // Use async await instead of callbacks for dns calls
|
95 | 'node/prefer-promises/dns': ['error'],
|
96 |
|
97 | /* Code style *****************************************************************/
|
98 | 'prettier/prettier': [
|
99 | 'error',
|
100 | {
|
101 | printWidth: 100,
|
102 | singleQuote: true,
|
103 | trailingComma: 'es5',
|
104 | tabWidth: 2,
|
105 | semi: true,
|
106 | },
|
107 | ],
|
108 | },
|
109 | };
|