import-js / import-js/eslint-plugin-import
No errors for TypeScript `import` types
Open
Nobody has claimed this yet.
enhancement
help wanted
typescript
- Dominant language
- JavaScript
- Stars
- 5.9k
- Forks
- 1.5k
- PR merge metrics
- No merged PRs in 30d
Description
Docs on import types: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-9.html#import-types
Reduced test case (all dependencies are latest):
// ./cypress/test.ts
// Expected error, got one
// Unexpected path "../app/helpers/api" imported in restricted zone
import Api from '../app/helpers/api';
// Expected error, but got none
type Api = typeof import('../app/helpers/api');
// .eslintrc.js
const config = {
extends: ['plugin:import/typescript'],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 6,
sourceType: 'module',
},
plugins: ['import'],
rules: {
'import/no-restricted-paths': [
2,
{
basePath: '.',
zones: [
{
target: './cypress',
from: './app',
},
],
},
],
},
}
module.exports = config;
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the reduced case in cypress/test.ts with the .eslintrc.js configuration and the import/no-restricted-paths rule. Read the rule's handling of TypeScript import types and compare it with the documented import-types syntax; done means the type-only import reports the same restricted-path error as the regular import.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- eslint, typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100