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

Commit 1e99ba0

Browse files
committed
Add rule dot-notation
1 parent 50ec38b commit 1e99ba0

File tree

4 files changed

+100
-1
lines changed

4 files changed

+100
-1
lines changed

src/rules/eslint/dot-notation.d.ts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import type { RuleConfig } from '../rule-config';
2+
3+
/**
4+
* Option.
5+
*/
6+
export type DotNotationOption = {
7+
/**
8+
* Set to `false` to follow ECMAScript version 3 compatible style, avoiding dot notation for reserved word properties.
9+
*
10+
* @default true
11+
*
12+
* @see [allowKeywords](https://eslint.org/docs/rules/dot-notation#allowkeywords)
13+
*/
14+
allowKeywords?: boolean;
15+
/**
16+
* Set to a regular expression string to allow bracket notation for property names that match a pattern.
17+
*
18+
* @default false
19+
*
20+
* @see [allowPattern](https://eslint.org/docs/rules/dot-notation#allowpattern)
21+
*/
22+
allowPattern?: boolean;
23+
};
24+
25+
/**
26+
* Options.
27+
*/
28+
export type DotNotationOptions = [DotNotationOption?];
29+
30+
/**
31+
* Require Dot Notation.
32+
*
33+
* @see [dot-notation](https://eslint.org/docs/rules/dot-notation)
34+
*/
35+
export type DotNotationRuleConfig = RuleConfig<DotNotationOptions>;
36+
37+
/**
38+
* Require Dot Notation.
39+
*
40+
* @see [dot-notation](https://eslint.org/docs/rules/dot-notation)
41+
*/
42+
export interface DotNotationRule {
43+
/**
44+
* Require Dot Notation.
45+
*
46+
* @see [dot-notation](https://eslint.org/docs/rules/dot-notation)
47+
*/
48+
'dot-notation': DotNotationRuleConfig;
49+
}

src/rules/eslint/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { CommaDangleRule } from './comma-dangle';
22
import type { CurlyRule } from './curly';
3+
import type { DotNotationRule } from './dot-notation';
34
import type { GroupedAccessorPairsRule } from './grouped-accessor-pairs';
45
import type { IdDenylistRule } from './id-denylist';
56
import type { IndentRule } from './indent';
@@ -22,6 +23,7 @@ import type { SemiRule } from './semi';
2223
*/
2324
export type EslintRules = CommaDangleRule &
2425
CurlyRule &
26+
DotNotationRule &
2527
GroupedAccessorPairsRule &
2628
IdDenylistRule &
2729
IndentRule &
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { DotNotationOption as BaseDotNotationOption } from '../eslint/dot-notation';
2+
import type { RuleConfig } from '../rule-config';
3+
4+
/**
5+
* Option.
6+
*/
7+
export type DotNotationOption = BaseDotNotationOption & {
8+
/**
9+
* @default false
10+
*
11+
* @see [allowPrivateClassPropertyAccess](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/dot-notation.md#allowprivateclasspropertyaccess)
12+
*/
13+
allowPrivateClassPropertyAccess?: boolean;
14+
/**
15+
* @default false
16+
*
17+
* @see [allowProtectedClassPropertyAccess](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/dot-notation.md#allowprotectedclasspropertyaccess)
18+
*/
19+
allowProtectedClassPropertyAccess?: boolean;
20+
};
21+
22+
/**
23+
* Options.
24+
*/
25+
export type DotNotationOptions = [DotNotationOption?];
26+
27+
/**
28+
* Enforce dot notation whenever possible.
29+
*
30+
* @see [dot-notation](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/dot-notation.md)
31+
*/
32+
export type DotNotationRuleConfig = RuleConfig<DotNotationOptions>;
33+
34+
/**
35+
* Enforce dot notation whenever possible.
36+
*
37+
* @see [dot-notation](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/dot-notation.md)
38+
*/
39+
export interface DotNotationRule {
40+
/**
41+
* Enforce dot notation whenever possible.
42+
*
43+
* @see [dot-notation](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/dot-notation.md)
44+
*/
45+
'@typescript-eslint/dot-notation': DotNotationRuleConfig;
46+
}

src/rules/typescript-eslint/index.d.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type { BanTsCommentRule } from './ban-ts-comment';
55
import type { BanTypesRule } from './ban-types';
66
import type { ConsistentTypeAssertionsRule } from './consistent-type-assertions';
77
import type { ConsistentTypeDefinitionsRule } from './consistent-type-definitions';
8+
import type { DotNotationRule } from './dot-notation';
89
import type { ExplicitFunctionReturnTypeRule } from './explicit-function-return-type';
910
import type { IndentRule } from './indent';
1011
import type { InterfaceNamePrefixRule } from './interface-name-prefix';
@@ -30,9 +31,10 @@ export type TypeScriptEslintRules = AdjacentOverloadSignaturesRule &
3031
BanTsCommentRule &
3132
BanTypesRule &
3233
ConsistentTypeAssertionsRule &
34+
ConsistentTypeDefinitionsRule &
35+
DotNotationRule &
3336
ExplicitFunctionReturnTypeRule &
3437
IndentRule &
35-
ConsistentTypeDefinitionsRule &
3638
InterfaceNamePrefixRule &
3739
MemberOrderingRule &
3840
NoExplicitAnyRule &

0 commit comments

Comments
 (0)