|
21 | 21 | // This is dangerous as it hides accidentally undefined variables.
|
22 | 22 | // We blacklist the globals that we deem potentially confusing.
|
23 | 23 | // To use them, explicitly reference them, e.g. `window.name` or `window.status`.
|
24 |
| -var restrictedGlobals = require('confusing-browser-globals'); |
| 24 | +const restrictedGlobals = require('confusing-browser-globals'); |
| 25 | + |
| 26 | +// The following is copied from `react-scripts/config/paths.js`. |
| 27 | +const path = require('path'); |
| 28 | +const fs = require('fs'); |
| 29 | +// Make sure any symlinks in the project folder are resolved: |
| 30 | +// https://github.com/facebook/create-react-app/issues/637 |
| 31 | +const appDirectory = fs.realpathSync(process.cwd()); |
| 32 | +const resolveApp = relativePath => path.resolve(appDirectory, relativePath); |
| 33 | +const projectRootPath = resolveApp('.'); |
| 34 | +const tsConfigPath = resolveApp('tsconfig.json'); |
25 | 35 |
|
26 | 36 | module.exports = {
|
27 | 37 | root: true,
|
@@ -52,6 +62,45 @@ module.exports = {
|
52 | 62 | },
|
53 | 63 | },
|
54 | 64 |
|
| 65 | + overrides: { |
| 66 | + files: ['**/*.ts', '**/*.tsx'], |
| 67 | + parser: '@typescript-eslint/parser', |
| 68 | + parserOptions: { |
| 69 | + ecmaVersion: 2018, |
| 70 | + sourceType: 'module', |
| 71 | + ecmaFeatures: { |
| 72 | + jsx: true, |
| 73 | + }, |
| 74 | + |
| 75 | + // typescript-eslint specific options |
| 76 | + project: tsConfigPath, |
| 77 | + tsconfigRootDir: projectRootPath, |
| 78 | + warnOnUnsupportedTypeScriptVersion: true, |
| 79 | + }, |
| 80 | + plugins: ['@typescript-eslint'], |
| 81 | + rules: { |
| 82 | + // These ESLint rules are known to cause issues with typescript-eslint |
| 83 | + // See https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/src/configs/recommended.json |
| 84 | + camelcase: 'off', |
| 85 | + indent: 'off', |
| 86 | + 'no-array-constructor': 'off', |
| 87 | + 'no-unused-vars': 'off', |
| 88 | + |
| 89 | + '@typescript-eslint/no-angle-bracket-type-assertion': 'warn', |
| 90 | + '@typescript-eslint/no-array-constructor': 'warn', |
| 91 | + '@typescript-eslint/no-namespace': 'error', |
| 92 | + '@typescript-eslint/no-unused-vars': [ |
| 93 | + 'warn', |
| 94 | + { |
| 95 | + args: 'none', |
| 96 | + ignoreRestSiblings: true, |
| 97 | + }, |
| 98 | + ], |
| 99 | + }, |
| 100 | + }, |
| 101 | + |
| 102 | + // NOTE: When adding rules here, you need to make sure they are compatible with |
| 103 | + // `typescript-eslint`, as some rules such as `no-array-constructor` aren't compatible. |
55 | 104 | rules: {
|
56 | 105 | // http://eslint.org/docs/rules/
|
57 | 106 | 'array-callback-return': 'warn',
|
|
0 commit comments