@graphql-eslint/eslint-plugin 4.0.1 → 4.1.0-alpha-20241128212708-133b421ba884f8bd8ca52bbc853ad2ee6ca68edb
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/index.d.cts +6 -0
- package/cjs/meta.js +1 -1
- package/cjs/rules/index.d.cts +6 -0
- package/cjs/rules/naming-convention/index.d.cts +22 -0
- package/cjs/rules/naming-convention/index.js +56 -10
- package/esm/index.d.ts +6 -0
- package/esm/meta.js +1 -1
- package/esm/rules/index.d.ts +6 -0
- package/esm/rules/naming-convention/index.d.ts +22 -0
- package/esm/rules/naming-convention/index.js +54 -8
- package/index.browser.js +54 -9
- package/package.json +1 -1
package/cjs/index.d.cts
CHANGED
@@ -98,6 +98,12 @@ declare const _default: {
|
|
98
98
|
style?: ("camelCase" | "PascalCase" | "snake_case" | "UPPER_CASE") | undefined;
|
99
99
|
suffix?: string | undefined;
|
100
100
|
prefix?: string | undefined;
|
101
|
+
forbiddenPattern?: {
|
102
|
+
[x: string]: unknown;
|
103
|
+
}[] | undefined;
|
104
|
+
requiredPattern?: {
|
105
|
+
[x: string]: unknown;
|
106
|
+
}[] | undefined;
|
101
107
|
forbiddenPrefixes?: string[] | undefined;
|
102
108
|
forbiddenSuffixes?: string[] | undefined;
|
103
109
|
requiredPrefixes?: string[] | undefined;
|
package/cjs/meta.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});const version = "4.0
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});const version = "4.1.0-alpha-20241128212708-133b421ba884f8bd8ca52bbc853ad2ee6ca68edb";
|
2
2
|
|
3
3
|
|
4
4
|
exports.version = version;
|
package/cjs/rules/index.d.cts
CHANGED
@@ -61,6 +61,12 @@ declare const rules: {
|
|
61
61
|
style?: ("camelCase" | "PascalCase" | "snake_case" | "UPPER_CASE") | undefined;
|
62
62
|
suffix?: string | undefined;
|
63
63
|
prefix?: string | undefined;
|
64
|
+
forbiddenPattern?: {
|
65
|
+
[x: string]: unknown;
|
66
|
+
}[] | undefined;
|
67
|
+
requiredPattern?: {
|
68
|
+
[x: string]: unknown;
|
69
|
+
}[] | undefined;
|
64
70
|
forbiddenPrefixes?: string[] | undefined;
|
65
71
|
forbiddenSuffixes?: string[] | undefined;
|
66
72
|
requiredPrefixes?: string[] | undefined;
|
@@ -28,7 +28,26 @@ declare const schema: {
|
|
28
28
|
readonly suffix: {
|
29
29
|
readonly type: "string";
|
30
30
|
};
|
31
|
+
readonly forbiddenPattern: {
|
32
|
+
readonly items: {
|
33
|
+
readonly type: "object";
|
34
|
+
};
|
35
|
+
readonly description: "Should be of instance of `RegEx`";
|
36
|
+
readonly type: "array";
|
37
|
+
readonly uniqueItems: true;
|
38
|
+
readonly minItems: 1;
|
39
|
+
};
|
40
|
+
readonly requiredPattern: {
|
41
|
+
readonly items: {
|
42
|
+
readonly type: "object";
|
43
|
+
};
|
44
|
+
readonly description: "Should be of instance of `RegEx`";
|
45
|
+
readonly type: "array";
|
46
|
+
readonly uniqueItems: true;
|
47
|
+
readonly minItems: 1;
|
48
|
+
};
|
31
49
|
readonly forbiddenPrefixes: {
|
50
|
+
readonly description: string;
|
32
51
|
readonly type: "array";
|
33
52
|
readonly uniqueItems: true;
|
34
53
|
readonly minItems: 1;
|
@@ -37,6 +56,7 @@ declare const schema: {
|
|
37
56
|
};
|
38
57
|
};
|
39
58
|
readonly forbiddenSuffixes: {
|
59
|
+
readonly description: string;
|
40
60
|
readonly type: "array";
|
41
61
|
readonly uniqueItems: true;
|
42
62
|
readonly minItems: 1;
|
@@ -45,6 +65,7 @@ declare const schema: {
|
|
45
65
|
};
|
46
66
|
};
|
47
67
|
readonly requiredPrefixes: {
|
68
|
+
readonly description: string;
|
48
69
|
readonly type: "array";
|
49
70
|
readonly uniqueItems: true;
|
50
71
|
readonly minItems: 1;
|
@@ -53,6 +74,7 @@ declare const schema: {
|
|
53
74
|
};
|
54
75
|
};
|
55
76
|
readonly requiredSuffixes: {
|
77
|
+
readonly description: string;
|
56
78
|
readonly type: "array";
|
57
79
|
readonly uniqueItems: true;
|
58
80
|
readonly minItems: 1;
|
@@ -5,6 +5,7 @@
|
|
5
5
|
|
6
6
|
|
7
7
|
|
8
|
+
|
8
9
|
var _utilsjs = require('../../utils.js');
|
9
10
|
const KindToDisplayName = {
|
10
11
|
// types
|
@@ -31,7 +32,9 @@ const KindToDisplayName = {
|
|
31
32
|
UPPER_CASE: /^[A-Z][\dA-Z_]*[\dA-Z]*$/
|
32
33
|
}, ALLOWED_KINDS = Object.keys(KindToDisplayName).sort(), ALLOWED_STYLES = Object.keys(StyleToRegex), schemaOption = {
|
33
34
|
oneOf: [{ $ref: "#/definitions/asString" }, { $ref: "#/definitions/asObject" }]
|
34
|
-
},
|
35
|
+
}, descriptionPrefixesSuffixes = (name) => `> [!WARNING]
|
36
|
+
>
|
37
|
+
> This option is deprecated and will be removed in the next major release. Use \`${name}\` instead`, schema = {
|
35
38
|
definitions: {
|
36
39
|
asString: {
|
37
40
|
enum: ALLOWED_STYLES,
|
@@ -44,10 +47,36 @@ const KindToDisplayName = {
|
|
44
47
|
style: { enum: ALLOWED_STYLES },
|
45
48
|
prefix: { type: "string" },
|
46
49
|
suffix: { type: "string" },
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
50
|
+
forbiddenPattern: {
|
51
|
+
..._utilsjs.ARRAY_DEFAULT_OPTIONS,
|
52
|
+
items: {
|
53
|
+
type: "object"
|
54
|
+
},
|
55
|
+
description: "Should be of instance of `RegEx`"
|
56
|
+
},
|
57
|
+
requiredPattern: {
|
58
|
+
..._utilsjs.ARRAY_DEFAULT_OPTIONS,
|
59
|
+
items: {
|
60
|
+
type: "object"
|
61
|
+
},
|
62
|
+
description: "Should be of instance of `RegEx`"
|
63
|
+
},
|
64
|
+
forbiddenPrefixes: {
|
65
|
+
..._utilsjs.ARRAY_DEFAULT_OPTIONS,
|
66
|
+
description: descriptionPrefixesSuffixes("forbiddenPattern")
|
67
|
+
},
|
68
|
+
forbiddenSuffixes: {
|
69
|
+
..._utilsjs.ARRAY_DEFAULT_OPTIONS,
|
70
|
+
description: descriptionPrefixesSuffixes("forbiddenPattern")
|
71
|
+
},
|
72
|
+
requiredPrefixes: {
|
73
|
+
..._utilsjs.ARRAY_DEFAULT_OPTIONS,
|
74
|
+
description: descriptionPrefixesSuffixes("requiredPattern")
|
75
|
+
},
|
76
|
+
requiredSuffixes: {
|
77
|
+
..._utilsjs.ARRAY_DEFAULT_OPTIONS,
|
78
|
+
description: descriptionPrefixesSuffixes("requiredPattern")
|
79
|
+
},
|
51
80
|
ignorePattern: {
|
52
81
|
type: "string",
|
53
82
|
description: "Option to skip validation of some words, e.g. acronyms"
|
@@ -326,13 +355,19 @@ ${_utilsjs.TYPES_KINDS.map((kind) => `- \`${kind}\``).join(`
|
|
326
355
|
style,
|
327
356
|
ignorePattern,
|
328
357
|
requiredPrefixes,
|
329
|
-
requiredSuffixes
|
330
|
-
|
358
|
+
requiredSuffixes,
|
359
|
+
forbiddenPattern,
|
360
|
+
requiredPattern
|
361
|
+
} = normalisePropertyOption(selector), nodeName = node.value, error = getError();
|
331
362
|
if (error) {
|
332
363
|
const { errorMessage, renameToNames } = error, [leadingUnderscores] = nodeName.match(/^_*/), [trailingUnderscores] = nodeName.match(/_*$/), suggestedNames = renameToNames.map(
|
333
364
|
(renameToName) => leadingUnderscores + renameToName + trailingUnderscores
|
365
|
+
), name = _utilsjs.displayNodeName.call(void 0, n);
|
366
|
+
report(
|
367
|
+
node,
|
368
|
+
`${name[0].toUpperCase()}${name.slice(1)} should ${errorMessage}`,
|
369
|
+
suggestedNames
|
334
370
|
);
|
335
|
-
report(node, `${nodeType} "${nodeName}" should ${errorMessage}`, suggestedNames);
|
336
371
|
}
|
337
372
|
function getError() {
|
338
373
|
const name = nodeName.replace(/(^_+)|(_+$)/g, "");
|
@@ -348,13 +383,24 @@ ${_utilsjs.TYPES_KINDS.map((kind) => `- \`${kind}\``).join(`
|
|
348
383
|
errorMessage: `have "${suffix}" suffix`,
|
349
384
|
renameToNames: [name + suffix]
|
350
385
|
};
|
351
|
-
const
|
386
|
+
const forbidden = _optionalChain([forbiddenPattern, 'optionalAccess', _ => _.find, 'call', _2 => _2((pattern) => pattern.test(name))]);
|
387
|
+
if (forbidden)
|
388
|
+
return {
|
389
|
+
errorMessage: `not contain the forbidden pattern "${forbidden}"`,
|
390
|
+
renameToNames: [name.replace(forbidden, "")]
|
391
|
+
};
|
392
|
+
if (requiredPattern && !requiredPattern.some((pattern) => pattern.test(name)))
|
393
|
+
return {
|
394
|
+
errorMessage: `contain the required pattern: ${_utilsjs.englishJoinWords.call(void 0, requiredPattern.map((re) => re.source))}`,
|
395
|
+
renameToNames: []
|
396
|
+
};
|
397
|
+
const forbiddenPrefix = _optionalChain([forbiddenPrefixes, 'optionalAccess', _3 => _3.find, 'call', _4 => _4((prefix2) => name.startsWith(prefix2))]);
|
352
398
|
if (forbiddenPrefix)
|
353
399
|
return {
|
354
400
|
errorMessage: `not have "${forbiddenPrefix}" prefix`,
|
355
401
|
renameToNames: [name.replace(new RegExp(`^${forbiddenPrefix}`), "")]
|
356
402
|
};
|
357
|
-
const forbiddenSuffix = _optionalChain([forbiddenSuffixes, 'optionalAccess',
|
403
|
+
const forbiddenSuffix = _optionalChain([forbiddenSuffixes, 'optionalAccess', _5 => _5.find, 'call', _6 => _6((suffix2) => name.endsWith(suffix2))]);
|
358
404
|
if (forbiddenSuffix)
|
359
405
|
return {
|
360
406
|
errorMessage: `not have "${forbiddenSuffix}" suffix`,
|
package/esm/index.d.ts
CHANGED
@@ -98,6 +98,12 @@ declare const _default: {
|
|
98
98
|
style?: ("camelCase" | "PascalCase" | "snake_case" | "UPPER_CASE") | undefined;
|
99
99
|
suffix?: string | undefined;
|
100
100
|
prefix?: string | undefined;
|
101
|
+
forbiddenPattern?: {
|
102
|
+
[x: string]: unknown;
|
103
|
+
}[] | undefined;
|
104
|
+
requiredPattern?: {
|
105
|
+
[x: string]: unknown;
|
106
|
+
}[] | undefined;
|
101
107
|
forbiddenPrefixes?: string[] | undefined;
|
102
108
|
forbiddenSuffixes?: string[] | undefined;
|
103
109
|
requiredPrefixes?: string[] | undefined;
|
package/esm/meta.js
CHANGED
package/esm/rules/index.d.ts
CHANGED
@@ -61,6 +61,12 @@ declare const rules: {
|
|
61
61
|
style?: ("camelCase" | "PascalCase" | "snake_case" | "UPPER_CASE") | undefined;
|
62
62
|
suffix?: string | undefined;
|
63
63
|
prefix?: string | undefined;
|
64
|
+
forbiddenPattern?: {
|
65
|
+
[x: string]: unknown;
|
66
|
+
}[] | undefined;
|
67
|
+
requiredPattern?: {
|
68
|
+
[x: string]: unknown;
|
69
|
+
}[] | undefined;
|
64
70
|
forbiddenPrefixes?: string[] | undefined;
|
65
71
|
forbiddenSuffixes?: string[] | undefined;
|
66
72
|
requiredPrefixes?: string[] | undefined;
|
@@ -28,7 +28,26 @@ declare const schema: {
|
|
28
28
|
readonly suffix: {
|
29
29
|
readonly type: "string";
|
30
30
|
};
|
31
|
+
readonly forbiddenPattern: {
|
32
|
+
readonly items: {
|
33
|
+
readonly type: "object";
|
34
|
+
};
|
35
|
+
readonly description: "Should be of instance of `RegEx`";
|
36
|
+
readonly type: "array";
|
37
|
+
readonly uniqueItems: true;
|
38
|
+
readonly minItems: 1;
|
39
|
+
};
|
40
|
+
readonly requiredPattern: {
|
41
|
+
readonly items: {
|
42
|
+
readonly type: "object";
|
43
|
+
};
|
44
|
+
readonly description: "Should be of instance of `RegEx`";
|
45
|
+
readonly type: "array";
|
46
|
+
readonly uniqueItems: true;
|
47
|
+
readonly minItems: 1;
|
48
|
+
};
|
31
49
|
readonly forbiddenPrefixes: {
|
50
|
+
readonly description: string;
|
32
51
|
readonly type: "array";
|
33
52
|
readonly uniqueItems: true;
|
34
53
|
readonly minItems: 1;
|
@@ -37,6 +56,7 @@ declare const schema: {
|
|
37
56
|
};
|
38
57
|
};
|
39
58
|
readonly forbiddenSuffixes: {
|
59
|
+
readonly description: string;
|
40
60
|
readonly type: "array";
|
41
61
|
readonly uniqueItems: true;
|
42
62
|
readonly minItems: 1;
|
@@ -45,6 +65,7 @@ declare const schema: {
|
|
45
65
|
};
|
46
66
|
};
|
47
67
|
readonly requiredPrefixes: {
|
68
|
+
readonly description: string;
|
48
69
|
readonly type: "array";
|
49
70
|
readonly uniqueItems: true;
|
50
71
|
readonly minItems: 1;
|
@@ -53,6 +74,7 @@ declare const schema: {
|
|
53
74
|
};
|
54
75
|
};
|
55
76
|
readonly requiredSuffixes: {
|
77
|
+
readonly description: string;
|
56
78
|
readonly type: "array";
|
57
79
|
readonly uniqueItems: true;
|
58
80
|
readonly minItems: 1;
|
@@ -2,6 +2,7 @@ import { Kind } from "graphql";
|
|
2
2
|
import {
|
3
3
|
ARRAY_DEFAULT_OPTIONS,
|
4
4
|
convertCase,
|
5
|
+
displayNodeName,
|
5
6
|
englishJoinWords,
|
6
7
|
truthy,
|
7
8
|
TYPES_KINDS
|
@@ -31,7 +32,9 @@ const KindToDisplayName = {
|
|
31
32
|
UPPER_CASE: /^[A-Z][\dA-Z_]*[\dA-Z]*$/
|
32
33
|
}, ALLOWED_KINDS = Object.keys(KindToDisplayName).sort(), ALLOWED_STYLES = Object.keys(StyleToRegex), schemaOption = {
|
33
34
|
oneOf: [{ $ref: "#/definitions/asString" }, { $ref: "#/definitions/asObject" }]
|
34
|
-
},
|
35
|
+
}, descriptionPrefixesSuffixes = (name) => `> [!WARNING]
|
36
|
+
>
|
37
|
+
> This option is deprecated and will be removed in the next major release. Use \`${name}\` instead`, schema = {
|
35
38
|
definitions: {
|
36
39
|
asString: {
|
37
40
|
enum: ALLOWED_STYLES,
|
@@ -44,10 +47,36 @@ const KindToDisplayName = {
|
|
44
47
|
style: { enum: ALLOWED_STYLES },
|
45
48
|
prefix: { type: "string" },
|
46
49
|
suffix: { type: "string" },
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
50
|
+
forbiddenPattern: {
|
51
|
+
...ARRAY_DEFAULT_OPTIONS,
|
52
|
+
items: {
|
53
|
+
type: "object"
|
54
|
+
},
|
55
|
+
description: "Should be of instance of `RegEx`"
|
56
|
+
},
|
57
|
+
requiredPattern: {
|
58
|
+
...ARRAY_DEFAULT_OPTIONS,
|
59
|
+
items: {
|
60
|
+
type: "object"
|
61
|
+
},
|
62
|
+
description: "Should be of instance of `RegEx`"
|
63
|
+
},
|
64
|
+
forbiddenPrefixes: {
|
65
|
+
...ARRAY_DEFAULT_OPTIONS,
|
66
|
+
description: descriptionPrefixesSuffixes("forbiddenPattern")
|
67
|
+
},
|
68
|
+
forbiddenSuffixes: {
|
69
|
+
...ARRAY_DEFAULT_OPTIONS,
|
70
|
+
description: descriptionPrefixesSuffixes("forbiddenPattern")
|
71
|
+
},
|
72
|
+
requiredPrefixes: {
|
73
|
+
...ARRAY_DEFAULT_OPTIONS,
|
74
|
+
description: descriptionPrefixesSuffixes("requiredPattern")
|
75
|
+
},
|
76
|
+
requiredSuffixes: {
|
77
|
+
...ARRAY_DEFAULT_OPTIONS,
|
78
|
+
description: descriptionPrefixesSuffixes("requiredPattern")
|
79
|
+
},
|
51
80
|
ignorePattern: {
|
52
81
|
type: "string",
|
53
82
|
description: "Option to skip validation of some words, e.g. acronyms"
|
@@ -326,13 +355,19 @@ ${TYPES_KINDS.map((kind) => `- \`${kind}\``).join(`
|
|
326
355
|
style,
|
327
356
|
ignorePattern,
|
328
357
|
requiredPrefixes,
|
329
|
-
requiredSuffixes
|
330
|
-
|
358
|
+
requiredSuffixes,
|
359
|
+
forbiddenPattern,
|
360
|
+
requiredPattern
|
361
|
+
} = normalisePropertyOption(selector), nodeName = node.value, error = getError();
|
331
362
|
if (error) {
|
332
363
|
const { errorMessage, renameToNames } = error, [leadingUnderscores] = nodeName.match(/^_*/), [trailingUnderscores] = nodeName.match(/_*$/), suggestedNames = renameToNames.map(
|
333
364
|
(renameToName) => leadingUnderscores + renameToName + trailingUnderscores
|
365
|
+
), name = displayNodeName(n);
|
366
|
+
report(
|
367
|
+
node,
|
368
|
+
`${name[0].toUpperCase()}${name.slice(1)} should ${errorMessage}`,
|
369
|
+
suggestedNames
|
334
370
|
);
|
335
|
-
report(node, `${nodeType} "${nodeName}" should ${errorMessage}`, suggestedNames);
|
336
371
|
}
|
337
372
|
function getError() {
|
338
373
|
const name = nodeName.replace(/(^_+)|(_+$)/g, "");
|
@@ -348,6 +383,17 @@ ${TYPES_KINDS.map((kind) => `- \`${kind}\``).join(`
|
|
348
383
|
errorMessage: `have "${suffix}" suffix`,
|
349
384
|
renameToNames: [name + suffix]
|
350
385
|
};
|
386
|
+
const forbidden = forbiddenPattern?.find((pattern) => pattern.test(name));
|
387
|
+
if (forbidden)
|
388
|
+
return {
|
389
|
+
errorMessage: `not contain the forbidden pattern "${forbidden}"`,
|
390
|
+
renameToNames: [name.replace(forbidden, "")]
|
391
|
+
};
|
392
|
+
if (requiredPattern && !requiredPattern.some((pattern) => pattern.test(name)))
|
393
|
+
return {
|
394
|
+
errorMessage: `contain the required pattern: ${englishJoinWords(requiredPattern.map((re) => re.source))}`,
|
395
|
+
renameToNames: []
|
396
|
+
};
|
351
397
|
const forbiddenPrefix = forbiddenPrefixes?.find((prefix2) => name.startsWith(prefix2));
|
352
398
|
if (forbiddenPrefix)
|
353
399
|
return {
|
package/index.browser.js
CHANGED
@@ -150,7 +150,7 @@ function convertToESTree(node, schema16) {
|
|
150
150
|
}
|
151
151
|
|
152
152
|
// src/meta.ts
|
153
|
-
var version =
|
153
|
+
var version = "4.1.0-alpha-20241128212708-133b421ba884f8bd8ca52bbc853ad2ee6ca68edb";
|
154
154
|
|
155
155
|
// src/siblings.ts
|
156
156
|
import {
|
@@ -1919,7 +1919,9 @@ var KindToDisplayName = {
|
|
1919
1919
|
UPPER_CASE: /^[A-Z][\dA-Z_]*[\dA-Z]*$/
|
1920
1920
|
}, ALLOWED_KINDS = Object.keys(KindToDisplayName).sort(), ALLOWED_STYLES = Object.keys(StyleToRegex), schemaOption2 = {
|
1921
1921
|
oneOf: [{ $ref: "#/definitions/asString" }, { $ref: "#/definitions/asObject" }]
|
1922
|
-
},
|
1922
|
+
}, descriptionPrefixesSuffixes = (name) => `> [!WARNING]
|
1923
|
+
>
|
1924
|
+
> This option is deprecated and will be removed in the next major release. Use \`${name}\` instead`, schema6 = {
|
1923
1925
|
definitions: {
|
1924
1926
|
asString: {
|
1925
1927
|
enum: ALLOWED_STYLES,
|
@@ -1932,10 +1934,36 @@ var KindToDisplayName = {
|
|
1932
1934
|
style: { enum: ALLOWED_STYLES },
|
1933
1935
|
prefix: { type: "string" },
|
1934
1936
|
suffix: { type: "string" },
|
1935
|
-
|
1936
|
-
|
1937
|
-
|
1938
|
-
|
1937
|
+
forbiddenPattern: {
|
1938
|
+
...ARRAY_DEFAULT_OPTIONS,
|
1939
|
+
items: {
|
1940
|
+
type: "object"
|
1941
|
+
},
|
1942
|
+
description: "Should be of instance of `RegEx`"
|
1943
|
+
},
|
1944
|
+
requiredPattern: {
|
1945
|
+
...ARRAY_DEFAULT_OPTIONS,
|
1946
|
+
items: {
|
1947
|
+
type: "object"
|
1948
|
+
},
|
1949
|
+
description: "Should be of instance of `RegEx`"
|
1950
|
+
},
|
1951
|
+
forbiddenPrefixes: {
|
1952
|
+
...ARRAY_DEFAULT_OPTIONS,
|
1953
|
+
description: descriptionPrefixesSuffixes("forbiddenPattern")
|
1954
|
+
},
|
1955
|
+
forbiddenSuffixes: {
|
1956
|
+
...ARRAY_DEFAULT_OPTIONS,
|
1957
|
+
description: descriptionPrefixesSuffixes("forbiddenPattern")
|
1958
|
+
},
|
1959
|
+
requiredPrefixes: {
|
1960
|
+
...ARRAY_DEFAULT_OPTIONS,
|
1961
|
+
description: descriptionPrefixesSuffixes("requiredPattern")
|
1962
|
+
},
|
1963
|
+
requiredSuffixes: {
|
1964
|
+
...ARRAY_DEFAULT_OPTIONS,
|
1965
|
+
description: descriptionPrefixesSuffixes("requiredPattern")
|
1966
|
+
},
|
1939
1967
|
ignorePattern: {
|
1940
1968
|
type: "string",
|
1941
1969
|
description: "Option to skip validation of some words, e.g. acronyms"
|
@@ -2214,13 +2242,19 @@ ${TYPES_KINDS.map((kind) => `- \`${kind}\``).join(`
|
|
2214
2242
|
style,
|
2215
2243
|
ignorePattern,
|
2216
2244
|
requiredPrefixes,
|
2217
|
-
requiredSuffixes
|
2218
|
-
|
2245
|
+
requiredSuffixes,
|
2246
|
+
forbiddenPattern,
|
2247
|
+
requiredPattern
|
2248
|
+
} = normalisePropertyOption(selector), nodeName = node.value, error = getError();
|
2219
2249
|
if (error) {
|
2220
2250
|
let { errorMessage, renameToNames } = error, [leadingUnderscores] = nodeName.match(/^_*/), [trailingUnderscores] = nodeName.match(/_*$/), suggestedNames = renameToNames.map(
|
2221
2251
|
(renameToName) => leadingUnderscores + renameToName + trailingUnderscores
|
2252
|
+
), name = displayNodeName(n);
|
2253
|
+
report(
|
2254
|
+
node,
|
2255
|
+
`${name[0].toUpperCase()}${name.slice(1)} should ${errorMessage}`,
|
2256
|
+
suggestedNames
|
2222
2257
|
);
|
2223
|
-
report(node, `${nodeType} "${nodeName}" should ${errorMessage}`, suggestedNames);
|
2224
2258
|
}
|
2225
2259
|
function getError() {
|
2226
2260
|
let name = nodeName.replace(/(^_+)|(_+$)/g, "");
|
@@ -2236,6 +2270,17 @@ ${TYPES_KINDS.map((kind) => `- \`${kind}\``).join(`
|
|
2236
2270
|
errorMessage: `have "${suffix}" suffix`,
|
2237
2271
|
renameToNames: [name + suffix]
|
2238
2272
|
};
|
2273
|
+
let forbidden = forbiddenPattern?.find((pattern) => pattern.test(name));
|
2274
|
+
if (forbidden)
|
2275
|
+
return {
|
2276
|
+
errorMessage: `not contain the forbidden pattern "${forbidden}"`,
|
2277
|
+
renameToNames: [name.replace(forbidden, "")]
|
2278
|
+
};
|
2279
|
+
if (requiredPattern && !requiredPattern.some((pattern) => pattern.test(name)))
|
2280
|
+
return {
|
2281
|
+
errorMessage: `contain the required pattern: ${englishJoinWords(requiredPattern.map((re) => re.source))}`,
|
2282
|
+
renameToNames: []
|
2283
|
+
};
|
2239
2284
|
let forbiddenPrefix = forbiddenPrefixes?.find((prefix2) => name.startsWith(prefix2));
|
2240
2285
|
if (forbiddenPrefix)
|
2241
2286
|
return {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@graphql-eslint/eslint-plugin",
|
3
|
-
"version": "4.0
|
3
|
+
"version": "4.1.0-alpha-20241128212708-133b421ba884f8bd8ca52bbc853ad2ee6ca68edb",
|
4
4
|
"type": "module",
|
5
5
|
"description": "GraphQL plugin for ESLint",
|
6
6
|
"repository": "https://github.com/dimaMachina/graphql-eslint",
|