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

Commit beb3707

Browse files
committed
Add rule import/default
1 parent 0a35618 commit beb3707

File tree

4 files changed

+35
-1
lines changed

4 files changed

+35
-1
lines changed

scripts/generate-rule.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ function generateRuleFileContent(name, provider) {
4848
case '@typescript-eslint':
4949
RuleLink = `https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/${kebabCase}.md`;
5050
break;
51+
case 'import':
52+
RuleLink = `https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/${kebabCase}.md`;
53+
break;
5154
}
5255

5356
provider = provider === 'eslint' ? '' : `${provider}/`;
@@ -96,4 +99,6 @@ export interface ${PascalCase}Rule {
9699
`;
97100
}
98101

102+
fs.mkdirSync(ruleProviderDir, { mode: 0o755, recursive: true });
103+
99104
fs.writeFileSync(rulePath, generateRuleFileContent(ruleName, ruleProvider));

src/rules/import/default.d.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import type { RuleConfig } from '../rule-config';
2+
3+
/**
4+
* If a default import is requested, this rule will report if there is no default export in the imported module.
5+
*
6+
* @see [default](https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/default.md)
7+
*/
8+
export type DefaultRuleConfig = RuleConfig<[]>;
9+
10+
/**
11+
* If a default import is requested, this rule will report if there is no default export in the imported module.
12+
*
13+
* @see [default](https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/default.md)
14+
*/
15+
export interface DefaultRule {
16+
/**
17+
* If a default import is requested, this rule will report if there is no default export in the imported module.
18+
*
19+
* @see [default](https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/default.md)
20+
*/
21+
'import/default': DefaultRuleConfig;
22+
}

src/rules/import/index.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import type { DefaultRule } from './default';
2+
3+
/**
4+
* All import rules.
5+
*/
6+
export type ImportRules = DefaultRule;

src/rules/index.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { EslintRules } from './eslint';
2+
import type { ImportRules } from './import';
23
import type { JSDocRules } from './jsdoc';
34
import type { RuleConfig } from './rule-config';
45
import type { SpellcheckRules } from './spellcheck';
@@ -10,5 +11,5 @@ import type { TypeScriptEslintRules } from './typescript-eslint';
1011
* @see [Rules](https://eslint.org/docs/user-guide/configuring/rules)
1112
*/
1213
export type Rules = Partial<
13-
EslintRules & TypeScriptEslintRules & JSDocRules & SpellcheckRules & Record<string, RuleConfig>
14+
EslintRules & TypeScriptEslintRules & ImportRules & JSDocRules & SpellcheckRules & Record<string, RuleConfig>
1415
>;

0 commit comments

Comments
 (0)