Skip to content

Commit 8c6e068

Browse files
authored
docs: alphabetize lists of names in naming-convention (#6891)
1 parent a4b633b commit 8c6e068

File tree

1 file changed

+63
-63
lines changed

1 file changed

+63
-63
lines changed

Diff for: packages/eslint-plugin/docs/rules/naming-convention.md

+63-63
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,10 @@ For information about how each selector is applied, see ["How does the rule eval
104104
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:
105105

106106
- `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).
108107
- `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.
110108
- `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.
111111
- `UPPER_CASE` - same as `snake_case`, except all characters must be upper-case.
112112

113113
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
118118
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.
119119
Accepts an object with the following properties:
120120

121-
- `regex` - a string that is then passed into RegExp to create a new regular expression: `new RegExp(regex)`
122121
- `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)`
123123

124124
#### `filter`
125125

@@ -129,21 +129,21 @@ You can use this to include or exclude specific identifiers from specific config
129129

130130
Accepts an object with the following properties:
131131

132-
- `regex` - a string that is then passed into RegExp to create a new regular expression: `new RegExp(regex)`
133132
- `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)`
134134

135135
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`.
136136

137137
#### `leadingUnderscore` / `trailingUnderscore`
138138

139139
The `leadingUnderscore` / `trailingUnderscore` options control whether leading/trailing underscores are considered valid. Accepts one of the following values:
140140

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.
144141
- `allow` - existence of a single leading/trailing underscore is not explicitly enforced.
145142
- `allowDouble` - existence of a double leading/trailing underscore is not explicitly enforced.
146143
- `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.
147147

148148
#### `prefix` / `suffix`
149149

@@ -163,27 +163,27 @@ If these are provided, the identifier must start with one of the provided values
163163
- The name must match _all_ of the modifiers.
164164
- 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.
165165
- 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)
166168
- `const` - matches a variable declared as being `const` (`const x = 1`).
167169
- `destructured` - matches a variable declared via an object destructuring pattern (`const {x, z = 2}`).
168170
- 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.
170171
- `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.
175173
- `#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.
177177
- `types` allows you to specify which types to match. This option supports simple, primitive types only (`array`,`boolean`,`function`,`number`,`string`).
178178
- The name must match _one_ of the types.
179179
- **_NOTE - Using this option will require that you lint with type information._**
180180
- For example, this lets you do things like enforce that `boolean` variables are prefixed with a verb.
181181
- 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`
185182
- `array` matches any type assignable to `Array<unknown> | null | undefined`
183+
- `boolean` matches any type assignable to `boolean | null | undefined`
186184
- `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`
187187

188188
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)
189189

@@ -195,57 +195,57 @@ There are two types of selectors, individual selectors, and grouped selectors.
195195

196196
Individual Selectors match specific, well-defined sets. There is no overlap between each of the individual selectors.
197197

