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

Commit 86f2aed

Browse files
committed
Improve rules
1 parent 0549d94 commit 86f2aed

File tree

7 files changed

+62
-5
lines changed

7 files changed

+62
-5
lines changed

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// @ts-check
12
const { defineConfig } = require('eslint-define-config');
23

34
module.exports = defineConfig({

src/index.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ export interface EslintConfig {
2626
parser?: string;
2727
parserOptions?: ParserOptions;
2828
plugins?: string[];
29+
/**
30+
* Rules.
31+
*
32+
* @see [Rules](https://eslint.org/docs/user-guide/configuring/rules)
33+
*/
2934
rules?: Rules;
3035
overrides?: Overrides;
3136
settings?: Settings;

src/rules/eslint/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ import type { QuotesRule } from './quotes';
33
import type { SemiRule } from './semi';
44

55
/**
6-
*
6+
* All eslint rules.
77
*/
88
export type EslintRules = NoDebuggerRule & QuotesRule & SemiRule;

src/rules/eslint/no-debugger.d.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
import type { RuleConfig } from '../rule-config';
22

33
/**
4+
* Disallow the use of debugger.
45
*
6+
* @see [no-debugger](https://eslint.org/docs/rules/no-debugger)
57
*/
6-
export type NoDebuggerRuleConfig = RuleConfig<[]>;
8+
export type NoDebuggerRuleConfig = RuleConfig;
79

810
/**
11+
* Disallow the use of debugger.
912
*
13+
* @see [no-debugger](https://eslint.org/docs/rules/no-debugger)
1014
*/
1115
export interface NoDebuggerRule {
1216
/**

src/rules/eslint/quotes.d.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import type { RuleConfig } from '../rule-config';
22

33
/**
4-
*
4+
* Options.
55
*/
66
export type QuotesOption = 'double' | 'single' | 'backtick';
77

88
/**
9-
*
9+
* Config.
1010
*/
1111
export interface QuotesConfig {
1212
/**
@@ -20,12 +20,16 @@ export interface QuotesConfig {
2020
}
2121

2222
/**
23+
* Enforce the consistent use of either backticks, double, or single quotes.
2324
*
25+
* @see [quotes](https://eslint.org/docs/rules/quotes)
2426
*/
2527
export type QuotesRuleConfig = RuleConfig<[QuotesOption, QuotesConfig]>;
2628

2729
/**
30+
* Enforce the consistent use of either backticks, double, or single quotes.
2831
*
32+
* @see [quotes](https://eslint.org/docs/rules/quotes)
2933
*/
3034
export interface QuotesRule {
3135
/**

src/rules/eslint/semi.d.ts

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,53 @@
11
import type { RuleConfig } from '../rule-config';
22

33
/**
4+
* Always Config.
5+
*/
6+
export interface SemiAlwaysConfig {
7+
/**
8+
* Ignores the last semicolon in a block in which its braces (and therefore the content of the block) are in the same line.
9+
*/
10+
omitLastInOneLineBlock?: boolean;
11+
}
12+
13+
/**
14+
* Always Options.
15+
*/
16+
export type SemiAlwaysOptions = ['always'] | ['always', SemiAlwaysConfig];
17+
18+
/**
19+
* Never Config.
20+
*/
21+
export interface SemiNeverConfig {
22+
/**
23+
* - `'any'` - Ignores semicolons (or lacking semicolon) at the end of statements if the next line starts with `[`, `(`, `/`, `+`, or `-`.
24+
* - `'always'` - Requires semicolons at the end of statements if the next line starts with `[`, `(`, `/`, `+`, or `-`.
25+
* - `'never'` - Disallows semicolons as the end of statements if it doesn't make ASI hazard even if the next line starts with `[`, `(`, `/`, `+`, or `-`.
26+
*/
27+
beforeStatementContinuationChars?: 'any' | 'always' | 'never';
28+
}
29+
30+
/**
31+
* Never Options.
32+
*/
33+
export type SemiNeverOptions = ['never'] | ['never', SemiNeverConfig];
34+
35+
/**
36+
* Options.
37+
*/
38+
export type SemiOptions = SemiAlwaysOptions | SemiNeverOptions;
39+
40+
/**
41+
* Require or disallow semicolons instead of ASI.
442
*
43+
* @see [semi](https://eslint.org/docs/rules/semi)
544
*/
6-
export type SemiRuleConfig = RuleConfig<['always' | 'never' /* ... */]>;
45+
export type SemiRuleConfig = RuleConfig<SemiOptions>;
746

847
/**
48+
* Require or disallow semicolons instead of ASI.
949
*
50+
* @see [semi](https://eslint.org/docs/rules/semi)
1051
*/
1152
export interface SemiRule {
1253
/**

src/rules/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import type { EslintRules } from './eslint';
22
import type { RuleConfig } from './rule-config';
33

44
/**
5+
* Rules.
56
*
7+
* @see [Rules](https://eslint.org/docs/user-guide/configuring/rules)
68
*/
79
export type Rules = Partial<EslintRules> & Partial<Record<string, RuleConfig>>;

0 commit comments

Comments
 (0)