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
Or you can extend `plugin:editorconfig/all` instead of adding rules.
43
+
44
+
```json
45
+
{
46
+
// ...
47
+
"extends": [ "plugin:editorconfig/all" ],
48
+
"plugins": [ "editorconfig" ]
49
+
}
50
+
```
51
+
36
52
## Conflicting ESLint rules
37
53
38
54
Following rules may conflicts `editorconfig` rule.
@@ -57,41 +73,116 @@ If they are specified in the extended config, consider adding `plugin:editorconf
57
73
}
58
74
```
59
75
60
-
### Passing options
76
+
If you extend `plugin:editorconfig/all`, the rules above are turned off too, so you don't have to add `plugin:editorconfig/noconflict` in addition to `plugin:editorconfig/all`.
61
77
62
-
Internally, eslint-plugin-editorconfig uses above options to verify/fix JS code.
Internally, eslint-plugin-editorconfig uses the existing ESLint and typescript-eslint rules to verify/fix the code.
81
+
Some rules allow passing options.
82
+
83
+
All citation in this section is from the backend ESLint rule document otherwise noted.
84
+
#### Enforce EditorConfig rules for charset (`editorconfig/charset`)
85
+
86
+
The corresponding EditorCongig property is `charset`.
87
+
The backend ESLint rule is [`unicode-bom`](https://eslint.org/docs/rules/unicode-bom)
88
+
89
+
This plugin works only when `utf-8` or `utf-8-bom` is specified. If other value is specified in .editorconfig, ESLint does not verify charset.
90
+
ESLint only verifies if BOM is specified or not.
91
+
92
+
##### Options
93
+
94
+
None
95
+
96
+
##### When Not To Use It
97
+
98
+
> If you use some UTF-16 or UTF-32 files and you want to allow a file to optionally begin with a Unicode BOM, you should turn this rule off.
99
+
100
+
#### Enforce EditorConfig rules for the newlines at the end of files (`editorconfig/eol-last`)
101
+
102
+
The corresponding EditorCongig property is `insert_final_newline`.
103
+
The backend ESLint rule is [`eol-last`](https://eslint.org/docs/rules/eol-last)
104
+
105
+
##### Options
106
+
107
+
None
108
+
109
+
#### Enforce EditorConfig rules for indentation (`editorconfig/indent`)
110
+
111
+
The corresponding EditorCongig property is `indent_style` and `indent_size`.
112
+
The backend ESLint rule is [`indent`](https://eslint.org/docs/rules/indent) and [`@typescript-eslint/indent`](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/indent.md).
113
+
114
+
As documented, `@typescript-eslint/indent` is unstable currently. Please read typescript-eslint#1824 before using this rule for TypeScript.
115
+
116
+
##### Options
117
+
118
+
> *`"SwitchCase"` (default: 0) enforces indentation level for `case` clauses in `switch` statements
119
+
> *`"VariableDeclarator"` (default: 1) enforces indentation level for `var` declarators; can also take an object to define separate rules for `var`, `let` and `const` declarations. It can also be `"first"`, indicating all the declarators should be aligned with the first declarator.
120
+
> *`"outerIIFEBody"` (default: 1) enforces indentation level for file-level IIFEs. This can also be set to `"off"` to disable checking for file-level IIFEs.
121
+
> *`"MemberExpression"` (default: 1) enforces indentation level for multi-line property chains. This can also be set to `"off"` to disable checking for MemberExpression indentation.
122
+
> *`"FunctionDeclaration"` takes an object to define rules for function declarations.
123
+
> *`parameters` (default: 1) enforces indentation level for parameters in a function declaration. This can either be a number indicating indentation level, or the string `"first"` indicating that all parameters of the declaration must be aligned with the first parameter. This can also be set to `"off"` to disable checking for FunctionDeclaration parameters.
124
+
> *`body` (default: 1) enforces indentation level for the body of a function declaration.
125
+
> *`"FunctionExpression"` takes an object to define rules for function expressions.
126
+
> *`parameters` (default: 1) enforces indentation level for parameters in a function expression. This can either be a number indicating indentation level, or the string `"first"` indicating that all parameters of the expression must be aligned with the first parameter. This can also be set to `"off"` to disable checking for FunctionExpression parameters.
127
+
> *`body` (default: 1) enforces indentation level for the body of a function expression.
128
+
> *`"CallExpression"` takes an object to define rules for function call expressions.
129
+
> *`arguments` (default: 1) enforces indentation level for arguments in a call expression. This can either be a number indicating indentation level, or the string `"first"` indicating that all arguments of the expression must be aligned with the first argument. This can also be set to `"off"` to disable checking for CallExpression arguments.
130
+
> *`"ArrayExpression"` (default: 1) enforces indentation level for elements in arrays. It can also be set to the string `"first"`, indicating that all the elements in the array should be aligned with the first element. This can also be set to `"off"` to disable checking for array elements.
131
+
> *`"ObjectExpression"` (default: 1) enforces indentation level for properties in objects. It can be set to the string `"first"`, indicating that all properties in the object should be aligned with the first property. This can also be set to `"off"` to disable checking for object properties.
132
+
> *`"ImportDeclaration"` (default: 1) enforces indentation level for import statements. It can be set to the string `"first"`, indicating that all imported members from a module should be aligned with the first member in the list. This can also be set to `"off"` to disable checking for imported module members.
133
+
> *`"flatTernaryExpressions": true` (`false` by default) requires no indentation for ternary expressions which are nested in other ternary expressions.
134
+
> *`"offsetTernaryExpressions": true` (`false` by default) requires indentation for values of ternary expressions.
135
+
> *`"ignoredNodes"` accepts an array of [selectors](/docs/developer-guide/selectors.md). If an AST node is matched by any of the selectors, the indentation of tokens which are direct children of that node will be ignored. This can be used as an escape hatch to relax the rule if you disagree with the indentation that it enforces for a particular syntactic pattern.
136
+
> *`"ignoreComments"` (default: false) can be used when comments do not need to be aligned with nodes on the previous or next line.
137
+
138
+
Example (based on the code in the [document for the backend rule `indent`](https://eslint.org/docs/rules/indent)):
139
+
140
+
```javascript
141
+
/*eslint indent: ["error", { "SwitchCase": 1 }]*/
142
+
143
+
switch(a){
144
+
case"a":
145
+
break;
146
+
case"b":
147
+
break;
75
148
}
76
149
```
77
150
78
-
Currently, following rules are supported.
79
-
See original rule documents for supported options.
151
+
Note: The third option parameter of the original backend `indent` rule should be passed as the second option parameter to this `editorconfig/indent` rule.
0 commit comments