198-
- `variable` - matches any `let` / `const` / `var` variable name.
199-
- Allowed `modifiers`: `async`, `const`, `destructured`, `exported`, `global`, `unused`.
198+
- `accessor` - matches any accessor.
199+
- Allowed `modifiers`: `abstract`, `override`, `private`, `protected`, `public`, `requiresQuotes`, `static`.
200200
- Allowed `types`: `array`, `boolean`, `function`, `number`, `string`.
201-
- `function` - matches any named function declaration or named function expression.
202-
- Allowed `modifiers`: `async`, `exported`, `global`, `unused`.
201+
- `class` - matches any class declaration.
202+
- Allowed `modifiers`: `abstract`, `exported`, `unused`.
203203
- Allowed `types`: none.
204-
- `parameter` - matches any function parameter. Does not match parameter properties.
205-
- Allowed `modifiers`: `destructured`, `unused`.
206-
- Allowed `types`: `boolean`, `string`, `number`, `function`, `array`.
207-
- `classProperty` - matches any class property. Does not match properties that have direct function expression or arrow function expression values.
208-
- Allowed `modifiers`: `abstract`, `override`, `#private`, `private`, `protected`, `public`, `readonly`, `requiresQuotes`, `static`.
209-
- Allowed `types`: `array`, `boolean`, `function`, `number`, `string`.
210-
- `objectLiteralProperty` - matches any object literal property. Does not match properties that have direct function expression or arrow function expression values.
211-
- Allowed `modifiers`: `public`, `requiresQuotes`.
212-
- Allowed `types`: `array`, `boolean`, `function`, `number`, `string`.
213-
- `typeProperty` - matches any object type property. Does not match properties that have direct function expression or arrow function expression values.
214-
- Allowed `modifiers`: `public`, `readonly`, `requiresQuotes`.
215-
- Allowed `types`: `array`, `boolean`, `function`, `number`, `string`.
216-
- `parameterProperty` - matches any parameter property.
217-
- Allowed `modifiers`: `private`, `protected`, `public`, `readonly`.
218-
- Allowed `types`: `array`, `boolean`, `function`, `number`, `string`.
219204
- `classMethod` - matches any class method. Also matches properties that have direct function expression or arrow function expression values. Does not match accessors.
220205
- Allowed `modifiers`: `abstract`, `async`, `override`, `#private`, `private`, `protected`, `public`, `requiresQuotes`, `static`.
221206
- Allowed `types`: none.
222-
- `objectLiteralMethod` - matches any object literal method. Also matches properties that have direct function expression or arrow function expression values. Does not match accessors.
223-
- Allowed `modifiers`: `async`, `public`, `requiresQuotes`.
224-
- Allowed `types`: none.
225-
- `typeMethod` - matches any object type method. Also matches properties that have direct function expression or arrow function expression values. Does not match accessors.
226-
- Allowed `modifiers`: `public`, `requiresQuotes`.
227-
- Allowed `types`: none.
228-
- `accessor` - matches any accessor.
229-
- Allowed `modifiers`: `abstract`, `override`, `private`, `protected`, `public`, `requiresQuotes`, `static`.
207+
- `classProperty` - matches any class property. Does not match properties that have direct function expression or arrow function expression values.
208+
- Allowed `modifiers`: `abstract`, `override`, `#private`, `private`, `protected`, `public`, `readonly`, `requiresQuotes`, `static`.
230209
- Allowed `types`: `array`, `boolean`, `function`, `number`, `string`.
210+
- `enum` - matches any enum declaration.
211+
- Allowed `modifiers`: `exported`, `unused`.
212+
- Allowed `types`: none.
231213
- `enumMember` - matches any enum member.
232214
- Allowed `modifiers`: `requiresQuotes`.
233215
- Allowed `types`: none.
234-
- `class` - matches any class declaration.
235-
- Allowed `modifiers`: `abstract`, `exported`, `unused`.
216+
- `function` - matches any named function declaration or named function expression.
217+
- Allowed `modifiers`: `async`, `exported`, `global`, `unused`.
236218
- Allowed `types`: none.
237219
- `interface` - matches any interface declaration.
238220
- Allowed `modifiers`: `exported`, `unused`.
239221
- Allowed `types`: none.
222+
- `objectLiteralMethod` - matches any object literal method. Also matches properties that have direct function expression or arrow function expression values. Does not match accessors.
223+
- Allowed `modifiers`: `async`, `public`, `requiresQuotes`.
224+
- Allowed `types`: none.
225+
- `objectLiteralProperty` - matches any object literal property. Does not match properties that have direct function expression or arrow function expression values.
226+
- Allowed `modifiers`: `public`, `requiresQuotes`.
227+
- Allowed `types`: `array`, `boolean`, `function`, `number`, `string`.
228+
- `parameter` - matches any function parameter. Does not match parameter properties.
229+
- Allowed `modifiers`: `destructured`, `unused`.
230+
- Allowed `types`: `array`, `boolean`, `function`, `number`, `string`.
231+
- `parameterProperty` - matches any parameter property.
232+
- Allowed `modifiers`: `private`, `protected`, `public`, `readonly`.
233+
- Allowed `types`: `array`, `boolean`, `function`, `number`, `string`.
240234
- `typeAlias` - matches any type alias declaration.
241235
- Allowed `modifiers`: `exported`, `unused`.
242236
- 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.
238+
- Allowed `modifiers`: `public`, `requiresQuotes`.
245239
- Allowed `types`: none.
246240
- `typeParameter` - matches any generic type parameter declaration.
247241
- Allowed `modifiers`: `unused`.
248242
- Allowed `types`: none.
243+
- `typeProperty` - matches any object type property. Does not match properties that have direct function expression or arrow function expression values.
244+
- Allowed `modifiers`: `public`, `readonly`, `requiresQuotes`.
245+
- Allowed `types`: `array`, `boolean`, `function`, `number`, `string`.
246+
- `variable` - matches any `const` / `let` / `var` variable name.
247+
- Allowed `modifiers`: `async`, `const`, `destructured`, `exported`, `global`, `unused`.
248+
- Allowed `types`: `array`, `boolean`, `function`, `number`, `string`.
249249

