-
Notifications
You must be signed in to change notification settings - Fork 20
/
createAliasSetting.js
36 lines (35 loc) · 1.09 KB
/
createAliasSetting.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
/**
* create an ESLint `settings` object
* that help configure the import resolver with path mappings in the given tsconfig files.
* @param {Array<string>} [project] an array of glob patterns,
* pointing to tsconfig files that contains the "paths" mappings.
* Defaults to ['tsconfig.json', 'tsconfig.*.json']
* @returns an object to be spread into `settings` property of ESLint config.
*/
module.exports = function createAliasSetting(
project = ['**/tsconfig.json', '**/tsconfig.*.json'],
) {
return {
'import/resolver': {
// The Node resolver must come first
// https://github.com/benmosher/eslint-plugin-import/issues/1396
[require.resolve('eslint-import-resolver-node')]: {
extensions: [
'.mts',
'.ts',
'.tsx',
'.mjs',
'.js',
'.jsx',
'.json',
'.node',
],
},
[require.resolve('eslint-import-resolver-typescript')]: {
alwaysTryTypes: true,
// https://github.com/import-js/eslint-import-resolver-typescript#configuration
project,
},
},
};
};