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
Copy file name to clipboardExpand all lines: packages/eslint-plugin/docs/rules/naming-convention.md
+63-63
Original file line number
Diff line number
Diff line change
@@ -104,10 +104,10 @@ For information about how each selector is applied, see ["How does the rule eval
104
104
The `format` option defines the allowed formats for the identifier. This option accepts an array of the following values, and the identifier can match any of them:
105
105
106
106
-`camelCase` - standard camelCase format - no underscores are allowed between characters, and consecutive capitals are allowed (i.e. both `myID` and `myId` are valid).
107
-
-`strictCamelCase` - same as `camelCase`, but consecutive capitals are not allowed (i.e. `myId` is valid, but `myID` is not).
108
107
-`PascalCase` - same as `camelCase`, except the first character must be upper-case.
109
-
-`StrictPascalCase` - same as `strictCamelCase`, except the first character must be upper-case.
110
108
-`snake_case` - standard snake_case format - all characters must be lower-case, and underscores are allowed.
109
+
-`strictCamelCase` - same as `camelCase`, but consecutive capitals are not allowed (i.e. `myId` is valid, but `myID` is not).
110
+
-`StrictPascalCase` - same as `strictCamelCase`, except the first character must be upper-case.
111
111
-`UPPER_CASE` - same as `snake_case`, except all characters must be upper-case.
112
112
113
113
Instead of an array, you may also pass `null`. This signifies "this selector shall not have its format checked".
@@ -118,8 +118,8 @@ This can be useful if you want to enforce no particular format for a specific se
118
118
The `custom` option defines a custom regex that the identifier must (or must not) match. This option allows you to have a bit more finer-grained control over identifiers, letting you ban (or force) certain patterns and substrings.
119
119
Accepts an object with the following properties:
120
120
121
-
-`regex` - a string that is then passed into RegExp to create a new regular expression: `new RegExp(regex)`
122
121
-`match` - true if the identifier _must_ match the `regex`, false if the identifier _must not_ match the `regex`.
122
+
-`regex` - a string that is then passed into RegExp to create a new regular expression: `new RegExp(regex)`
123
123
124
124
#### `filter`
125
125
@@ -129,21 +129,21 @@ You can use this to include or exclude specific identifiers from specific config
129
129
130
130
Accepts an object with the following properties:
131
131
132
-
-`regex` - a string that is then passed into RegExp to create a new regular expression: `new RegExp(regex)`
133
132
-`match` - true if the identifier _must_ match the `regex`, false if the identifier _must not_ match the `regex`.
133
+
-`regex` - a string that is then passed into RegExp to create a new regular expression: `new RegExp(regex)`
134
134
135
135
Alternatively, `filter` accepts a regular expression (anything accepted into `new RegExp(filter)`). In this case, it's treated as if you had passed an object with the regex and `match: true`.
136
136
137
137
#### `leadingUnderscore` / `trailingUnderscore`
138
138
139
139
The `leadingUnderscore` / `trailingUnderscore` options control whether leading/trailing underscores are considered valid. Accepts one of the following values:
140
140
141
-
-`forbid` - a leading/trailing underscore is not allowed at all.
142
-
-`require` - a single leading/trailing underscore must be included.
143
-
-`requireDouble` - two leading/trailing underscores must be included.
144
141
-`allow` - existence of a single leading/trailing underscore is not explicitly enforced.
145
142
-`allowDouble` - existence of a double leading/trailing underscore is not explicitly enforced.
146
143
-`allowSingleOrDouble` - existence of a single or a double leading/trailing underscore is not explicitly enforced.
144
+
-`forbid` - a leading/trailing underscore is not allowed at all.
145
+
-`require` - a single leading/trailing underscore must be included.
146
+
-`requireDouble` - two leading/trailing underscores must be included.
147
147
148
148
#### `prefix` / `suffix`
149
149
@@ -163,27 +163,27 @@ If these are provided, the identifier must start with one of the provided values
163
163
- The name must match _all_ of the modifiers.
164
164
- For example, if you provide `{ modifiers: ['private','readonly','static'] }`, then it will only match something that is `private static readonly`, and something that is just `private` will not match.
165
165
- The following `modifiers` are allowed:
166
+
-`abstract`,`override`,`private`,`protected`,`readonly`,`static` - matches any member explicitly declared with the given modifier.
167
+
-`async` - matches any method, function, or function variable which is async via the `async` keyword (e.g. does not match functions that return promises without using `async` keyword)
166
168
-`const` - matches a variable declared as being `const` (`const x = 1`).
167
169
-`destructured` - matches a variable declared via an object destructuring pattern (`const {x, z = 2}`).
168
170
- Note that this does not match renamed destructured properties (`const {x: y, a: b = 2}`).
169
-
-`global` - matches a variable/function declared in the top-level scope.
170
171
-`exported` - matches anything that is exported from the module.
171
-
-`unused` - matches anything that is not used.
172
-
-`requiresQuotes` - matches any name that requires quotes as it is not a valid identifier (i.e. has a space, a dash, etc in it).
173
-
-`public` - matches any member that is either explicitly declared as `public`, or has no visibility modifier (i.e. implicitly public).
174
-
-`abstract`,`override`,`private`,`protected`,`readonly`,`static` - matches any member explicitly declared with the given modifier.
172
+
-`global` - matches a variable/function declared in the top-level scope.
175
173
-`#private` - matches any member with a private identifier (an identifier that starts with `#`)
176
-
-`async` - matches any method, function, or function variable which is async via the `async` keyword (e.g. does not match functions that return promises without using `async` keyword)
174
+
-`public` - matches any member that is either explicitly declared as `public`, or has no visibility modifier (i.e. implicitly public).
175
+
-`requiresQuotes` - matches any name that requires quotes as it is not a valid identifier (i.e. has a space, a dash, etc in it).
176
+
-`unused` - matches anything that is not used.
177
177
-`types` allows you to specify which types to match. This option supports simple, primitive types only (`array`,`boolean`,`function`,`number`,`string`).
178
178
- The name must match _one_ of the types.
179
179
-**_NOTE - Using this option will require that you lint with type information._**
180
180
- For example, this lets you do things like enforce that `boolean` variables are prefixed with a verb.
181
181
- The following `types` are allowed:
182
-
-`boolean` matches any type assignable to `boolean | null | undefined`
183
-
-`string` matches any type assignable to `string | null | undefined`
184
-
-`number` matches any type assignable to `number | null | undefined`
185
182
-`array` matches any type assignable to `Array<unknown> | null | undefined`
183
+
-`boolean` matches any type assignable to `boolean | null | undefined`
186
184
-`function` matches any type assignable to `Function | null | undefined`
185
+
-`number` matches any type assignable to `number | null | undefined`
186
+
-`string` matches any type assignable to `string | null | undefined`
187
187
188
188
The ordering of selectors does not matter. The implementation will automatically sort the selectors to ensure they match from most-specific to least specific. It will keep checking selectors in that order until it finds one that matches the name. See ["How does the rule automatically order selectors?"](#how-does-the-rule-automatically-order-selectors)
189
189
@@ -195,57 +195,57 @@ There are two types of selectors, individual selectors, and grouped selectors.
195
195
196
196
Individual Selectors match specific, well-defined sets. There is no overlap between each of the individual selectors.
-`objectLiteralProperty` - matches any object literal property. Does not match properties that have direct function expression or arrow function expression values.
-`typeProperty` - matches any object type property. Does not match properties that have direct function expression or arrow function expression values.
-`classMethod` - matches any class method. Also matches properties that have direct function expression or arrow function expression values. Does not match accessors.
-`objectLiteralMethod` - matches any object literal method. Also matches properties that have direct function expression or arrow function expression values. Does not match accessors.
-`typeMethod` - matches any object type method. Also matches properties that have direct function expression or arrow function expression values. Does not match accessors.
-`objectLiteralMethod` - matches any object literal method. Also matches properties that have direct function expression or arrow function expression values. Does not match accessors.
-`objectLiteralProperty` - matches any object literal property. Does not match properties that have direct function expression or arrow function expression values.
-`typeAlias` - matches any type alias declaration.
241
235
- Allowed `modifiers`: `exported`, `unused`.
242
236
- Allowed `types`: none.
243
-
-`enum` - matches any enum declaration.
244
-
- Allowed `modifiers`: `exported`, `unused`.
237
+
-`typeMethod` - matches any object type method. Also matches properties that have direct function expression or arrow function expression values. Does not match accessors.
-`typeParameter` - matches any generic type parameter declaration.
247
241
- Allowed `modifiers`: `unused`.
248
242
- Allowed `types`: none.
243
+
-`typeProperty` - matches any object type property. Does not match properties that have direct function expression or arrow function expression values.
0 commit comments