Gathering detailed insights and metrics for @kubit-ui-web/eslint-plugin-no-index-import
Gathering detailed insights and metrics for @kubit-ui-web/eslint-plugin-no-index-import
Gathering detailed insights and metrics for @kubit-ui-web/eslint-plugin-no-index-import
Gathering detailed insights and metrics for @kubit-ui-web/eslint-plugin-no-index-import
An ESLint plugin to disallow imports from index files.
npm install @kubit-ui-web/eslint-plugin-no-index-import
Typescript
Module System
Node Version
NPM Version
69.1
Supply Chain
98.7
Quality
77.9
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
395
Last Day
3
Last Week
23
Last Month
101
Last Year
395
4 Commits
1 Watching
1 Branches
1 Contributors
Minified
Minified + Gzipped
Latest Version
1.0.2
Package Id
@kubit-ui-web/eslint-plugin-no-index-import@1.0.2
Unpacked Size
34.48 kB
Size
8.34 kB
File Count
8
NPM Version
10.8.1
Node Version
22.3.0
Publised On
06 Nov 2024
Cumulative downloads
Total Downloads
Last day
200%
3
Compared to previous day
Last week
-4.2%
23
Compared to previous week
Last month
24.7%
101
Compared to previous month
Last year
0%
395
Compared to previous year
1
This ESLint plugin disallows imports from index files to enforce better module structure and avoid potential issues with circular dependencies.
To install the plugin, you need to have ESLint already installed in your project. If you don't have ESLint installed, you can install it using npm or yarn:
1npm install eslint --save-dev 2# or 3yarn add eslint --dev
Then, install the eslint-plugin-no-index-import plugin:
1npm install @kubit-ui-web/eslint-plugin-no-index-import --save-dev 2# or 3yarn add @kubit-ui-web/eslint-plugin-no-index-import --dev
To use the plugin, you need to add it to your ESLint configuration file (e.g., .eslintrc.js
).
Add no-index-import
to the plugins
array and configure the rule in the rules
section:
1module.exports = { 2 // Other ESLint configurations... 3 plugins: ['@kubit-ui-web/no-index-import'], 4 rules: { 5 '@kubit-ui-web/no-index-import/no-index-import': 'error', 6 }, 7};
You can also configure aliases and ignore specific imports:
1module.exports = { 2 // Other ESLint configurations... 3 plugins: ['@kubit-ui-web/no-index-import'], 4 rules: { 5 '@kubit-ui-web/no-index-import/no-index-import': [ 6 'error', 7 { 8 aliases: { 9 '@components': './src/components', 10 '@utils': './src/utils', 11 }, 12 ignoreImports: ['@/components/loader', '@/types/customToken'], 13 }, 14 ], 15 }, 16};
Here is an example of a complete ESLint configuration file with the no-index-import plugin:
1module.exports = { 2 env: { 3 browser: true, 4 es2021: true, 5 }, 6 extends: [ 7 'eslint:recommended', 8 'plugin:react/recommended', 9 'plugin:@typescript-eslint/recommended', 10 ], 11 parser: '@typescript-eslint/parser', 12 parserOptions: { 13 ecmaFeatures: { 14 jsx: true, 15 }, 16 ecmaVersion: 12, 17 sourceType: 'module', 18 }, 19 plugins: [ 20 'react', 21 '@typescript-eslint', 22 '@kubit-ui-web/no-index-import/no-index-import', 23 ], 24 rules: { 25 '@kubit-ui-web/no-index-import/no-index-import': [ 26 'error', 27 { 28 aliases: { 29 '@components': './src/components', 30 '@utils': './src/utils', 31 }, 32 ignoreImports: ['@/components/loader', '@/types/customToken'], 33 }, 34 ], 35 }, 36};
This rule disallows importing from index files or directories containing an index file. It helps to enforce better module structure and avoid potential issues with circular dependencies.
aliases
: An object where keys are alias names and values are the corresponding paths.ignoreImports
: An array of import paths to ignore.Given the following project structure:
1src/ 2 components/ 3 index.ts 4 button.ts 5 utils/ 6 index.ts 7 logger.ts 8 index.ts
The following imports would be disallowed:
1import { Button } from '@/components'; // Disallowed 2import { Logger } from '@/utils'; // Disallowed
But the following imports would be allowed:
1import { Button } from '@/components/button'; // Allowed 2import { Logger } from '@/utils/logger'; // Allowed
If you have any ideas, bug reports, or feature requests, feel free to open an issue or submit a pull request. We welcome contributions from the community and are happy to help with any questions you may have.
No vulnerabilities found.
No security vulnerabilities found.