Skip to content

Commit 039adcb

Browse files
committed
Add tests for v5
1 parent 98f2f0b commit 039adcb

21 files changed

+1031
-439
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
coverage
12
dist
23
samples
34
# until re-enabled later

.eslintrc.cjs

Lines changed: 86 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
/* eslint-disable @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call */
2-
const xoTypescript = require('eslint-config-xo-typescript');
3-
41
/** @type {import('eslint').Linter.Config} */
52
module.exports = {
63
extends: [
@@ -13,21 +10,94 @@ module.exports = {
1310
},
1411
rules: {
1512
'@typescript-eslint/naming-convention': [
16-
// Allow for OBS in class/interface name
17-
...xoTypescript.rules['@typescript-eslint/naming-convention'].map(
18-
options => {
19-
console.log({options});
20-
if (options.selector === 'typeLike' || options.selector === 'interface') {
21-
return {
22-
...options,
23-
format: ['PascalCase'],
24-
};
25-
}
26-
27-
return options;
13+
// Allow for OBS in class/interface name, UPPER_CASE const
14+
'error',
15+
{
16+
// selector: ['variableLike', 'memberLike', 'property', 'method'],
17+
// Note: Leaving out `parameter` and `typeProperty` because of the mentioned known issues.
18+
// Note: We are intentionally leaving out `enumMember` as it's usually pascal-case or upper-snake-case.
19+
selector: ['function', 'classProperty', 'objectLiteralProperty', 'parameterProperty', 'classMethod', 'objectLiteralMethod', 'typeMethod', 'accessor'],
20+
format: [
21+
'strictCamelCase',
22+
],
23+
// We allow double underscope because of GraphQL type names and some React names.
24+
leadingUnderscore: 'allowSingleOrDouble',
25+
trailingUnderscore: 'allow',
26+
// Ignore `{'Retry-After': retryAfter}` type properties.
27+
filter: {
28+
regex: '[- ]',
29+
match: false,
2830
},
29-
),
31+
},
32+
// MOD: Variable separately to allow for UPPER_CASE const
33+
{
34+
selector: ['variable'],
35+
modifiers: ['const'],
36+
format: ['strictCamelCase', 'UPPER_CASE'],
37+
},
38+
{
39+
selector: ['variable'],
40+
format: [
41+
'strictCamelCase',
42+
],
43+
// We allow double underscope because of GraphQL type names and some React names.
44+
leadingUnderscore: 'allowSingleOrDouble',
45+
trailingUnderscore: 'allow',
46+
},
47+
{
48+
selector: 'typeLike',
49+
format: [
50+
// MOD: Allow for OBS
51+
'PascalCase',
52+
],
53+
},
54+
{
55+
selector: 'variable',
56+
types: [
57+
'boolean',
58+
],
59+
format: [
60+
'StrictPascalCase',
61+
],
62+
prefix: [
63+
'is',
64+
'has',
65+
'can',
66+
'should',
67+
'will',
68+
'did',
69+
],
70+
},
71+
{
72+
// Interface name should not be prefixed with `I`.
73+
selector: 'interface',
74+
filter: /^(?!I)[A-Z]/.source,
75+
format: [
76+
// MOD: Allow for OBS
77+
'PascalCase',
78+
],
79+
},
80+
{
81+
// Type parameter name should either be `T` or a descriptive name.
82+
selector: 'typeParameter',
83+
filter: /^T$|^[A-Z][a-zA-Z]+$/.source,
84+
format: [
85+
'StrictPascalCase',
86+
],
87+
},
88+
// Allow these in non-camel-case when quoted.
89+
{
90+
selector: [
91+
'classProperty',
92+
'objectLiteralProperty',
93+
],
94+
format: null,
95+
modifiers: [
96+
'requiresQuotes',
97+
],
98+
},
3099
],
100+
'capitalized-comments': 'off',
31101
},
32102
overrides: [
33103
{

0 commit comments

Comments
 (0)