250250
##### Group Selectors
251251

@@ -254,20 +254,20 @@ Group Selectors are provided for convenience, and essentially bundle up sets of
254254
- `default` - matches everything.
255255
- Allowed `modifiers`: all modifiers.
256256
- Allowed `types`: none.
257-
- `variableLike` - matches the same as `function`, `parameter` and `variable`.
258-
- Allowed `modifiers`: `async`, `unused`.
259-
- Allowed `types`: none.
260257
- `memberLike` - matches the same as `accessor`, `enumMember`, `method`, `parameterProperty`, `property`.
261258
- Allowed `modifiers`: `abstract`, `async`, `override`, `#private`, `private`, `protected`, `public`, `readonly`, `requiresQuotes`, `static`.
262259
- Allowed `types`: none.
263-
- `typeLike` - matches the same as `class`, `enum`, `interface`, `typeAlias`, `typeParameter`.
264-
- Allowed `modifiers`: `abstract`, `unused`.
260+
- `method` - matches the same as `classMethod`, `objectLiteralMethod`, `typeMethod`.
261+
- Allowed `modifiers`: `abstract`, `async`, `override`, `#private`, `private`, `protected`, `public`, `readonly`, `requiresQuotes`, `static`.
265262
- Allowed `types`: none.
266263
- `property` - matches the same as `classProperty`, `objectLiteralProperty`, `typeProperty`.
267264
- Allowed `modifiers`: `abstract`, `async`, `override`, `#private`, `private`, `protected`, `public`, `readonly`, `requiresQuotes`, `static`.
268265
- Allowed `types`: `array`, `boolean`, `function`, `number`, `string`.
269-
- `method` - matches the same as `classMethod`, `objectLiteralMethod`, `typeMethod`.
270-
- Allowed `modifiers`: `abstract`, `async`, `override`, `#private`, `private`, `protected`, `public`, `readonly`, `requiresQuotes`, `static`.
266+
- `typeLike` - matches the same as `class`, `enum`, `interface`, `typeAlias`, `typeParameter`.
267+
- Allowed `modifiers`: `abstract`, `unused`.
268+
- Allowed `types`: none.
269+
- `variableLike` - matches the same as `function`, `parameter` and `variable`.
270+
- Allowed `modifiers`: `async`, `unused`.
271271
- Allowed `types`: none.
272272

273273
## FAQ
@@ -278,18 +278,18 @@ This is a big rule, and there's a lot of docs. Here are a few clarifications tha
278278

279279
Each selector is checked in the following way:
280280

281-
1. check the `selector`
282-
1. if `selector` is one individual selector → the name's type must be of that type.
283-
1. if `selector` is a group selector → the name's type must be one of the grouped types.
284-
1. if `selector` is an array of selectors → apply the above for each selector in the array.
285281
1. check the `filter`
286282
1. if `filter` is omitted → skip this step.
287-
1. if the name matches the `filter` → continue evaluating this selector.
288-
1. if the name does not match the `filter` → skip this selector and continue to the next selector.
289-
1. check the `types`
283+
2. if the name matches the `filter` → continue evaluating this selector.
284+
3. if the name does not match the `filter` → skip this selector and continue to the next selector.
285+
2. check the `selector`
286+
1. if `selector` is one individual selector → the name's type must be of that type.
287+
2. if `selector` is a group selector → the name's type must be one of the grouped types.
288+
3. if `selector` is an array of selectors → apply the above for each selector in the array.
289+
3. check the `types`
290290
1. if `types` is omitted → skip this step.
291-
1. if the name has a type in `types` → continue evaluating this selector.
292-
1. if the name does not have a type in `types` → skip this selector and continue to the next selector.
291+
2. if the name has a type in `types` → continue evaluating this selector.
292+
3. if the name does not have a type in `types` → skip this selector and continue to the next selector.
293293

294294
A name is considered to pass the config if it:
295295

0 commit comments

Comments
 (0)