8000 [FEAT] [indent] Extend the base rule to support TS nodes (#219) · kaicataldo/typescript-eslint@3606353 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3606353

Browse files
bradzacherJamesHenry
authored andcommitted
[FEAT] [indent] Extend the base rule to support TS nodes (typescript-eslint#219)
Fixes typescript-eslint#201 Fixes typescript-eslint#96 Fixes eslint/typescript-eslint-parser#577 The [base eslint implementation](https://github.com/eslint/eslint/blob/master/lib/rules/indent.js) purposely ignores nodes it doesn't know about (i.e. our TS nodes). Because of how the base rule is written, we have to override the implementation entirely.
1 parent 0a858be commit 3606353

File tree

6 files changed

+1570
-13
lines changed

6 files changed

+1570
-13
lines changed

packages/eslint-plugin-typescript/.eslintrc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,16 @@
1212
"plugin:eslint-plugin/recommended"
1313
],
1414
"rules": {
15+
"new-cap": "off",
16+
"lines-around-comment": "off",
17+
1518
"prettier/prettier": [
1619
"error",
1720
{
1821
"tabWidth": 4
1922
}
2023
],
21-
"lines-around-comment": "off",
24+
2225
"eslint-plugin/prefer-placeholders": "error",
2326
"eslint-plugin/prefer-replace-text": "error",
2427
"eslint-plugin/no-deprecated-report-api": "error",

packages/eslint-plugin-typescript/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ This guarantees 100% compatibility between the plugin and the parser.
6262
| [`typescript/explicit-function-return-type`](./docs/rules/explicit-function-return-type.md) | Require explicit return types on functions and class methods | | |
6363
| [`typescript/explicit-member-accessibility`](./docs/rules/explicit-member-accessibility.md) | Require explicit accessibility modifiers on class properties and methods (`member-access` from TSLint) | | |
6464
| [`typescript/generic-type-naming`](./docs/rules/generic-type-naming.md) | Enforces naming of generic type variables | | |
65+
| [`typescript/indent`](./docs/rules/indent.md) | Enforce consistent indentation (`indent` from TSLint) | :heavy_check_mark: | :wrench: |
6566
| [`typescript/interface-name-prefix`](./docs/rules/interface-name-prefix.md) | Require that interface names be prefixed with `I` (`interface-name` from TSLint) | | |
6667
| [`typescript/member-delimiter-style`](./docs/rules/member-delimiter-style.md) | Require a specific member delimiter style for interfaces and type literals | | :wrench: |
6768
| [`typescript/member-naming`](. 10000 /docs/rules/member-naming.md) | Enforces naming conventions for class members by visibility. | | |

packages/eslint-plugin-typescript/docs/rules/camelcase.md

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ variable that will be imported into the local module scope.
2020

2121
## Options
2222

23+
```cjson
24+
{
25+
// note you must disable the base rule as it can report incorrect errors
26+
"camelcase": "off",
27+
"typescript/camelcase": ["error", { "properties": "always" }]
28+
}
29+
```
30+
2331
This rule has an object option:
2432

2533
* `"properties": "always"` (default) enforces camelcase style for property names
@@ -33,7 +41,7 @@ This rule has an object option:
3341
Examples of **incorrect** code for this rule with the default `{ "properties": "always" }` option:
3442

3543
```js
36-
/*eslint camelcase: "error"*/
44+
/*eslint typescript/camelcase: "error"*/
3745

3846
import { no_camelcased } from "external-module"
3947

@@ -73,7 +81,7 @@ var { foo: bar_baz = 1 } = quz;
7381
Examples of **correct** code for this rule with the default `{ "properties": "always" }` option:
7482

7583
```js
76-
/*eslint camelcase: "error"*/
84+
/*eslint typescript/camelcase: "error"*/
7785

7886
import { no_camelcased as camelCased } from "external-module";
7987

@@ -115,7 +123,7 @@ var { foo: isCamelCased = 1 } = quz;
115123
Examples of **correct** code for this rule with the `{ "properties": "never" }` option:
116124

117125
```js
118-
/*eslint camelcase: ["error", {properties: "never"}]*/
126+
/*eslint typescript/camelcase: ["error", {properties: "never"}]*/
119127

120128
var obj = {
121129
my_pref: 1
@@ -127,7 +135,7 @@ var obj = {
127135
Examples of **incorrect** code for this rule with the default `{ "ignoreDestructuring": false }` option:
128136

129137
```js
130-
/*eslint camelcase: "error"*/
138+
/*eslint typescript/camelcase: "error"*/
131139

132140
var { category_id } = query;
133141

@@ -145,7 +153,7 @@ var { category_id: categoryId, ...other_props } = query;
145153
Examples of **incorrect** code for this rule with the `{ "ignoreDestructuring": true }` option:
146154

147155
```js
148-
/*eslint camelcase: ["error", {ignoreDestructuring: true}]*/
156+
/*eslint typescript/camelcase: ["error", {ignoreDestructuring: true}]*/
149157

150158
var { category_id: category_alias } = query;
151159

@@ -155,7 +163,7 @@ var { category_id, ...other_props } = query;
155163
Examples of **correct** code for this rule with the `{ "ignoreDestructuring": true }` option:
156164

157165
```js
158-
/*eslint camelcase: ["error", {ignoreDestructuring: true}]*/
166+
/*eslint typescript/camelcase: ["error", {ignoreDestructuring: true}]*/
159167

160168
var { category_id } = query;
161169

@@ -169,15 +177,15 @@ var { category_id: category_id } = query;
169177
Examples of **correct** code for this rule with the `allow` option:
170178

171179
```js
172-
/*eslint camelcase: ["error", {allow: ["UNSAFE_componentWillMount"]}]*/
180+
/*eslint typescript/camelcase: ["error", {allow: ["UNSAFE_componentWillMount"]}]*/
173181

174182
function UNSAFE_componentWillMount() {
175183
// ...
176184
}
177185
```
178186

179187
```js
180-
/*eslint camelcase: ["error", {allow: ["^UNSAFE_"]}]*/
188+
/*eslint typescript/camelcase: ["error", {allow: ["^UNSAFE_"]}]*/
181189

182190
function UNSAFE_componentWillMount() {
183191
// ...

0 commit comments

Comments
 (0)
0