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

Commit 8f80421

Browse files
committed
Add rule max-len
1 parent 82161e1 commit 8f80421

File tree

3 files changed

+117
-0
lines changed

3 files changed

+117
-0
lines changed

.eslintrc.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ module.exports = defineConfig({
104104
'jsdoc',
105105
'jsx',
106106
'lang',
107+
'len',
107108
'linebreak',
108109
'loc',
109110
'multiline',
@@ -119,6 +120,7 @@ module.exports = defineConfig({
119120
'tsconfig',
120121
'typedarrays',
121122
'unix',
123+
'urls',
122124
'vue',
123125
'webextensions',
124126
'webworker',

src/rules/eslint/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { CurlyRule } from './curly';
33
import type { GroupedAccessorPairsRule } from './grouped-accessor-pairs';
44
import type { LinebreakStyleRule } from './linebreak-style';
55
import type { MaxClassesPerFileRule } from './max-classes-per-file';
6+
import type { MaxLenRule } from './max-len';
67
import type { NoCaseDeclarationsRule } from './no-case-declarations';
78
import type { NoDebuggerRule } from './no-debugger';
89
import type { QuotesRule } from './quotes';
@@ -16,6 +17,7 @@ export type EslintRules = CommaDangleRule &
1617
GroupedAccessorPairsRule &
1718
LinebreakStyleRule &
1819
MaxClassesPerFileRule &
20+
MaxLenRule &
1921
NoCaseDeclarationsRule &
2022
NoDebuggerRule &
2123
QuotesRule &

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

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
import type { RuleConfig } from '../rule-config';
2+
3+
/**
4+
* Option.
5+
*/
6+
export type MaxLenOption = {
7+
/**
8+
* Enforces a maximum line length.
9+
*
10+
* @default 80
11+
*
12+
* @see [code](https://eslint.org/docs/rules/max-len#code)
13+
*/
14+
code?: number;
15+
/**
16+
* Specifies the character width for tab characters.
17+
*
18+
* @default 4
19+
*
20+
* @see [tabWidth](https://eslint.org/docs/rules/max-len#tabwidth)
21+
*/
22+
tabWidth?: number;
23+
/**
24+
* Enforces a maximum line length for comments.
25+
*
26+
* @default - to value of code.
27+
*
28+
* @see [comments](https://eslint.org/docs/rules/max-len#comments)
29+
*/
30+
comments?: number;
31+
/**
32+
* Ignores lines matching a regular expression
33+
*
34+
* Can only match a single line and need to be double escaped when written in YAML or JSON.
35+
*
36+
* @see [ignorePattern](https://eslint.org/docs/rules/max-len#ignorepattern)
37+
*/
38+
ignorePattern?: string;
39+
/**
40+
* Ignores all trailing comments and comments on their own line.
41+
*
42+
* @default true
43+
*
44+
* @see [ignoreComments](https://eslint.org/docs/rules/max-len#ignorecomments)
45+
*/
46+
ignoreComments?: boolean;
47+
/**
48+
* Ignores only trailing comments.
49+
*
50+
* @default true
51+
*
52+
* @see [ignoreTrailingComments](https://eslint.org/docs/rules/max-len#ignoretrailingcomments)
53+
*/
54+
ignoreTrailingComments?: boolean;
55+
/**
56+
* Ignores lines that contain a URL.
57+
*
58+
* @default true
59+
*
60+
* @see [ignoreUrls](https://eslint.org/docs/rules/max-len#ignoreurls)
61+
*/
62+
ignoreUrls?: boolean;
63+
/**
64+
* Ignores lines that contain a double-quoted or single-quoted string.
65+
*
66+
* @default true
67+
*
68+
* @see [ignoreStrings](https://eslint.org/docs/rules/max-len#ignorestrings)
69+
*/
70+
ignoreStrings?: boolean;
71+
/**
72+
* Ignores lines that contain a template literal.
73+
*
74+
* @default true
75+
*
76+
* @see [ignoreTemplateLiterals](https://eslint.org/docs/rules/max-len#ignoretemplateliterals)
77+
*/
78+
ignoreTemplateLiterals?: boolean;
79+
/**
80+
* Ignores lines that contain a RegExp literal.
81+
*
82+
* @default true
83+
*
84+
* @see [ignoreRegExpLiterals](https://eslint.org/docs/rules/max-len#ignoreregexpliterals)
85+
*/
86+
ignoreRegExpLiterals?: boolean;
87+
};
88+
89+
/**
90+
* Options.
91+
*/
92+
export type MaxLenOptions = [MaxLenOption?];
93+
94+
/**
95+
* Enforce a maximum line length.
96+
*
97+
* @see [max-len](https://eslint.org/docs/rules/max-len)
98+
*/
99+
export type MaxLenRuleConfig = RuleConfig<MaxLenOptions>;
100+
101+
/**
102+
* Enforce a maximum line length.
103+
*
104+
* @see [max-len](https://eslint.org/docs/rules/max-len)
105+
*/
106+
export interface MaxLenRule {
107+
/**
108+
* Enforce a maximum line length.
109+
*
110+
* @see [max-len](https://eslint.org/docs/rules/max-len)
111+
*/
112+
'max-len': MaxLenRuleConfig;
113+
}

0 commit comments

Comments
 (0)