Skip to content

Commit 1136c1c

Browse files
committed
aa
1 parent 0cacf02 commit 1136c1c

File tree

5 files changed

+14
-6
lines changed

5 files changed

+14
-6
lines changed

packages/plugin/src/rules/naming-convention/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,15 @@ const schema = {
7070
...ARRAY_DEFAULT_OPTIONS,
7171
items: {
7272
type: 'object',
73-
description: 'RegEx',
7473
},
74+
description: 'RegEx',
7575
},
7676
requiredPattern: {
7777
...ARRAY_DEFAULT_OPTIONS,
7878
items: {
7979
type: 'object',
80-
description: 'RegEx',
8180
},
81+
description: 'RegEx',
8282
},
8383
forbiddenPrefixes: {
8484
...ARRAY_DEFAULT_OPTIONS,

packages/plugin/src/rules/naming-convention/snapshot.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -385,8 +385,7 @@ exports[`naming-convention > invalid > forbiddenPattern 1`] = `
385385
{
386386
"OperationDefinition": {
387387
"forbiddenPattern": [
388-
"^get",
389-
"^query"
388+
"/^(get|query)/"
390389
]
391390
}
392391
}
@@ -1985,8 +1984,7 @@ exports[`naming-convention > invalid > requiredPattern 1`] = `
19851984
"FieldDefinition[gqlType.gqlType.name.value=Boolean]": {
19861985
"style": "camelCase",
19871986
"requiredPattern": [
1988-
"^is",
1989-
"^has"
1987+
"/^(is|has)/"
19901988
]
19911989
}
19921990
}

packages/plugin/tsup.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ export default defineConfig([
6363
dts: false,
6464
bundle: true,
6565
env: {
66+
...opts.env,
6667
NODE_ENV: 'production',
6768
},
6869
esbuildOptions(options, _context) {

packages/rule-tester/src/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ function applyFix(code: string, { range, text }: Rule.Fix): string {
2525
return [code.slice(0, range[0]), text, code.slice(range[1])].join('');
2626
}
2727

28+
// @ts-expect-error -- Extend RegExp with a custom toJSON method
29+
RegExp.prototype.toJSON = function() {
30+
return `/${this.source}/${this.flags}`
31+
};
32+
2833
export class RuleTester<ParserOptions> extends ESLintRuleTester {
2934
fromMockFile(path: string): string {
3035
return readFileSync(resolve(__dirname, `../../plugin/__tests__/mocks/${path}`), 'utf-8');

website/content/rules/naming-convention.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,8 @@ This element must be one of the following enum values:
323323

324324
### `forbiddenPattern` (array)
325325

326+
RegEx
327+
326328
The object is an array with all elements of the type `object`.
327329

328330
The array object has the following properties:
@@ -334,6 +336,8 @@ Additional restrictions:
334336

335337
### `requiredPattern` (array)
336338

339+
RegEx
340+
337341
The object is an array with all elements of the type `object`.
338342

339343
The array object has the following properties:

0 commit comments

Comments
 (0)