|
1 |
| -module.exports = { |
2 |
| - extends: 'erb', |
3 |
| - plugins: ['@typescript-eslint'], |
| 1 | +const common = { |
| 2 | + env: { |
| 3 | + node: true, |
| 4 | + es6: true, |
| 5 | + 'jest/globals': true, |
| 6 | + }, |
| 7 | + plugins: ['prettier', 'jest', 'markdown', 'jsonc'], |
| 8 | + extends: [ |
| 9 | + 'airbnb-base', |
| 10 | + 'prettier', |
| 11 | + 'plugin:jest/all', |
| 12 | + 'plugin:json/recommended', |
| 13 | + ], |
4 | 14 | rules: {
|
5 |
| - // A temporary hack related to IDE not resolving correct package.json |
6 | 15 | 'import/no-extraneous-dependencies': 'off',
|
7 | 16 | 'react/react-in-jsx-scope': 'off',
|
8 | 17 | 'react/jsx-filename-extension': 'off',
|
| 18 | + 'prettier/prettier': 'error', |
| 19 | + 'jest/unbound-method': 'off', |
| 20 | + 'jest/no-disabled-tests': 'warn', |
| 21 | + 'jest/no-focused-tests': 'error', |
| 22 | + 'jest/no-identical-title': 'error', |
| 23 | + 'jest/prefer-to-have-length': 'warn', |
| 24 | + 'jest/valid-expect': 'error', |
| 25 | + 'jest/expect-expect': 'off', |
| 26 | + 'jest/prefer-expect-assertions': 'off', |
| 27 | + 'jest/no-test-return-statement': 'off', |
| 28 | + 'import/prefer-default-export': 'off', |
9 | 29 | 'import/extensions': 'off',
|
10 | 30 | 'import/no-unresolved': 'off',
|
11 | 31 | 'import/no-import-module-exports': 'off',
|
| 32 | + 'no-console': 'off', |
| 33 | + 'no-iterator': 'off', |
| 34 | + 'no-restricted-syntax': 'off', |
| 35 | + 'no-await-in-loop': 'off', |
12 | 36 | 'no-shadow': 'off',
|
13 |
| - '@typescript-eslint/no-shadow': 'error', |
14 | 37 | 'no-unused-vars': 'off',
|
| 38 | + 'no-underscore-dangle': 'off', |
| 39 | + 'no-plusplus': 'off', |
| 40 | + 'consistent-return': 'off', |
| 41 | + camelcase: 'off', |
| 42 | + 'jsonc/indent': ['error', 2], |
| 43 | + '@typescript-eslint/no-shadow': 'error', |
15 | 44 | '@typescript-eslint/no-unused-vars': 'error',
|
16 | 45 | },
|
17 |
| - parserOptions: { |
18 |
| - ecmaVersion: 2022, |
19 |
| - sourceType: 'module', |
| 46 | + globals: { |
| 47 | + fetch: true, |
| 48 | + window: true, |
| 49 | + document: true, |
| 50 | + __CDN_URL__: true, |
| 51 | + __DEV__: true, |
| 52 | + __TEST__: true, |
| 53 | + __CLIENT__: true, |
| 54 | + __SERVER__: true, |
| 55 | + __GRAPHQL_ENDPOINT__: true, |
| 56 | + __SSR__: true, |
| 57 | + __PERSIST_GQL__: true, |
| 58 | + __API_URL__: true, |
| 59 | + __WEBSITE_URL__: true, |
| 60 | + __FRONTEND_BUILD_DIR__: true, |
20 | 61 | },
|
21 |
| - settings: { |
22 |
| - 'import/resolver': { |
23 |
| - // See https://github.com/benmosher/eslint-plugin-import/issues/1396#issuecomment-575727774 for line below |
24 |
| - node: {}, |
25 |
| - webpack: { |
26 |
| - config: require.resolve('./.erb/configs/webpack.config.eslint.ts'), |
| 62 | +}; |
| 63 | + |
| 64 | +module.exports = { |
| 65 | + root: true, |
| 66 | + overrides: [ |
| 67 | + { |
| 68 | + /* |
| 69 | + eslint-plugin-markdown only finds javascript code block snippet. |
| 70 | + For specific spec, refer to https://github.com/eslint/eslint-plugin-markdown |
| 71 | + */ |
| 72 | + files: ['**/*.js', '**/*.md'], |
| 73 | + ...common, |
| 74 | + }, |
| 75 | + { |
| 76 | + files: ['**/*.ts'], |
| 77 | + parser: '@typescript-eslint/parser', |
| 78 | + env: common.env, |
| 79 | + plugins: [...common.plugins, '@typescript-eslint'], |
| 80 | + extends: [ |
| 81 | + ...common.extends, |
| 82 | + 'plugin:@typescript-eslint/recommended', |
| 83 | + 'plugin:import/errors', |
| 84 | + 'plugin:import/warnings', |
| 85 | + 'plugin:import/typescript', |
| 86 | + ], |
| 87 | + rules: { |
| 88 | + ...common.rules, |
| 89 | + '@typescript-eslint/explicit-function-return-type': 'off', |
| 90 | + }, |
| 91 | + settings: { |
| 92 | + 'import/resolver': { |
| 93 | + node: { |
| 94 | + extensions: [ |
| 95 | + '.js', |
| 96 | + '.jsx', |
| 97 | + '.ts', |
| 98 | + '.d.ts', |
| 99 | + '.tsx', |
| 100 | + '.graphql', |
| 101 | + '.gql', |
| 102 | + ], |
| 103 | + }, |
| 104 | + typescript: { |
| 105 | + // alwaysTryTypes: true, |
| 106 | + // paths: './tsconfig.json', |
| 107 | + }, |
| 108 | + }, |
27 | 109 | },
|
28 |
| - typescript: {}, |
29 | 110 | },
|
30 |
| - 'import/parsers': { |
31 |
| - '@typescript-eslint/parser': ['.ts', '.tsx'], |
| 111 | + { |
| 112 | + files: ['**/store/models/*.ts'], |
| 113 | + rules: { |
| 114 | + 'no-underscore-dangle': 'off', |
| 115 | + 'no-param-reassign': 'off', |
| 116 | + 'func-names': 'off', |
| 117 | + }, |
32 | 118 | },
|
33 |
| - }, |
| 119 | + { |
| 120 | + files: ['**/services/*.ts'], |
| 121 | + rules: { |
| 122 | + 'no-useless-constructor': 'off', |
| 123 | + }, |
| 124 | + }, |
| 125 | + { |
| 126 | + files: ['**/server/**/store/**/*.ts'], |
| 127 | + rules: { |
| 128 | + 'jest/require-hook': 'off', |
| 129 | + }, |
| 130 | + }, |
| 131 | + ], |
34 | 132 | };
|
0 commit comments