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

Commit d426963

Browse files
committed
Add rule max-lines
1 parent 3f2cee4 commit d426963

File tree

3 files changed

+62
-0
lines changed

3 files changed

+62
-0
lines changed

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ module.exports = defineConfig({
125125
'webextensions',
126126
'webworker',
127127
'wellknown',
128+
'whitespace',
128129
'writeable'
129130
]
130131
}

src/rules/eslint/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type { GroupedAccessorPairsRule } from './grouped-accessor-pairs';
44
import type { LinebreakStyleRule } from './linebreak-style';
55
import type { MaxClassesPerFileRule } from './max-classes-per-file';
66
import type { MaxLenRule } from './max-len';
7+
import type { MaxLinesRule } from './max-lines';
78
import type { NoCaseDeclarationsRule } from './no-case-declarations';
89
import type { NoConstantConditionRule } from './no-constant-condition';
910
import type { NoDebuggerRule } from './no-debugger';
@@ -23,6 +24,7 @@ export type EslintRules = CommaDangleRule &
2324
LinebreakStyleRule &
2425
MaxClassesPerFileRule &
2526
MaxLenRule &
27+
MaxLinesRule &
2628
NoCaseDeclarationsRule &
2729
NoConstantConditionRule &
2830
NoDebuggerRule &

src/rules/eslint/max-lines.d.ts

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import type { RuleConfig } from '../rule-config';
2+
3+
/**
4+
* Option.
5+
*/
6+
export type MaxLinesOption =
7+
| number
8+
| {
9+
/**
10+
* Enforces a maximum number of lines in a file.
11+
*
12+
* @default 300
13+
*
14+
* @see [max](https://eslint.org/docs/rules/max-lines#code)
15+
*/
16+
max?: number;
17+
/**
18+
* Ignore lines made up purely of whitespace.
19+
*
20+
* @default true
21+
*
22+
* @see [skipBlankLines](https://eslint.org/docs/rules/max-lines#skipblanklines)
23+
*/
24+
skipBlankLines?: boolean;
25+
/**
26+
* Ignore lines containing just comments.
27+
*
28+
* @default true
29+
*
30+
* @see [skipComments](https://eslint.org/docs/rules/max-lines#skipcomments)
31+
*/
32+
skipComments?: boolean;
33+
};
34+
35+
/**
36+
* Options.
37+
*/
38+
export type MaxLinesOptions = [MaxLinesOption?];
39+
40+
/**
41+
* Enforce a maximum file length.
42+
*
43+
* @see [max-lines](https://eslint.org/docs/rules/max-lines)
44+
*/
45+
export type MaxLinesRuleConfig = RuleConfig<MaxLinesOptions>;
46+
47+
/**
48+
* Enforce a maximum file length.
49+
*
50+
* @see [max-lines](https://eslint.org/docs/rules/max-lines)
51+
*/
52+
export interface MaxLinesRule {
53+
/**
54+
* Enforce a maximum file length.
55+
*
56+
* @see [max-lines](https://eslint.org/docs/rules/max-lines)
57+
*/
58+
'max-lines': MaxLinesRuleConfig;
59+
}

0 commit comments

Comments
 (0)