web-infra-dev / web-infra-dev/rslint
[Tracking]: eslint-plugin-import rules
- Dominant language
- Go
- Stars
- 459
- Forks
- 33
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 376
Description
### What problem does this feature solve?
Port https://www.npmjs.com/package/eslint-plugin-import
### What does the proposed API of configuration look like?
```ts
// rslint.config.ts
import { defineConfig } from '@rslint/core';
export default defineConfig([
{
plugins: ['import'],
rules: {
'import/no-commonjs': 'error',
'import/no-cycle': 'error',
'import/first': 'error',
'import/newline-after-import': 'error',
// ...
},
},
]);
```
### Rules
#### Helpful warnings
- [ ] [Recommended] [export](https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/export.md): Forbid any invalid exports, i.e. re-export of the same name
- [ ] [no-deprecated](https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-deprecated.md): Forbid imported names marked with `@deprecated` documentation tag
- [ ] [no-empty-named-blocks](https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-empty-named-blocks.md): Forbid empty named import blocks
- [ ] [no-extraneous-dependencies](https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-extraneous-dependencies.md): Forbid the use of extraneous packages
- [x] [no-mutable-exports](https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-mutable-exports.md): Forbid the use of mutable exports with `var` or `let`
- https://github.com/web-infra-dev/rslint/pull/649
- [ ] [Recommended] [no-named-as-default](https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-named-as-default.md): Forbid use of exported name as identifier of default export
- [ ] [Recommended] [no-named-as-default-member](https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-named-as-default-member.md): Forbid use of exported name as property of default export
- [ ] [no-unused-modules](https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-unused-modules.md): Forbid modules without exports, or exports without matching import in another module
#### Module systems
- [ ] [no-amd](https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-amd.md): Forbid AMD `require` and `define` calls
- [ ] [no-commonjs](https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-commonjs.md): Forbid CommonJS `require` calls and `module.exports` or `exports.*`
- [ ] [no-import-module-exports](https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-import-module-exports.md): Forbid import statements with CommonJS module.exports
- [ ] [no-nodejs-modules](https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-nodejs-modules.md): Forbid Node.js builtin modules
- [ ] [unambiguous](https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/unambiguous.md): Forbid potentially ambiguous parse goal (`script` vs. `module`)
#### Static analysis
- [x] [Recommended] [default](https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/default.md): Ensure a default export is present, given a default import
- https://github.com/web-infra-dev/rslint/pull/1199
- [ ] [enforce-node-protocol-usage](https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/enforce-node-protocol-usage.md): Enforce either using, or omitting, the `node:` protocol when importing Node.js builtin modules
- [ ] [Recommended] [named](https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/named.md): Ensure named imports correspond to a named export in the remote file
- [x] [Recommended] [namespace](https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/namespace.md): Ensure imported namespaces contain dereferenced properties as they are dereferenced
- https://github.com/web-infra-dev/rslint/pull/1207
- [ ] [no-absolute-path](https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-absolute-path.md): Forbid import of modules using absolute paths
- [x] [no-cycle](https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-cycle.md): Forbid a module from importing a module with a dependency path back to itself
- https://github.com/web-infra-dev/rslint/pull/1215
- [ ] [no-dynamic-require](https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-dynamic-require.md): Forbid `require()` calls with expressions
- [ ] [no-internal-modules](https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-internal-modules.md): Forbid importing the submodules of other modules
- [ ] [no-relative-packages](https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-relative-packages.md): Forbid importing packages through relative paths
- [ ] [no-relative-parent-imports](https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-relative-parent-imports.md): Forbid importing modules from parent directories
- [x] [no-restricted-paths](https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-restricted-paths.md): Enforce which files can be imported in a given folder
- https://github.com/web-infra-dev/rslint/pull/1561
- [x] [no-self-import](https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-self-import.md): Forbid a module from importing itself
- https://github.com/web-infra-dev/rslint/pull/215
- [ ] [Recommended] [no-unresolved](https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-unresolved.md): Ensure imports point to a file/module that can be resolved
- [ ] [no-useless-path-segments](https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-useless-path-segments.md): Forbid unnecessary path segments in import and require statements
- [x] [no-webpack-loader-syntax](https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-webpack-loader-syntax.md): Forbid webpack loader syntax in imports
- https://github.com/web-infra-dev/rslint/pull/339
#### Style guide
- [ ] [consistent-type-specifier-style](https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/consistent-type-specifier-style.md): Enforce or ban the use of inline type-only markers for named imports
- [ ] [dynamic-import-chunkname](https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/dynamic-import-chunkname.md): Enforce a leading comment with the webpackChunkName for dynamic imports
- [ ] [exports-last](https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/exports-last.md): Ensure all exports appear after other statements
- [ ] [extensions](https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/extensions.md): Ensure consistent use of file extension within the import path
- [x] [first](https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/first.md): Ensure all imports appear before other statements
- https://github.com/web-infra-dev/rslint/pull/647
- [ ] [group-exports](https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/group-exports.md): Prefer named exports to be grouped together in a single export declaration
- [ ] [imports-first](https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/imports-first.md): Replaced by `import/first` (deprecated)
- [ ] [max-dependencies](https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/max-dependencies.md): Enforce the maximum number of dependencies a module can have
- [x] [newline-after-import](https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/newline-after-import.md): Enforce a newline after import statements
- https://github.com/web-infra-dev/rslint/pull/646
- [ ] [no-anonymous-default-export](https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-anonymous-default-export.md): Forbid anonymous values as default exports
- [x] [no-default-export](https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-default-export.md): Forbid default exports
- https://github.com/web-infra-dev/rslint/pull/1218
- [x] [Recommended] [no-duplicates](https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-duplicates.md): Forbid repeated import of the same module in multiple places
- https://github.com/web-infra-dev/rslint/pull/656
- [ ] [no-named-default](https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-named-default.md): Forbid named default exports
- [ ] [no-named-export](https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-named-export.md): Forbid named exports
- [ ] [no-namespace](https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-namespace.md): Forbid namespace (a.k.a. "wildcard" `*`) imports
- [ ] [no-unassigned-import](https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-unassigned-import.md): Forbid unassigned imports
- [x] [order](https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/order.md): Enforce a convention in module import order
- https://github.com/web-infra-dev/rslint/pull/1783
- [ ] [prefer-default-export](https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/prefer-default-export.md): Prefer a default export if module exports a single name or multiple names
Contributor guide
Assessment
This issue has not been assessed yet.