Skip to content

Commit bda41ad

Browse files
committed
feat: add new import rules
1 parent 9cdc59c commit bda41ad

File tree

6 files changed

+293
-1
lines changed

6 files changed

+293
-1
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
},
5252
"dependencies": {
5353
"eslint-plugin-astro": "^1.3.1",
54+
"eslint-plugin-import": "^2.31.0",
5455
"eslint-plugin-jsdoc": "^50.6.3",
5556
"eslint-plugin-jsonc": "^2.19.1",
5657
"eslint-plugin-jsx-a11y": "^6.10.2",

pnpm-lock.yaml

Lines changed: 178 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/configs/base.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export const baseConfig = async ({
3434
],
3535
'no-alert': 'error',
3636
'no-console': ['error', { allow: ['warn', 'error'] }],
37+
'no-duplicate-imports': 'error',
3738
'no-var': 'error',
3839
'prefer-const': 'error'
3940
}

src/configs/import.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { filesFactory } from '../utils.js';
2+
3+
import type { Config, Options } from '../types.js';
4+
5+
export const importConfig = async ({ fileRoots }: Pick<Options, 'fileRoots'>): Promise<Config[]> => {
6+
const { default: importPlugin } = await import('eslint-plugin-import');
7+
return [
8+
{
9+
files: filesFactory(['**/*.js', '**/*.jsx', '**/*.cjs', '**/*.mjs', '**/*.ts', '**/*.tsx'], fileRoots),
10+
plugins: {
11+
import: importPlugin
12+
},
13+
rules: {
14+
'import/consistent-type-specifier-style': ['error', 'prefer-top-level'],
15+
'import/exports-last': 'error'
16+
}
17+
}
18+
];
19+
};

0 commit comments

Comments
 (0)