|
1 | 1 | /** @format */
|
2 | 2 |
|
3 | 3 | import * as path from 'path';
|
| 4 | +import * as fs from 'fs'; |
4 | 5 |
|
5 |
| -const eslintFolder = path.join(path.dirname(require.resolve('eslint')), '..'); |
6 |
| - |
7 |
| -const moduleResolverPath = path.join(eslintFolder, 'lib/shared/relative-module-resolver'); |
8 |
| -const ModuleResolver = require(moduleResolverPath); |
9 |
| - |
10 |
| -ModuleResolver.resolve = function(moduleName: string) { |
11 |
| - return require.resolve(moduleName); |
| 6 | +let parserOptions: { |
| 7 | + tsconfigRootDir?: string; |
| 8 | + project?: string; |
| 9 | + createDefaultProgram?: boolean; |
| 10 | +} = { |
| 11 | + project: './tsconfig.json', |
12 | 12 | };
|
13 | 13 |
|
| 14 | +if (!fs.existsSync(path.join(process.env.PWD || '.', './tsconfig.json'))) { |
| 15 | + parserOptions = { |
| 16 | + tsconfigRootDir: __dirname, |
| 17 | + project: './tsconfig.json', |
| 18 | + /** |
| 19 | + * parserOptions.createDefaultProgram |
| 20 | + * Default .false |
| 21 | + * This option allows you to request that when the setting is specified, |
| 22 | + * files will be allowed when not included in the projects defined by the provided files. |
| 23 | + * Using this option will incur significant performance costs. |
| 24 | + * This option is primarily included for backwards-compatibility. |
| 25 | + * See the project section above for more information.projecttsconfig.json |
| 26 | + */ |
| 27 | + createDefaultProgram: true, |
| 28 | + }; |
| 29 | +} |
| 30 | + |
14 | 31 | module.exports = {
|
15 | 32 | extends: [
|
16 | 33 | 'airbnb',
|
@@ -115,7 +132,5 @@ module.exports = {
|
115 | 132 | 'import/resolver': { node: { extensions: ['.js', '.jsx', '.ts', '.tsx', '.d.ts'] } },
|
116 | 133 | polyfills: ['fetch', 'Promise', 'URL', 'object-assign'],
|
117 | 134 | },
|
118 |
| - parserOptions: { |
119 |
| - project: './tsconfig.json', |
120 |
| - }, |
| 135 | + parserOptions, |
121 | 136 | };
|
0 commit comments