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

Commit d436979

Browse files
Add support for N (#130)
Co-authored-by: Shinigami92 <[email protected]>
1 parent 347d182 commit d436979

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+2157
-0
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
"eslint-plugin-inclusive-language": "~2.2.0",
6565
"eslint-plugin-jsdoc": "~39.3.6",
6666
"eslint-plugin-mdx": "~2.0.5",
67+
"eslint-plugin-n": "~15.3.0",
6768
"eslint-plugin-node": "~11.1.0",
6869
"eslint-plugin-prettier": "~4.2.1",
6970
"eslint-plugin-spellcheck": "~0.0.19",

pnpm-lock.yaml

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

scripts/generate-rule-files.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import * as eslintPluginMdx from 'eslint-plugin-mdx';
1313
// @ts-expect-error
1414
import eslintPluginNode from 'eslint-plugin-node';
1515
// @ts-expect-error
16+
import eslintPluginN from 'eslint-plugin-n';
17+
// @ts-expect-error
1618
import eslintPluginSpellcheck from 'eslint-plugin-spellcheck';
1719
// @ts-expect-error
1820
import eslintPluginUnicorn from 'eslint-plugin-unicorn';
@@ -64,6 +66,10 @@ const generationMap: Record<string, Plugin> = {
6466
name: 'Mdx',
6567
rules: eslintPluginMdx.rules,
6668
},
69+
n: {
70+
name: 'N',
71+
rules: (eslintPluginN as Plugin).rules,
72+
},
6773
node: {
6874
name: 'Node',
6975
rules: (eslintPluginNode as Plugin).rules,

src/extends/eslint-plugin-n.d.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/**
2+
* Eslint N (Node) extensions.
3+
*
4+
* @see [Eslint N extensions](https://github.com/eslint-community/eslint-plugin-n#-configs)
5+
*/
6+
export type NExtensions =
7+
| 'plugin:n/recommended'
8+
| 'plugin:n/recommended-module'
9+
| 'plugin:n/recommended-script';

src/extends/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { EslintExtensions } from './eslint';
33
import type { ImportExtensions } from './eslint-plugin-import';
44
import type { JsdocExtensions } from './eslint-plugin-jsdoc';
55
import type { MdxExtensions } from './eslint-plugin-mdx';
6+
import type { NExtensions } from './eslint-plugin-n';
67
import type { NodeExtensions } from './eslint-plugin-node';
78
import type { PrettierExtensions } from './eslint-plugin-prettier';
89
import type { UnicornExtensions } from './eslint-plugin-unicorn';
@@ -20,6 +21,7 @@ export type KnownExtensions = LiteralUnion<
2021
| IntlifyVueI18nExtensions
2122
| JsdocExtensions
2223
| MdxExtensions
24+
| NExtensions
2325
| NodeExtensions
2426
| PrettierExtensions
2527
| TypescriptEslintExtensions

src/rules/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { EslintRules } from './eslint';
22
import type { ImportRules } from './import';
33
import type { JSDocRules } from './jsdoc';
4+
import type { NRules } from './n';
45
import type { NodeRules } from './node';
56
import type { RuleConfig } from './rule-config';
67
import type { SpellcheckRules } from './spellcheck';
@@ -20,6 +21,7 @@ export type Rules = Partial<
2021
ImportRules &
2122
JSDocRules &
2223
NodeRules &
24+
NRules &
2325
SpellcheckRules &
2426
TypeScriptRules &
2527
UnicornRules &

src/rules/n/callback-return.d.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import type { RuleConfig } from '../rule-config';
2+
3+
/**
4+
* Option.
5+
*/
6+
export type CallbackReturnOption = string[];
7+
8+
/**
9+
* Options.
10+
*/
11+
export type CallbackReturnOptions = [CallbackReturnOption?];
12+
13+
/**
14+
* Require `return` statements after callbacks.
15+
*
16+
* @see [callback-return](https://github.com/weiran-zsd/eslint-plugin-node/blob/HEAD/docs/rules/callback-return.md)
17+
*/
18+
export type CallbackReturnRuleConfig = RuleConfig<CallbackReturnOptions>;
19+
20+
/**
21+
* Require `return` statements after callbacks.
22+
*
23+
* @see [callback-return](https://github.com/weiran-zsd/eslint-plugin-node/blob/HEAD/docs/rules/callback-return.md)
24+
*/
25+
export interface CallbackReturnRule {
26+
/**
27+
* Require `return` statements after callbacks.
28+
*
29+
* @see [callback-return](https://github.com/weiran-zsd/eslint-plugin-node/blob/HEAD/docs/rules/callback-return.md)
30+
*/
31+
'n/callback-return': CallbackReturnRuleConfig;
32+
}

src/rules/n/exports-style.d.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import type { RuleConfig } from '../rule-config';
2+
3+
/**
4+
* Config.
5+
*/
6+
export interface ExportsStyleConfig {
7+
allowBatchAssign?: boolean;
8+
}
9+
10+
/**
11+
* Option.
12+
*/
13+
export type ExportsStyleOption = 'module.exports' | 'exports';
14+
15+
/**
16+
* Options.
17+
*/
18+
export type ExportsStyleOptions = [ExportsStyleOption?, ExportsStyleConfig?];
19+
20+
/**
21+
* Enforce either `module.exports` or `exports`.
22+
*
23+
* @see [exports-style](https://github.com/weiran-zsd/eslint-plugin-node/blob/HEAD/docs/rules/exports-style.md)
24+
*/
25+
export type ExportsStyleRuleConfig = RuleConfig<ExportsStyleOptions>;
26+
27+
/**
28+
* Enforce either `module.exports` or `exports`.
29+
*
30+
* @see [exports-style](https://github.com/weiran-zsd/eslint-plugin-node/blob/HEAD/docs/rules/exports-style.md)
31+
*/
32+
export interface ExportsStyleRule {
33+
/**
34+
* Enforce either `module.exports` or `exports`.
35+
*
36+
* @see [exports-style](https://github.com/weiran-zsd/eslint-plugin-node/blob/HEAD/docs/rules/exports-style.md)
37+
*/
38+
'n/exports-style': ExportsStyleRuleConfig;
39+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import type { RuleConfig } from '../rule-config';
2+
3+
/**
4+
* Config.
5+
*/
6+
export interface FileExtensionInImportConfig {
7+
[k: string]: 'always' | 'never';
8+
}
9+
10+
/**
11+
* Option.
12+
*/
13+
export type FileExtensionInImportOption = 'always' | 'never';
14+
15+
/**
16+
* Options.
17+
*/
18+
export type FileExtensionInImportOptions = [
19+
FileExtensionInImportOption?,
20+
FileExtensionInImportConfig?,
21+
];
22+
23+
/**
24+
* Enforce the style of file extensions in `import` declarations.
25+
*
26+
* @see [file-extension-in-import](https://github.com/weiran-zsd/eslint-plugin-node/blob/HEAD/docs/rules/file-extension-in-import.md)
27+
*/
28+
export type FileExtensionInImportRuleConfig =
29+
RuleConfig<FileExtensionInImportOptions>;
30+
31+
/**
32+
* Enforce the style of file extensions in `import` declarations.
33+
*
34+
* @see [file-extension-in-import](https://github.com/weiran-zsd/eslint-plugin-node/blob/HEAD/docs/rules/file-extension-in-import.md)
35+
*/
36+
export interface FileExtensionInImportRule {
37+
/**
38+
* Enforce the style of file extensions in `import` declarations.
39+
*
40+
* @see [file-extension-in-import](https://github.com/weiran-zsd/eslint-plugin-node/blob/HEAD/docs/rules/file-extension-in-import.md)
41+
*/
42+
'n/file-extension-in-import': FileExtensionInImportRuleConfig;
43+
}

src/rules/n/global-require.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+
* Require `require()` calls to be placed at top-level module scope.
5+
*
6+
* @see [global-require](https://github.com/weiran-zsd/eslint-plugin-node/blob/HEAD/docs/rules/global-require.md)
7+
*/
8+
export type GlobalRequireRuleConfig = RuleConfig<[]>;
9+
10+
/**
11+
* Require `require()` calls to be placed at top-level module scope.
12+
*
13+
* @see [global-require](https://github.com/weiran-zsd/eslint-plugin-node/blob/HEAD/docs/rules/global-require.md)
14+
*/
15+
export interface GlobalRequireRule {
16+
/**
17+
* Require `require()` calls to be placed at top-level module scope.
18+
*
19+
* @see [global-require](https://github.com/weiran-zsd/eslint-plugin-node/blob/HEAD/docs/rules/global-require.md)
20+
*/
21+
'n/global-require': GlobalRequireRuleConfig;
22+
}

0 commit comments

Comments
 (0)