Skip to content
This repository was archived by the owner on May 12, 2025. It is now read-only.

Commit 1d5b279

Browse files
authored
chore: add documentation for import/no-unresolved rule (#285)
1 parent 48b7c49 commit 1d5b279

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

README.md

+12
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,18 @@ module.exports = {
116116

117117
My personal ESLint config file with support for Jest, Promises, and Prettier can be found in [create-exposed-app](https://github.com/iamturns/create-exposed-app/blob/master/.eslintrc.js).
118118

119+
### Why is `import/no-unresolved` disabled?
120+
121+
Two reasons:
122+
123+
1. It requires additional configuration, which may be different for monorepo's, webpack usage, etc
124+
2. The rule offers little value in a TypeScript world, as the TypeScript compiler will catch these errors
125+
126+
If you would like to enable this rule, then:
127+
128+
- Enable the rule within your config: `'import/no-unresolved': 'error'`
129+
- Install and configure the TypeScript import resolver: [eslint-import-resolver-typescript](https://www.npmjs.com/package/eslint-import-resolver-typescript)
130+
119131
## Additional Documentation
120132

121133
- [CHANGELOG.md](CHANGELOG.md)

index.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,17 @@ module.exports = {
33
extends: ['./lib/shared'].map(require.resolve),
44
settings: {
55
// Append 'ts' extensions to Airbnb 'import/resolver' setting
6+
// Prepend 'mjs' to match shared config
7+
// Original: ['.js', '.jsx', '.json']
68
'import/resolver': {
79
node: {
8-
extensions: ['.js', '.jsx', '.json', '.ts', '.tsx', '.d.ts'],
10+
extensions: ['.mjs', '.js', '.jsx', '.json', '.ts', '.tsx', '.d.ts'],
911
},
1012
},
1113
},
1214
rules: {
1315
// Append 'tsx' to Airbnb 'react/jsx-filename-extension' rule
14-
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-filename-extension.md
16+
// Original: ['.jsx']
1517
'react/jsx-filename-extension': ['error', { extensions: ['.jsx', '.tsx'] }],
1618
},
1719
};

lib/shared.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,14 @@ module.exports = {
1616
'@typescript-eslint/parser': ['.ts', '.tsx', '.d.ts'],
1717
},
1818
// Append 'ts' extensions to Airbnb 'import/resolver' setting
19+
// Original: ['.mjs', '.js', '.json']
1920
'import/resolver': {
2021
node: {
2122
extensions: ['.mjs', '.js', '.json', '.ts', '.d.ts'],
2223
},
2324
},
2425
// Append 'ts' extensions to Airbnb 'import/extensions' setting
26+
// Original: ['.js', '.mjs', '.jsx']
2527
'import/extensions': ['.js', '.mjs', '.jsx', '.ts', '.tsx', '.d.ts'],
2628
// Resolve type definition packages
2729
'import/external-module-folders': ['node_modules', 'node_modules/@types'],
@@ -279,7 +281,7 @@ module.exports = {
279281
// See: https://github.com/typescript-eslint/typescript-eslint/blob/13583e65f5973da2a7ae8384493c5e00014db51b/docs/linting/TROUBLESHOOTING.md#eslint-plugin-import
280282
'import/named': 'off',
281283
'import/no-named-as-default-member': 'off',
282-
// The following rule has likely been incorrectly disabled. This will be fixed in a separate PR.
284+
// Disable `import/no-unresolved`, see README.md for details
283285
'import/no-unresolved': 'off',
284286
},
285287
},

0 commit comments

Comments
 (0)