Skip to content

Commit c759da1

Browse files
eliasm307JoshuaKGoldberg
andauthoredNov 7, 2022
feat(eslint-plugin): [naming-convention] add support for "override" and "async" modifiers (#5310) (#5610)
* feat(eslint-plugin): [naming-convention] add support for "override" and "async" modifiers (#5310) * apply pr feedback ie remove test case util, split tests by type, remove abstract getter change, remove override for variable selector in docs * remove async parameter logic which is impossible Co-authored-by: Josh Goldberg <git@joshuakgoldberg.com>
1 parent 923d486 commit c759da1

File tree

5 files changed

+530
-13
lines changed

5 files changed

+530
-13
lines changed
 

‎packages/eslint-plugin/docs/rules/naming-convention.md

+12-11
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,8 @@ If these are provided, the identifier must start with one of the provided values
171171
- `unused` - matches anything that is not used.
172172
- `requiresQuotes` - matches any name that requires quotes as it is not a valid identifier (i.e. has a space, a dash, etc in it).
173173
- `public` - matches any member that is either explicitly declared as `public`, or has no visibility modifier (i.e. implicitly public).
174-
- `readonly`, `static`, `abstract`, `protected`, `private` - matches any member explicitly declared with the given modifier.
174+
- `readonly`, `static`, `abstract`, `protected`, `private`, `override` - matches any member explicitly declared with the given modifier.
175+
- `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)
175176
- `types` allows you to specify which types to match. This option supports simple, primitive types only (`boolean`, `string`, `number`, `array`, `function`).
176177
- The name must match _one_ of the types.
177178
- **_NOTE - Using this option will require that you lint with type information._**
@@ -194,16 +195,16 @@ There are two types of selectors, individual selectors, and grouped selectors.
194195
Individual Selectors match specific, well-defined sets. There is no overlap between each of the individual selectors.
195196

196197
- `variable` - matches any `var` / `let` / `const` variable name.
197-
- Allowed `modifiers`: `const`, `destructured`, `global`, `exported`, `unused`.
198+
- Allowed `modifiers`: `const`, `destructured`, `global`, `exported`, `unused`, `async`.
198199
- Allowed `types`: `boolean`, `string`, `number`, `function`, `array`.
199200
- `function` - matches any named function declaration or named function expression.
200-
- Allowed `modifiers`: `global`, `exported`, `unused`.
201+
- Allowed `modifiers`: `global`, `exported`, `unused`, `async`.
201202
- Allowed `types`: none.
202203
- `parameter` - matches any function parameter. Does not match parameter properties.
203204
- Allowed `modifiers`: `destructured`, `unused`.
204205
- Allowed `types`: `boolean`, `string`, `number`, `function`, `array`.
205206
- `classProperty` - matches any class property. Does not match properties that have direct function expression or arrow function expression values.
206-
- Allowed `modifiers`: `abstract`, `private`, `protected`, `public`, `readonly`, `requiresQuotes`, `static`.
207+
- Allowed `modifiers`: `abstract`, `private`, `protected`, `public`, `readonly`, `requiresQuotes`, `static`, `override`.
207208
- Allowed `types`: `boolean`, `string`, `number`, `function`, `array`.
208209
- `objectLiteralProperty` - matches any object literal property. Does not match properties that have direct function expression or arrow function expression values.
209210
- Allowed `modifiers`: `public`, `requiresQuotes`.
@@ -215,16 +216,16 @@ Individual Selectors match specific, well-defined sets. There is no overlap betw
215216
- Allowed `modifiers`: `private`, `protected`, `public`, `readonly`.
216217
- Allowed `types`: `boolean`, `string`, `number`, `function`, `array`.
217218
- `classMethod` - matches any class method. Also matches properties that have direct function expression or arrow function expression values. Does not match accessors.
218-
- Allowed `modifiers`: `abstract`, `private`, `protected`, `public`, `requiresQuotes`, `static`.
219+
- Allowed `modifiers`: `abstract`, `private`, `protected`, `public`, `requiresQuotes`, `static`, `override`, `async`.
219220
- Allowed `types`: none.
220221
- `objectLiteralMethod` - matches any object literal method. Also matches properties that have direct function expression or arrow function expression values. Does not match accessors.
221-
- Allowed `modifiers`: `public`, `requiresQuotes`.
222+
- Allowed `modifiers`: `public`, `requiresQuotes`, `async`.
222223
- Allowed `types`: none.
223224
- `typeMethod` - matches any object type method. Also matches properties that have direct function expression or arrow function expression values. Does not match accessors.
224225
- Allowed `modifiers`: `public`, `requiresQuotes`.
225226
- Allowed `types`: none.
226227
- `accessor` - matches any accessor.
227-
- Allowed `modifiers`: `abstract`, `private`, `protected`, `public`, `requiresQuotes`, `static`.
228+
- Allowed `modifiers`: `abstract`, `private`, `protected`, `public`, `requiresQuotes`, `static`, `override`.
228229
- Allowed `types`: `boolean`, `string`, `number`, `function`, `array`.
229230
- `enumMember` - matches any enum member.
230231
- Allowed `modifiers`: `requiresQuotes`.
@@ -253,19 +254,19 @@ Group Selectors are provided for convenience, and essentially bundle up sets of
253254
- Allowed `modifiers`: all modifiers.
254255
- Allowed `types`: none.
255256
- `variableLike` - matches the same as `variable`, `function` and `parameter`.
256-
- Allowed `modifiers`: `unused`.
257+
- Allowed `modifiers`: `unused`, `async`.
257258
- Allowed `types`: none.
258259
- `memberLike` - matches the same as `property`, `parameterProperty`, `method`, `accessor`, `enumMember`.
259-
- Allowed `modifiers`: `private`, `protected`, `public`, `static`, `readonly`, `abstract`, `requiresQuotes`.
260+
- Allowed `modifiers`: `private`, `protected`, `public`, `static`, `readonly`, `abstract`, `requiresQuotes`, `override`, `async`.
260261
- Allowed `types`: none.
261262
- `typeLike` - matches the same as `class`, `interface`, `typeAlias`, `enum`, `typeParameter`.
262263
- Allowed `modifiers`: `abstract`, `unused`.
263264
- Allowed `types`: none.
264265
- `property` - matches the same as `classProperty`, `objectLiteralProperty`, `typeProperty`.
265-
- Allowed `modifiers`: `private`, `protected`, `public`, `static`, `readonly`, `abstract`, `requiresQuotes`.
266+
- Allowed `modifiers`: `private`, `protected`, `public`, `static`, `readonly`, `abstract`, `requiresQuotes`, `override`, `async`.
266267
- Allowed `types`: `boolean`, `string`, `number`, `function`, `array`.
267268
- `method` - matches the same as `classMethod`, `objectLiteralMethod`, `typeMethod`.
268-
- Allowed `modifiers`: `private`, `protected`, `public`, `static`, `readonly`, `abstract`, `requiresQuotes`.
269+
- Allowed `modifiers`: `private`, `protected`, `public`, `static`, `readonly`, `abstract`, `requiresQuotes`, `override`, `async`.
269270
- Allowed `types`: none.
270271

271272
## FAQ

‎packages/eslint-plugin/src/rules/naming-convention-utils/enums.ts

+4
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ enum Modifiers {
102102
unused = 1 << 10,
103103
// properties that require quoting
104104
requiresQuotes = 1 << 11,
105+
// class members that are overridden
106+
override = 1 << 12,
107+
// class methods, object function properties, or functions that are async via the `async` keyword
108+
async = 1 << 13,
105109

106110
// make sure TypeModifiers starts at Modifiers + 1 or else sorting won't work
107111
}

‎packages/eslint-plugin/src/rules/naming-convention-utils/schema.ts

+19-2
Original file line numberDiff line numberDiff line change
@@ -170,15 +170,21 @@ const SCHEMA: JSONSchema.JSONSchema4 = {
170170
selectorsSchema(),
171171
...selectorSchema('default', false, util.getEnumNames(Modifiers)),
172172

173-
...selectorSchema('variableLike', false, ['unused']),
173+
...selectorSchema('variableLike', false, ['unused', 'async']),
174174
...selectorSchema('variable', true, [
175175
'const',
176176
'destructured',
177177
'exported',
178178
'global',
179179
'unused',
180+
'async',
181+
]),
182+
...selectorSchema('function', false, [
183+
'exported',
184+
'global',
185+
'unused',
186+
'async',
180187
]),
181-
...selectorSchema('function', false, ['exported', 'global', 'unused']),
182188
...selectorSchema('parameter', true, ['destructured', 'unused']),
183189

184190
...selectorSchema('memberLike', false, [
@@ -189,6 +195,8 @@ const SCHEMA: JSONSchema.JSONSchema4 = {
189195
'readonly',
190196
'requiresQuotes',
191197
'static',
198+
'override',
199+
'async',
192200
]),
193201
...selectorSchema('classProperty', true, [
194202
'abstract',
@@ -198,6 +206,7 @@ const SCHEMA: JSONSchema.JSONSchema4 = {
198206
'readonly',
199207
'requiresQuotes',
200208
'static',
209+
'override',
201210
]),
202211
...selectorSchema('objectLiteralProperty', true, [
203212
'public',
@@ -222,6 +231,8 @@ const SCHEMA: JSONSchema.JSONSchema4 = {
222231
'readonly',
223232
'requiresQuotes',
224233
'static',
234+
'override',
235+
'async',
225236
]),
226237

227238
...selectorSchema('classMethod', false, [
@@ -231,10 +242,13 @@ const SCHEMA: JSONSchema.JSONSchema4 = {
231242
'public',
232243
'requiresQuotes',
233244
'static',
245+
'override',
246+
'async',
234247
]),
235248
...selectorSchema('objectLiteralMethod', false, [
236249
'public',
237250
'requiresQuotes',
251+
'async',
238252
]),
239253
...selectorSchema('typeMethod', false, ['public', 'requiresQuotes']),
240254
...selectorSchema('method', false, [
@@ -244,6 +258,8 @@ const SCHEMA: JSONSchema.JSONSchema4 = {
244258
'public',
245259
'requiresQuotes',
246260
'static',
261+
'override',
262+
'async',
247263
]),
248264
...selectorSchema('accessor', true, [
249265
'abstract',
@@ -252,6 +268,7 @@ const SCHEMA: JSONSchema.JSONSchema4 = {
252268
'public',
253269
'requiresQuotes',
254270
'static',
271+
'override',
255272
]),
256273
...selectorSchema('enumMember', false, ['requiresQuotes']),
257274

‎packages/eslint-plugin/src/rules/naming-convention.ts

+49
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,9 @@ export default util.createRule<Options, MessageIds>({
138138
if ('readonly' in node && node.readonly) {
139139
modifiers.add(Modifiers.readonly);
140140
}
141+
if ('override' in node && node.override) {
142+
modifiers.add(Modifiers.override);
143+
}
141144
if (
142145
node.type === AST_NODE_TYPES.TSAbstractPropertyDefinition ||
143146
node.type === AST_NODE_TYPES.TSAbstractMethodDefinition
@@ -182,6 +185,34 @@ export default util.createRule<Options, MessageIds>({
182185
);
183186
}
184187

188+
function isAsyncMemberOrProperty(
189+
propertyOrMemberNode:
190+
| TSESTree.PropertyNonComputedName
191+
| TSESTree.TSMethodSignatureNonComputedName
192+
| TSESTree.PropertyDefinitionNonComputedName
193+
| TSESTree.TSAbstractPropertyDefinitionNonComputedName
194+
| TSESTree.MethodDefinitionNonComputedName
195+
| TSESTree.TSAbstractMethodDefinitionNonComputedName,
196+
): boolean {
197+
return Boolean(
198+
'value' in propertyOrMemberNode &&
199+
propertyOrMemberNode.value &&
200+
'async' in propertyOrMemberNode.value &&
201+
propertyOrMemberNode.value.async,
202+
);
203+
}
204+
205+
function isAsyncVariableIdentifier(id: TSESTree.Identifier): boolean {
206+
return Boolean(
207+
id.parent &&
208+
(('async' in id.parent && id.parent.async) ||
209+
('init' in id.parent &&
210+
id.parent.init &&
211+
'async' in id.parent.init &&
212+
id.parent.init.async)),
213+
);
214+
}
215+
185216
return {
186217
// #region variable
187218

@@ -219,6 +250,10 @@ export default util.createRule<Options, MessageIds>({
219250
modifiers.add(Modifiers.unused);
220251
}
221252

253+
if (isAsyncVariableIdentifier(id)) {
254+
modifiers.add(Modifiers.async);
255+
}
256+
222257
validator(id, modifiers);
223258
});
224259
},
@@ -254,6 +289,10 @@ export default util.createRule<Options, MessageIds>({
254289
modifiers.add(Modifiers.unused);
255290
}
256291

292+
if (node.async) {
293+
modifiers.add(Modifiers.async);
294+
}
295+
257296
validator(node.id, modifiers);
258297
},
259298

@@ -360,6 +399,11 @@ export default util.createRule<Options, MessageIds>({
360399
| TSESTree.TSMethodSignatureNonComputedName,
361400
): void {
362401
const modifiers = new Set<Modifiers>([Modifiers.public]);
402+
403+
if (isAsyncMemberOrProperty(node)) {
404+
modifiers.add(Modifiers.async);
405+
}
406+
363407
handleMember(validators.objectLiteralMethod, node, modifiers);
364408
},
365409

@@ -376,6 +420,11 @@ export default util.createRule<Options, MessageIds>({
376420
| TSESTree.TSAbstractMethodDefinitionNonComputedName,
377421
): void {
378422
const modifiers = getMemberModifiers(node);
423+
424+
if (isAsyncMemberOrProperty(node)) {
425+
modifiers.add(Modifiers.async);
426+
}
427+
379428
handleMember(validators.classMethod, node, modifiers);
380429
},
381430

‎packages/eslint-plugin/tests/rules/naming-convention/naming-convention.test.ts

+446
Original file line numberDiff line numberDiff line change
@@ -768,6 +768,105 @@ ruleTester.run('naming-convention', rule, {
768768
},
769769
],
770770
},
771+
{
772+
code: `
773+
const obj = {
774+
Bar() {
775+
return 42;
776+
},
777+
async async_bar() {
778+
return 42;
779+
},
780+
};
781+
class foo {
782+
public Bar() {
783+
return 42;
784+
}
785+
public async async_bar() {
786+
return 42;
787+
}
788+
}
789+
abstract class foo {
790+
public abstract Bar() {
791+
return 42;
792+
}
793+
public abstract async async_bar() {
794+
return 42;
795+
}
796+
}
797+
`,
798+
parserOptions,
799+
options: [
800+
{
801+
selector: 'memberLike',
802+
format: ['camelCase'],
803+
},
804+
{
805+
selector: ['method', 'objectLiteralMethod'],
806+
format: ['snake_case'],
807+
modifiers: ['async'],
808+
},
809+
{
810+
selector: 'method',
811+
format: ['PascalCase'],
812+
},
813+
],
814+
},
815+
{
816+
code: `
817+
const async_bar1 = async () => {};
818+
async function async_bar2() {}
819+
const async_bar3 = async function async_bar4() {};
820+
`,
821+
parserOptions,
822+
options: [
823+
{
824+
selector: 'memberLike',
825+
format: ['camelCase'],
826+
},
827+
{
828+
selector: 'method',
829+
format: ['PascalCase'],
830+
},
831+
{
832+
selector: ['variable'],
833+
format: ['snake_case'],
834+
modifiers: ['async'],
835+
},
836+
],
837+
},
838+
{
839+
code: `
840+
class foo extends bar {
841+
public someAttribute = 1;
842+
public override some_attribute_override = 1;
843+
public someMethod() {
844+
return 42;
845+
}
846+
public override some_method_override2() {
847+
return 42;
848+
}
849+
}
850+
abstract class foo extends bar {
851+
public abstract someAttribute: string;
852+
public abstract override some_attribute_override: string;
853+
public abstract someMethod(): string;
854+
public abstract override some_method_override2(): string;
855+
}
856+
`,
857+
parserOptions,
858+
options: [
859+
{
860+
selector: 'memberLike',
861+
format: ['camelCase'],
862+
},
863+
{
864+
selector: ['memberLike'],
865+
modifiers: ['override'],
866+
format: ['snake_case'],
867+
},
868+
],
869+
},
771870
],
772871
invalid: [
773872
{
@@ -1526,5 +1625,352 @@ ruleTester.run('naming-convention', rule, {
15261625
// 6, not 7 because 'foo' is valid
15271626
errors: Array(6).fill({ messageId: 'doesNotMatchFormat' }),
15281627
},
1628+
{
1629+
code: `
1630+
class foo {
1631+
public Bar() {
1632+
return 42;
1633+
}
1634+
public async async_bar() {
1635+
return 42;
1636+
}
1637+
// ❌ error
1638+
public async asyncBar() {
1639+
return 42;
1640+
}
1641+
// ❌ error
1642+
public AsyncBar2 = async () => {
1643+
return 42;
1644+
};
1645+
// ❌ error
1646+
public AsyncBar3 = async function () {
1647+
return 42;
1648+
};
1649+
}
1650+
abstract class foo {
1651+
public abstract Bar(): number;
1652+
public abstract async async_bar(): number;
1653+
// ❌ error
1654+
public abstract async ASYNC_BAR(): number;
1655+
}
1656+
`,
1657+
parserOptions,
1658+
options: [
1659+
{
1660+
selector: 'memberLike',
1661+
format: ['camelCase'],
1662+
},
1663+
{
1664+
selector: 'method',
1665+
format: ['PascalCase'],
1666+
},
1667+
{
1668+
selector: ['method', 'objectLiteralMethod'],
1669+
format: ['snake_case'],
1670+
modifiers: ['async'],
1671+
},
1672+
],
1673+
errors: [
1674+
{
1675+
messageId: 'doesNotMatchFormat',
1676+
data: {
1677+
type: 'Class Method',
1678+
name: 'asyncBar',
1679+
formats: 'snake_case',
1680+
},
1681+
},
1682+
{
1683+
messageId: 'doesNotMatchFormat',
1684+
data: {
1685+
type: 'Class Method',
1686+
name: 'AsyncBar2',
1687+
formats: 'snake_case',
1688+
},
1689+
},
1690+
{
1691+
messageId: 'doesNotMatchFormat',
1692+
data: {
1693+
type: 'Class Method',
1694+
name: 'AsyncBar3',
1695+
formats: 'snake_case',
1696+
},
1697+
},
1698+
{
1699+
messageId: 'doesNotMatchFormat',
1700+
data: {
1701+
type: 'Class Method',
1702+
name: 'ASYNC_BAR',
1703+
formats: 'snake_case',
1704+
},
1705+
},
1706+
],
1707+
},
1708+
{
1709+
code: `
1710+
const obj = {
1711+
Bar() {
1712+
return 42;
1713+
},
1714+
async async_bar() {
1715+
return 42;
1716+
},
1717+
// ❌ error
1718+
async AsyncBar() {
1719+
return 42;
1720+
},
1721+
// ❌ error
1722+
AsyncBar2: async () => {
1723+
return 42;
1724+
},
1725+
// ❌ error
1726+
AsyncBar3: async function () {
1727+
return 42;
1728+
},
1729+
};
1730+
`,
1731+
parserOptions,
1732+
options: [
1733+
{
1734+
selector: 'memberLike',
1735+
format: ['camelCase'],
1736+
},
1737+
{
1738+
selector: 'method',
1739+
format: ['PascalCase'],
1740+
},
1741+
{
1742+
selector: ['method', 'objectLiteralMethod'],
1743+
format: ['snake_case'],
1744+
modifiers: ['async'],
1745+
},
1746+
],
1747+
errors: [
1748+
{
1749+
messageId: 'doesNotMatchFormat',
1750+
data: {
1751+
type: 'Object Literal Method',
1752+
name: 'AsyncBar',
1753+
formats: 'snake_case',
1754+
},
1755+
},
1756+
{
1757+
messageId: 'doesNotMatchFormat',
1758+
data: {
1759+
type: 'Object Literal Method',
1760+
name: 'AsyncBar2',
1761+
formats: 'snake_case',
1762+
},
1763+
},
1764+
{
1765+
messageId: 'doesNotMatchFormat',
1766+
data: {
1767+
type: 'Object Literal Method',
1768+
name: 'AsyncBar3',
1769+
formats: 'snake_case',
1770+
},
1771+
},
1772+
],
1773+
},
1774+
{
1775+
code: `
1776+
const syncbar1 = () => {};
1777+
function syncBar2() {}
1778+
const syncBar3 = function syncBar4() {};
1779+
1780+
// ❌ error
1781+
const AsyncBar1 = async () => {};
1782+
const async_bar1 = async () => {};
1783+
const async_bar3 = async function async_bar4() {};
1784+
async function async_bar2() {}
1785+
// ❌ error
1786+
const asyncBar5 = async function async_bar6() {};
1787+
`,
1788+
parserOptions,
1789+
options: [
1790+
{
1791+
selector: 'variableLike',
1792+
format: ['camelCase'],
1793+
},
1794+
{
1795+
selector: ['variableLike'],
1796+
modifiers: ['async'],
1797+
format: ['snake_case'],
1798+
},
1799+
],
1800+
errors: [
1801+
{
1802+
messageId: 'doesNotMatchFormat',
1803+
data: {
1804+
type: 'Variable',
1805+
name: 'AsyncBar1',
1806+
formats: 'snake_case',
1807+
},
1808+
},
1809+
{
1810+
messageId: 'doesNotMatchFormat',
1811+
data: {
1812+
type: 'Variable',
1813+
name: 'asyncBar5',
1814+
formats: 'snake_case',
1815+
},
1816+
},
1817+
],
1818+
},
1819+
{
1820+
code: `
1821+
const syncbar1 = () => {};
1822+
function syncBar2() {}
1823+
const syncBar3 = function syncBar4() {};
1824+
1825+
const async_bar1 = async () => {};
1826+
// ❌ error
1827+
async function asyncBar2() {}
1828+
const async_bar3 = async function async_bar4() {};
1829+
async function async_bar2() {}
1830+
// ❌ error
1831+
const async_bar3 = async function ASYNC_BAR4() {};
1832+
`,
1833+
parserOptions,
1834+
options: [
1835+
{
1836+
selector: 'variableLike',
1837+
format: ['camelCase'],
1838+
},
1839+
{
1840+
selector: ['variableLike'],
1841+
modifiers: ['async'],
1842+
format: ['snake_case'],
1843+
},
1844+
],
1845+
errors: [
1846+
{
1847+
messageId: 'doesNotMatchFormat',
1848+
data: {
1849+
type: 'Function',
1850+
name: 'asyncBar2',
1851+
formats: 'snake_case',
1852+
},
1853+
},
1854+
{
1855+
messageId: 'doesNotMatchFormat',
1856+
data: {
1857+
type: 'Function',
1858+
name: 'ASYNC_BAR4',
1859+
formats: 'snake_case',
1860+
},
1861+
},
1862+
],
1863+
},
1864+
{
1865+
code: `
1866+
class foo extends bar {
1867+
public someAttribute = 1;
1868+
public override some_attribute_override = 1;
1869+
// ❌ error
1870+
public override someAttributeOverride = 1;
1871+
}
1872+
`,
1873+
parserOptions,
1874+
options: [
1875+
{
1876+
selector: 'memberLike',
1877+
format: ['camelCase'],
1878+
},
1879+
{
1880+
selector: ['memberLike'],
1881+
modifiers: ['override'],
1882+
format: ['snake_case'],
1883+
},
1884+
],
1885+
errors: [
1886+
{
1887+
messageId: 'doesNotMatchFormat',
1888+
data: {
1889+
type: 'Class Property',
1890+
name: 'someAttributeOverride',
1891+
formats: 'snake_case',
1892+
},
1893+
},
1894+
],
1895+
},
1896+
{
1897+
code: `
1898+
class foo extends bar {
1899+
public override some_method_override() {
1900+
return 42;
1901+
}
1902+
// ❌ error
1903+
public override someMethodOverride() {
1904+
return 42;
1905+
}
1906+
}
1907+
`,
1908+
parserOptions,
1909+
options: [
1910+
{
1911+
selector: 'memberLike',
1912+
format: ['camelCase'],
1913+
},
1914+
{
1915+
selector: ['memberLike'],
1916+
modifiers: ['override'],
1917+
format: ['snake_case'],
1918+
},
1919+
],
1920+
errors: [
1921+
{
1922+
messageId: 'doesNotMatchFormat',
1923+
data: {
1924+
type: 'Class Method',
1925+
name: 'someMethodOverride',
1926+
formats: 'snake_case',
1927+
},
1928+
},
1929+
],
1930+
},
1931+
{
1932+
code: `
1933+
class foo extends bar {
1934+
public get someGetter(): string;
1935+
public override get some_getter_override(): string;
1936+
// ❌ error
1937+
public override get someGetterOverride(): string;
1938+
public set someSetter(val: string);
1939+
public override set some_setter_override(val: string);
1940+
// ❌ error
1941+
public override set someSetterOverride(val: string);
1942+
}
1943+
`,
1944+
parserOptions,
1945+
options: [
1946+
{
1947+
selector: 'memberLike',
1948+
format: ['camelCase'],
1949+
},
1950+
{
1951+
selector: ['memberLike'],
1952+
modifiers: ['override'],
1953+
format: ['snake_case'],
1954+
},
1955+
],
1956+
errors: [
1957+
{
1958+
messageId: 'doesNotMatchFormat',
1959+
data: {
1960+
type: 'Accessor',
1961+
name: 'someGetterOverride',
1962+
formats: 'snake_case',
1963+
},
1964+
},
1965+
{
1966+
messageId: 'doesNotMatchFormat',
1967+
data: {
1968+
type: 'Accessor',
1969+
name: 'someSetterOverride',
1970+
formats: 'snake_case',
1971+
},
1972+
},
1973+
],
1974+
},
15291975
],
15301976
});

0 commit comments

Comments
 (0)
Please sign in to comment.