You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fixestypescript-eslint#144
Requires ~~typescript-eslint#259~~, ~~typescript-eslint#260~~.
- added a util to make it standardised and easier to add default config for a rule
- configured recommended based on typescript-eslint#144
- purposely switched `recommended` prop to be `"error" | "warning" | false`
- inside the eslint repo, it should be `true`. otherwise it's just a property that isn't used officially by eslint. It's truthy so `eslint-docs` still work.
- changed recommended generator to accept `"error"`/`"warning"` for more configurability.
- adjusted default config of certain rules that didn't match our recommendations.
Add `eslint-plugin-typescript/parser` to the `parser` field and `typescript` to the plugins section of your `.eslintrc` configuration file. You can omit the `eslint-plugin-` prefix:
29
+
Add `eslint-plugin-typescript/parser` to the `parser` field and `typescript` to the plugins section of your `.eslintrc` configuration file:
30
30
31
31
```json
32
32
{
@@ -35,18 +35,28 @@ Add `eslint-plugin-typescript/parser` to the `parser` field and `typescript` to
35
35
}
36
36
```
37
37
38
+
Note: The plugin provides its own version of the `typescript-eslint-parser` via `eslint-plugin-typescript/parser`.
39
+
This helps us guarantee 100% compatibility between the plugin and the parser.
40
+
38
41
Then configure the rules you want to use under the rules section.
39
42
40
43
```json
41
44
{
45
+
"parser": "eslint-plugin-typescript/parser",
46
+
"plugins": ["typescript"],
42
47
"rules": {
43
48
"typescript/rule-name": "error"
44
49
}
45
50
}
46
51
```
47
52
48
-
Note: The plugin provides its own version of the `typescript-eslint-parser` via `eslint-plugin-typescript/parser`.
49
-
This guarantees 100% compatibility between the plugin and the parser.
53
+
You can also enable all the recommended rules at once. Add `plugin:typescript/recommended` in extends:
54
+
55
+
```json
56
+
{
57
+
"extends": ["plugin:typescript/recommended"]
58
+
}
59
+
```
50
60
51
61
## Supported Rules
52
62
@@ -58,38 +68,38 @@ This guarantees 100% compatibility between the plugin and the parser.
58
68
<!-- prettier-ignore -->
59
69
| Name | Description |:heavy_check_mark:|:wrench:|
|[`typescript/adjacent-overload-signatures`](./docs/rules/adjacent-overload-signatures.md)| Require that member overloads be consecutive (`adjacent-overload-signatures` from TSLint) |||
62
-
|[`typescript/array-type`](./docs/rules/array-type.md)| Requires using either `T[]` or `Array<T>` for arrays (`array-type` from TSLint) ||:wrench:|
63
-
|[`typescript/ban-types`](./docs/rules/ban-types.md)| Enforces that types will not to be used (`ban-types` from TSLint) ||:wrench:|
|[`typescript/adjacent-overload-signatures`](./docs/rules/adjacent-overload-signatures.md)| Require that member overloads be consecutive (`adjacent-overload-signatures` from TSLint) |:heavy_check_mark:||
72
+
|[`typescript/array-type`](./docs/rules/array-type.md)| Requires using either `T[]` or `Array<T>` for arrays (`array-type` from TSLint) |:heavy_check_mark:|:wrench:|
73
+
|[`typescript/ban-types`](./docs/rules/ban-types.md)| Enforces that types will not to be used (`ban-types` from TSLint) |:heavy_check_mark:|:wrench:|
|[`typescript/class-name-casing`](./docs/rules/class-name-casing.md)| Require PascalCased class and interface names (`class-name` from TSLint) |:heavy_check_mark:||
66
-
|[`typescript/explicit-function-return-type`](./docs/rules/explicit-function-return-type.md)| Require explicit return types on functions and class methods |||
67
-
|[`typescript/explicit-member-accessibility`](./docs/rules/explicit-member-accessibility.md)| Require explicit accessibility modifiers on class properties and methods (`member-access` from TSLint) |||
76
+
|[`typescript/explicit-function-return-type`](./docs/rules/explicit-function-return-type.md)| Require explicit return types on functions and class methods |:heavy_check_mark:||
77
+
|[`typescript/explicit-member-accessibility`](./docs/rules/explicit-member-accessibility.md)| Require explicit accessibility modifiers on class properties and methods (`member-access` from TSLint) |:heavy_check_mark:||
68
78
|[`typescript/generic-type-naming`](./docs/rules/generic-type-naming.md)| Enforces naming of generic type variables |||
69
79
|[`typescript/indent`](./docs/rules/indent.md)| Enforce consistent indentation (`indent` from TSLint) |:heavy_check_mark:|:wrench:|
70
-
|[`typescript/interface-name-prefix`](./docs/rules/interface-name-prefix.md)| Require that interface names be prefixed with `I` (`interface-name` from TSLint) |||
71
-
|[`typescript/member-delimiter-style`](./docs/rules/member-delimiter-style.md)| Require a specific member delimiter style for interfaces and type literals ||:wrench:|
80
+
|[`typescript/interface-name-prefix`](./docs/rules/interface-name-prefix.md)| Require that interface names be prefixed with `I` (`interface-name` from TSLint) |:heavy_check_mark:||
81
+
|[`typescript/member-delimiter-style`](./docs/rules/member-delimiter-style.md)| Require a specific member delimiter style for interfaces and type literals |:heavy_check_mark:|:wrench:|
72
82
|[`typescript/member-naming`](./docs/rules/member-naming.md)| Enforces naming conventions for class members by visibility. |||
73
83
|[`typescript/member-ordering`](./docs/rules/member-ordering.md)| Require a consistent member declaration order (`member-ordering` from TSLint) |||
74
-
|[`typescript/no-angle-bracket-type-assertion`](./docs/rules/no-angle-bracket-type-assertion.md)| Enforces the use of `as Type` assertions instead of `<Type>` assertions (`no-angle-bracket-type-assertion` from TSLint) |||
|[`typescript/no-empty-interface`](./docs/rules/no-empty-interface.md)| Disallow the declaration of empty interfaces (`no-empty-interface` from TSLint) |||
77
-
|[`typescript/no-explicit-any`](./docs/rules/no-explicit-any.md)| Disallow usage of the `any` type (`no-any` from TSLint) |||
84
+
|[`typescript/no-angle-bracket-type-assertion`](./docs/rules/no-angle-bracket-type-assertion.md)| Enforces the use of `as Type` assertions instead of `<Type>` assertions (`no-angle-bracket-type-assertion` from TSLint) |:heavy_check_mark:||
|[`typescript/no-empty-interface`](./docs/rules/no-empty-interface.md)| Disallow the declaration of empty interfaces (`no-empty-interface` from TSLint) |:heavy_check_mark:||
87
+
|[`typescript/no-explicit-any`](./docs/rules/no-explicit-any.md)| Disallow usage of the `any` type (`no-any` from TSLint) |:heavy_check_mark:||
78
88
|[`typescript/no-extraneous-class`](./docs/rules/no-extraneous-class.md)| Forbids the use of classes as namespaces (`no-unnecessary-class` from TSLint) |||
79
-
|[`typescript/no-inferrable-types`](./docs/rules/no-inferrable-types.md)| Disallows explicit type declarations for variables or parameters initialized to a number, string, or boolean. (`no-inferrable-types` from TSLint) ||:wrench:|
80
-
|[`typescript/no-misused-new`](./docs/rules/no-misused-new.md)| Enforce valid definition of `new` and `constructor`. (`no-misused-new` from TSLint) |||
81
-
|[`typescript/no-namespace`](./docs/rules/no-namespace.md)| Disallow the use of custom TypeScript modules and namespaces (`no-namespace` from TSLint) |||
82
-
|[`typescript/no-non-null-assertion`](./docs/rules/no-non-null-assertion.md)| Disallows non-null assertions using the `!` postfix operator (`no-non-null-assertion` from TSLint) |||
83
-
|[`typescript/no-object-literal-type-assertion`](./docs/rules/no-object-literal-type-assertion.md)| Forbids an object literal to appear in a type assertion expression (`no-object-literal-type-assertion` from TSLint) |||
84
-
|[`typescript/no-parameter-properties`](./docs/rules/no-parameter-properties.md)| Disallow the use of parameter properties in class constructors. (`no-parameter-properties` from TSLint) |||
89
+
|[`typescript/no-inferrable-types`](./docs/rules/no-inferrable-types.md)| Disallows explicit type declarations for variables or parameters initialized to a number, string, or boolean. (`no-inferrable-types` from TSLint) |:heavy_check_mark:|:wrench:|
90
+
|[`typescript/no-misused-new`](./docs/rules/no-misused-new.md)| Enforce valid definition of `new` and `constructor`. (`no-misused-new` from TSLint) |:heavy_check_mark:||
91
+
|[`typescript/no-namespace`](./docs/rules/no-namespace.md)| Disallow the use of custom TypeScript modules and namespaces (`no-namespace` from TSLint) |:heavy_check_mark:||
92
+
|[`typescript/no-non-null-assertion`](./docs/rules/no-non-null-assertion.md)| Disallows non-null assertions using the `!` postfix operator (`no-non-null-assertion` from TSLint) |:heavy_check_mark:||
93
+
|[`typescript/no-object-literal-type-assertion`](./docs/rules/no-object-literal-type-assertion.md)| Forbids an object literal to appear in a type assertion expression (`no-object-literal-type-assertion` from TSLint) |:heavy_check_mark:||
94
+
|[`typescript/no-parameter-properties`](./docs/rules/no-parameter-properties.md)| Disallow the use of parameter properties in class constructors. (`no-parameter-properties` from TSLint) |:heavy_check_mark:||
85
95
|[`typescript/no-this-alias`](./docs/rules/no-this-alias.md)| Disallow aliasing `this` (`no-this-assignment` from TSLint) |||
|[`typescript/no-type-alias`](./docs/rules/no-type-alias.md)| Disallow the use of type aliases (`interface-over-type-literal` from TSLint) |||
88
98
|[`typescript/no-unused-vars`](./docs/rules/no-unused-vars.md)| Disallow unused variables (`no-unused-variable` from TSLint) |:heavy_check_mark:||
89
-
|[`typescript/no-use-before-define`](./docs/rules/no-use-before-define.md)| Disallow the use of variables before they are defined |||
90
-
|[`typescript/no-var-requires`](./docs/rules/no-var-requires.md)| Disallows the use of require statements except in import statements (`no-var-requires` from TSLint) |||
91
-
|[`typescript/prefer-interface`](./docs/rules/prefer-interface.md)| Prefer an interface declaration over a type literal (type T = { ... }) (`interface-over-type-literal` from TSLint) ||:wrench:|
92
-
|[`typescript/prefer-namespace-keyword`](./docs/rules/prefer-namespace-keyword.md)| Require the use of the `namespace` keyword instead of the `module` keyword to declare custom TypeScript modules. (`no-internal-module` from TSLint) ||:wrench:|
93
-
|[`typescript/type-annotation-spacing`](./docs/rules/type-annotation-spacing.md)| Require consistent spacing around type annotations (`typedef-whitespace` from TSLint) ||:wrench:|
99
+
|[`typescript/no-use-before-define`](./docs/rules/no-use-before-define.md)| Disallow the use of variables before they are defined |:heavy_check_mark:||
100
+
|[`typescript/no-var-requires`](./docs/rules/no-var-requires.md)| Disallows the use of require statements except in import statements (`no-var-requires` from TSLint) |:heavy_check_mark:||
101
+
|[`typescript/prefer-interface`](./docs/rules/prefer-interface.md)| Prefer an interface declaration over a type literal (type T = { ... }) (`interface-over-type-literal` from TSLint) |:heavy_check_mark:|:wrench:|
102
+
|[`typescript/prefer-namespace-keyword`](./docs/rules/prefer-namespace-keyword.md)| Require the use of the `namespace` keyword instead of the `module` keyword to declare custom TypeScript modules. (`no-internal-module` from TSLint) |:heavy_check_mark:|:wrench:|
103
+
|[`typescript/type-annotation-spacing`](./docs/rules/type-annotation-spacing.md)| Require consistent spacing around type annotations (`typedef-whitespace` from TSLint) |:heavy_check_mark:|:wrench:|
0 commit comments