From 8a5c6212e05a16c5a172bc4ba939452c1771d462 Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Fri, 29 Nov 2024 03:02:45 +0700 Subject: [PATCH 01/14] introduce `forbiddenPattern` and `requiredPattern` options for `naming-convention` rule and deprecate `forbiddenPrefixes`, `forbiddenSuffixes` and `requiredPrefixes` and `requiredSuffixes` --- .changeset/happy-bottles-warn.md | 5 ++++ .../src/rules/naming-convention/index.ts | 25 ++++++++++++++++--- website/content/docs/usage/js.mdx | 2 +- website/content/rules/alphabetize.mdx | 4 +-- website/content/rules/description-style.mdx | 4 +-- website/content/rules/input-name.mdx | 4 +-- .../rules/lone-executable-definition.mdx | 4 +-- .../content/rules/match-document-filename.mdx | 4 +-- .../content/rules/no-anonymous-operations.mdx | 4 +-- website/content/rules/no-deprecated.mdx | 4 +-- website/content/rules/no-duplicate-fields.mdx | 4 +-- .../content/rules/no-hashtag-description.mdx | 4 +-- .../content/rules/no-one-place-fragments.mdx | 4 +-- website/content/rules/no-root-type.mdx | 4 +-- .../no-scalar-result-type-on-mutation.mdx | 4 +-- website/content/rules/no-typename-prefix.mdx | 4 +-- .../content/rules/no-unreachable-types.mdx | 4 +-- website/content/rules/no-unused-fields.mdx | 4 +-- website/content/rules/relay-arguments.mdx | 4 +-- .../content/rules/relay-connection-types.mdx | 4 +-- website/content/rules/relay-edge-types.mdx | 4 +-- website/content/rules/relay-page-info.mdx | 4 +-- .../rules/require-deprecation-date.mdx | 4 +-- .../rules/require-deprecation-reason.mdx | 4 +-- website/content/rules/require-description.mdx | 4 +-- ...field-of-type-query-in-mutation-result.mdx | 4 +-- .../content/rules/require-import-fragment.mdx | 4 +-- .../require-nullable-fields-with-oneof.mdx | 4 +-- .../rules/require-nullable-result-in-root.mdx | 4 +-- website/content/rules/require-selections.mdx | 4 +-- .../rules/require-type-pattern-with-oneof.mdx | 4 +-- website/content/rules/selection-set-depth.mdx | 4 +-- website/content/rules/strict-id-in-types.mdx | 4 +-- .../content/rules/unique-enum-value-names.mdx | 4 +-- .../content/rules/unique-fragment-name.mdx | 4 +-- .../content/rules/unique-operation-name.mdx | 4 +-- 36 files changed, 93 insertions(+), 71 deletions(-) create mode 100644 .changeset/happy-bottles-warn.md diff --git a/.changeset/happy-bottles-warn.md b/.changeset/happy-bottles-warn.md new file mode 100644 index 00000000000..1dbe307d217 --- /dev/null +++ b/.changeset/happy-bottles-warn.md @@ -0,0 +1,5 @@ +--- +'@graphql-eslint/eslint-plugin': minor +--- + +introduce `forbiddenPattern` and `requiredPattern` options for `naming-convention` rule and deprecate `forbiddenPrefixes`, `forbiddenSuffixes` and `requiredPrefixes` and `requiredSuffixes` diff --git a/packages/plugin/src/rules/naming-convention/index.ts b/packages/plugin/src/rules/naming-convention/index.ts index 8917e23dfee..657899f84dd 100644 --- a/packages/plugin/src/rules/naming-convention/index.ts +++ b/packages/plugin/src/rules/naming-convention/index.ts @@ -47,6 +47,9 @@ const schemaOption = { oneOf: [{ $ref: '#/definitions/asString' }, { $ref: '#/definitions/asObject' }], } as const; +const descriptionPrefixesSuffixes = (name: 'forbiddenPattern' | 'requiredPattern') => + `> This option is deprecated and will be removed in next major release. Use "${name}" instead`; + const schema = { definitions: { asString: { @@ -60,10 +63,24 @@ const schema = { style: { enum: ALLOWED_STYLES }, prefix: { type: 'string' }, suffix: { type: 'string' }, - forbiddenPrefixes: ARRAY_DEFAULT_OPTIONS, - forbiddenSuffixes: ARRAY_DEFAULT_OPTIONS, - requiredPrefixes: ARRAY_DEFAULT_OPTIONS, - requiredSuffixes: ARRAY_DEFAULT_OPTIONS, + forbiddenPattern: ARRAY_DEFAULT_OPTIONS, + requiredPattern: ARRAY_DEFAULT_OPTIONS, + forbiddenPrefixes: { + ...ARRAY_DEFAULT_OPTIONS, + description: descriptionPrefixesSuffixes('forbiddenPattern'), + }, + forbiddenSuffixes: { + ...ARRAY_DEFAULT_OPTIONS, + description: descriptionPrefixesSuffixes('forbiddenPattern'), + }, + requiredPrefixes: { + ...ARRAY_DEFAULT_OPTIONS, + description: descriptionPrefixesSuffixes('requiredPattern'), + }, + requiredSuffixes: { + ...ARRAY_DEFAULT_OPTIONS, + description: descriptionPrefixesSuffixes('requiredPattern'), + }, ignorePattern: { type: 'string', description: 'Option to skip validation of some words, e.g. acronyms', diff --git a/website/content/docs/usage/js.mdx b/website/content/docs/usage/js.mdx index c608d974f17..14340a85b39 100644 --- a/website/content/docs/usage/js.mdx +++ b/website/content/docs/usage/js.mdx @@ -37,7 +37,7 @@ export default [ > Under the hood, the processor extracts schema and operation files from `files: ['**/*.js']` and > treats them as virtual GraphQL documents with `.graphql` extensions. This enables the overrides > you define for `.graphql` files, under `files: ['**/*.graphql']`, to be applied to the definitions -> within your code files[^1]. +> within your code files. --- diff --git a/website/content/rules/alphabetize.mdx b/website/content/rules/alphabetize.mdx index 87ea8c86de2..cae85338b8c 100644 --- a/website/content/rules/alphabetize.mdx +++ b/website/content/rules/alphabetize.mdx @@ -180,5 +180,5 @@ Additional restrictions: ## Resources -- [Rule source](https://github.com/B2o5T/graphql-eslint/tree/master/packages/plugin/src/rules/alphabetize.ts) -- [Test source](https://github.com/B2o5T/graphql-eslint/tree/master/packages/plugin/__tests__/alphabetize.spec.ts) +- [Rule source](https://github.com/dimaMachina/graphql-eslint/tree/master/packages/plugin/src/rules/alphabetize.ts) +- [Test source](https://github.com/dimaMachina/graphql-eslint/tree/master/packages/plugin/__tests__/alphabetize.spec.ts) diff --git a/website/content/rules/description-style.mdx b/website/content/rules/description-style.mdx index 57573d08029..60d7ebf2c06 100644 --- a/website/content/rules/description-style.mdx +++ b/website/content/rules/description-style.mdx @@ -58,5 +58,5 @@ Default: `"block"` ## Resources -- [Rule source](https://github.com/B2o5T/graphql-eslint/tree/master/packages/plugin/src/rules/description-style.ts) -- [Test source](https://github.com/B2o5T/graphql-eslint/tree/master/packages/plugin/__tests__/description-style.spec.ts) +- [Rule source](https://github.com/dimaMachina/graphql-eslint/tree/master/packages/plugin/src/rules/description-style.ts) +- [Test source](https://github.com/dimaMachina/graphql-eslint/tree/master/packages/plugin/__tests__/description-style.spec.ts) diff --git a/website/content/rules/input-name.mdx b/website/content/rules/input-name.mdx index c42fdf1caf3..d680be83379 100644 --- a/website/content/rules/input-name.mdx +++ b/website/content/rules/input-name.mdx @@ -83,5 +83,5 @@ Default: `true` ## Resources -- [Rule source](https://github.com/B2o5T/graphql-eslint/tree/master/packages/plugin/src/rules/input-name.ts) -- [Test source](https://github.com/B2o5T/graphql-eslint/tree/master/packages/plugin/__tests__/input-name.spec.ts) +- [Rule source](https://github.com/dimaMachina/graphql-eslint/tree/master/packages/plugin/src/rules/input-name.ts) +- [Test source](https://github.com/dimaMachina/graphql-eslint/tree/master/packages/plugin/__tests__/input-name.spec.ts) diff --git a/website/content/rules/lone-executable-definition.mdx b/website/content/rules/lone-executable-definition.mdx index 7bc00983809..344f098bcc7 100644 --- a/website/content/rules/lone-executable-definition.mdx +++ b/website/content/rules/lone-executable-definition.mdx @@ -61,5 +61,5 @@ Additional restrictions: ## Resources -- [Rule source](https://github.com/B2o5T/graphql-eslint/tree/master/packages/plugin/src/rules/lone-executable-definition.ts) -- [Test source](https://github.com/B2o5T/graphql-eslint/tree/master/packages/plugin/__tests__/lone-executable-definition.spec.ts) +- [Rule source](https://github.com/dimaMachina/graphql-eslint/tree/master/packages/plugin/src/rules/lone-executable-definition.ts) +- [Test source](https://github.com/dimaMachina/graphql-eslint/tree/master/packages/plugin/__tests__/lone-executable-definition.spec.ts) diff --git a/website/content/rules/match-document-filename.mdx b/website/content/rules/match-document-filename.mdx index b1c12f4c4ac..b5d0df00537 100644 --- a/website/content/rules/match-document-filename.mdx +++ b/website/content/rules/match-document-filename.mdx @@ -182,5 +182,5 @@ This element must be one of the following enum values: ## Resources -- [Rule source](https://github.com/B2o5T/graphql-eslint/tree/master/packages/plugin/src/rules/match-document-filename.ts) -- [Test source](https://github.com/B2o5T/graphql-eslint/tree/master/packages/plugin/__tests__/match-document-filename.spec.ts) +- [Rule source](https://github.com/dimaMachina/graphql-eslint/tree/master/packages/plugin/src/rules/match-document-filename.ts) +- [Test source](https://github.com/dimaMachina/graphql-eslint/tree/master/packages/plugin/__tests__/match-document-filename.spec.ts) diff --git a/website/content/rules/no-anonymous-operations.mdx b/website/content/rules/no-anonymous-operations.mdx index fc8494ad7ca..9225096ac5c 100644 --- a/website/content/rules/no-anonymous-operations.mdx +++ b/website/content/rules/no-anonymous-operations.mdx @@ -45,5 +45,5 @@ query user { ## Resources -- [Rule source](https://github.com/B2o5T/graphql-eslint/tree/master/packages/plugin/src/rules/no-anonymous-operations.ts) -- [Test source](https://github.com/B2o5T/graphql-eslint/tree/master/packages/plugin/__tests__/no-anonymous-operations.spec.ts) +- [Rule source](https://github.com/dimaMachina/graphql-eslint/tree/master/packages/plugin/src/rules/no-anonymous-operations.ts) +- [Test source](https://github.com/dimaMachina/graphql-eslint/tree/master/packages/plugin/__tests__/no-anonymous-operations.spec.ts) diff --git a/website/content/rules/no-deprecated.mdx b/website/content/rules/no-deprecated.mdx index 7a88388bbd5..759103f0f81 100644 --- a/website/content/rules/no-deprecated.mdx +++ b/website/content/rules/no-deprecated.mdx @@ -89,5 +89,5 @@ query user { ## Resources -- [Rule source](https://github.com/B2o5T/graphql-eslint/tree/master/packages/plugin/src/rules/no-deprecated.ts) -- [Test source](https://github.com/B2o5T/graphql-eslint/tree/master/packages/plugin/__tests__/no-deprecated.spec.ts) +- [Rule source](https://github.com/dimaMachina/graphql-eslint/tree/master/packages/plugin/src/rules/no-deprecated.ts) +- [Test source](https://github.com/dimaMachina/graphql-eslint/tree/master/packages/plugin/__tests__/no-deprecated.spec.ts) diff --git a/website/content/rules/no-duplicate-fields.mdx b/website/content/rules/no-duplicate-fields.mdx index 6eed8cd92f3..1dd9f8e1b99 100644 --- a/website/content/rules/no-duplicate-fields.mdx +++ b/website/content/rules/no-duplicate-fields.mdx @@ -71,5 +71,5 @@ query ( ## Resources -- [Rule source](https://github.com/B2o5T/graphql-eslint/tree/master/packages/plugin/src/rules/no-duplicate-fields.ts) -- [Test source](https://github.com/B2o5T/graphql-eslint/tree/master/packages/plugin/__tests__/no-duplicate-fields.spec.ts) +- [Rule source](https://github.com/dimaMachina/graphql-eslint/tree/master/packages/plugin/src/rules/no-duplicate-fields.ts) +- [Test source](https://github.com/dimaMachina/graphql-eslint/tree/master/packages/plugin/__tests__/no-duplicate-fields.spec.ts) diff --git a/website/content/rules/no-hashtag-description.mdx b/website/content/rules/no-hashtag-description.mdx index d0c3474bd6b..8ea8a3f5ef9 100644 --- a/website/content/rules/no-hashtag-description.mdx +++ b/website/content/rules/no-hashtag-description.mdx @@ -63,5 +63,5 @@ type User { ## Resources -- [Rule source](https://github.com/B2o5T/graphql-eslint/tree/master/packages/plugin/src/rules/no-hashtag-description.ts) -- [Test source](https://github.com/B2o5T/graphql-eslint/tree/master/packages/plugin/__tests__/no-hashtag-description.spec.ts) +- [Rule source](https://github.com/dimaMachina/graphql-eslint/tree/master/packages/plugin/src/rules/no-hashtag-description.ts) +- [Test source](https://github.com/dimaMachina/graphql-eslint/tree/master/packages/plugin/__tests__/no-hashtag-description.spec.ts) diff --git a/website/content/rules/no-one-place-fragments.mdx b/website/content/rules/no-one-place-fragments.mdx index a119a6b2308..6086f0f1904 100644 --- a/website/content/rules/no-one-place-fragments.mdx +++ b/website/content/rules/no-one-place-fragments.mdx @@ -52,5 +52,5 @@ fragment UserFields on User { ## Resources -- [Rule source](https://github.com/B2o5T/graphql-eslint/tree/master/packages/plugin/src/rules/no-one-place-fragments.ts) -- [Test source](https://github.com/B2o5T/graphql-eslint/tree/master/packages/plugin/__tests__/no-one-place-fragments.spec.ts) +- [Rule source](https://github.com/dimaMachina/graphql-eslint/tree/master/packages/plugin/src/rules/no-one-place-fragments.ts) +- [Test source](https://github.com/dimaMachina/graphql-eslint/tree/master/packages/plugin/__tests__/no-one-place-fragments.spec.ts) diff --git a/website/content/rules/no-root-type.mdx b/website/content/rules/no-root-type.mdx index 6cc46449556..764e43786ac 100644 --- a/website/content/rules/no-root-type.mdx +++ b/website/content/rules/no-root-type.mdx @@ -56,5 +56,5 @@ Additional restrictions: ## Resources -- [Rule source](https://github.com/B2o5T/graphql-eslint/tree/master/packages/plugin/src/rules/no-root-type.ts) -- [Test source](https://github.com/B2o5T/graphql-eslint/tree/master/packages/plugin/__tests__/no-root-type.spec.ts) +- [Rule source](https://github.com/dimaMachina/graphql-eslint/tree/master/packages/plugin/src/rules/no-root-type.ts) +- [Test source](https://github.com/dimaMachina/graphql-eslint/tree/master/packages/plugin/__tests__/no-root-type.spec.ts) diff --git a/website/content/rules/no-scalar-result-type-on-mutation.mdx b/website/content/rules/no-scalar-result-type-on-mutation.mdx index 4c7725b4f7a..8da736402cc 100644 --- a/website/content/rules/no-scalar-result-type-on-mutation.mdx +++ b/website/content/rules/no-scalar-result-type-on-mutation.mdx @@ -40,5 +40,5 @@ type Mutation { ## Resources -- [Rule source](https://github.com/B2o5T/graphql-eslint/tree/master/packages/plugin/src/rules/no-scalar-result-type-on-mutation.ts) -- [Test source](https://github.com/B2o5T/graphql-eslint/tree/master/packages/plugin/__tests__/no-scalar-result-type-on-mutation.spec.ts) +- [Rule source](https://github.com/dimaMachina/graphql-eslint/tree/master/packages/plugin/src/rules/no-scalar-result-type-on-mutation.ts) +- [Test source](https://github.com/dimaMachina/graphql-eslint/tree/master/packages/plugin/__tests__/no-scalar-result-type-on-mutation.spec.ts) diff --git a/website/content/rules/no-typename-prefix.mdx b/website/content/rules/no-typename-prefix.mdx index dcada3c9bf7..37cd748e525 100644 --- a/website/content/rules/no-typename-prefix.mdx +++ b/website/content/rules/no-typename-prefix.mdx @@ -44,5 +44,5 @@ type User { ## Resources -- [Rule source](https://github.com/B2o5T/graphql-eslint/tree/master/packages/plugin/src/rules/no-typename-prefix.ts) -- [Test source](https://github.com/B2o5T/graphql-eslint/tree/master/packages/plugin/__tests__/no-typename-prefix.spec.ts) +- [Rule source](https://github.com/dimaMachina/graphql-eslint/tree/master/packages/plugin/src/rules/no-typename-prefix.ts) +- [Test source](https://github.com/dimaMachina/graphql-eslint/tree/master/packages/plugin/__tests__/no-typename-prefix.spec.ts) diff --git a/website/content/rules/no-unreachable-types.mdx b/website/content/rules/no-unreachable-types.mdx index aba5bf3e28d..faaf0396cb7 100644 --- a/website/content/rules/no-unreachable-types.mdx +++ b/website/content/rules/no-unreachable-types.mdx @@ -53,5 +53,5 @@ type Query { ## Resources -- [Rule source](https://github.com/B2o5T/graphql-eslint/tree/master/packages/plugin/src/rules/no-unreachable-types.ts) -- [Test source](https://github.com/B2o5T/graphql-eslint/tree/master/packages/plugin/__tests__/no-unreachable-types.spec.ts) +- [Rule source](https://github.com/dimaMachina/graphql-eslint/tree/master/packages/plugin/src/rules/no-unreachable-types.ts) +- [Test source](https://github.com/dimaMachina/graphql-eslint/tree/master/packages/plugin/__tests__/no-unreachable-types.spec.ts) diff --git a/website/content/rules/no-unused-fields.mdx b/website/content/rules/no-unused-fields.mdx index 472efac05a0..7b386958e50 100644 --- a/website/content/rules/no-unused-fields.mdx +++ b/website/content/rules/no-unused-fields.mdx @@ -159,5 +159,5 @@ Additional restrictions: ## Resources -- [Rule source](https://github.com/B2o5T/graphql-eslint/tree/master/packages/plugin/src/rules/no-unused-fields.ts) -- [Test source](https://github.com/B2o5T/graphql-eslint/tree/master/packages/plugin/__tests__/no-unused-fields.spec.ts) +- [Rule source](https://github.com/dimaMachina/graphql-eslint/tree/master/packages/plugin/src/rules/no-unused-fields.ts) +- [Test source](https://github.com/dimaMachina/graphql-eslint/tree/master/packages/plugin/__tests__/no-unused-fields.spec.ts) diff --git a/website/content/rules/relay-arguments.mdx b/website/content/rules/relay-arguments.mdx index 480d9384913..09c8ec32f26 100644 --- a/website/content/rules/relay-arguments.mdx +++ b/website/content/rules/relay-arguments.mdx @@ -60,5 +60,5 @@ Default: `true` ## Resources -- [Rule source](https://github.com/B2o5T/graphql-eslint/tree/master/packages/plugin/src/rules/relay-arguments.ts) -- [Test source](https://github.com/B2o5T/graphql-eslint/tree/master/packages/plugin/__tests__/relay-arguments.spec.ts) +- [Rule source](https://github.com/dimaMachina/graphql-eslint/tree/master/packages/plugin/src/rules/relay-arguments.ts) +- [Test source](https://github.com/dimaMachina/graphql-eslint/tree/master/packages/plugin/__tests__/relay-arguments.spec.ts) diff --git a/website/content/rules/relay-connection-types.mdx b/website/content/rules/relay-connection-types.mdx index 7a1c680b46f..23c984a6585 100644 --- a/website/content/rules/relay-connection-types.mdx +++ b/website/content/rules/relay-connection-types.mdx @@ -44,5 +44,5 @@ type UserConnection { ## Resources -- [Rule source](https://github.com/B2o5T/graphql-eslint/tree/master/packages/plugin/src/rules/relay-connection-types.ts) -- [Test source](https://github.com/B2o5T/graphql-eslint/tree/master/packages/plugin/__tests__/relay-connection-types.spec.ts) +- [Rule source](https://github.com/dimaMachina/graphql-eslint/tree/master/packages/plugin/src/rules/relay-connection-types.ts) +- [Test source](https://github.com/dimaMachina/graphql-eslint/tree/master/packages/plugin/__tests__/relay-connection-types.spec.ts) diff --git a/website/content/rules/relay-edge-types.mdx b/website/content/rules/relay-edge-types.mdx index d063c5e48fd..554e502c0aa 100644 --- a/website/content/rules/relay-edge-types.mdx +++ b/website/content/rules/relay-edge-types.mdx @@ -61,5 +61,5 @@ Default: `true` ## Resources -- [Rule source](https://github.com/B2o5T/graphql-eslint/tree/master/packages/plugin/src/rules/relay-edge-types.ts) -- [Test source](https://github.com/B2o5T/graphql-eslint/tree/master/packages/plugin/__tests__/relay-edge-types.spec.ts) +- [Rule source](https://github.com/dimaMachina/graphql-eslint/tree/master/packages/plugin/src/rules/relay-edge-types.ts) +- [Test source](https://github.com/dimaMachina/graphql-eslint/tree/master/packages/plugin/__tests__/relay-edge-types.spec.ts) diff --git a/website/content/rules/relay-page-info.mdx b/website/content/rules/relay-page-info.mdx index c7a7686db96..acd709ae50b 100644 --- a/website/content/rules/relay-page-info.mdx +++ b/website/content/rules/relay-page-info.mdx @@ -35,5 +35,5 @@ type PageInfo { ## Resources -- [Rule source](https://github.com/B2o5T/graphql-eslint/tree/master/packages/plugin/src/rules/relay-page-info.ts) -- [Test source](https://github.com/B2o5T/graphql-eslint/tree/master/packages/plugin/__tests__/relay-page-info.spec.ts) +- [Rule source](https://github.com/dimaMachina/graphql-eslint/tree/master/packages/plugin/src/rules/relay-page-info.ts) +- [Test source](https://github.com/dimaMachina/graphql-eslint/tree/master/packages/plugin/__tests__/relay-page-info.spec.ts) diff --git a/website/content/rules/require-deprecation-date.mdx b/website/content/rules/require-deprecation-date.mdx index b6c2ef3923f..dd7e121600a 100644 --- a/website/content/rules/require-deprecation-date.mdx +++ b/website/content/rules/require-deprecation-date.mdx @@ -61,5 +61,5 @@ The schema defines the following properties: ## Resources -- [Rule source](https://github.com/B2o5T/graphql-eslint/tree/master/packages/plugin/src/rules/require-deprecation-date.ts) -- [Test source](https://github.com/B2o5T/graphql-eslint/tree/master/packages/plugin/__tests__/require-deprecation-date.spec.ts) +- [Rule source](https://github.com/dimaMachina/graphql-eslint/tree/master/packages/plugin/src/rules/require-deprecation-date.ts) +- [Test source](https://github.com/dimaMachina/graphql-eslint/tree/master/packages/plugin/__tests__/require-deprecation-date.spec.ts) diff --git a/website/content/rules/require-deprecation-reason.mdx b/website/content/rules/require-deprecation-reason.mdx index da498a42524..12e82444023 100644 --- a/website/content/rules/require-deprecation-reason.mdx +++ b/website/content/rules/require-deprecation-reason.mdx @@ -50,5 +50,5 @@ type MyType { ## Resources -- [Rule source](https://github.com/B2o5T/graphql-eslint/tree/master/packages/plugin/src/rules/require-deprecation-reason.ts) -- [Test source](https://github.com/B2o5T/graphql-eslint/tree/master/packages/plugin/__tests__/require-deprecation-reason.spec.ts) +- [Rule source](https://github.com/dimaMachina/graphql-eslint/tree/master/packages/plugin/src/rules/require-deprecation-reason.ts) +- [Test source](https://github.com/dimaMachina/graphql-eslint/tree/master/packages/plugin/__tests__/require-deprecation-reason.spec.ts) diff --git a/website/content/rules/require-description.mdx b/website/content/rules/require-description.mdx index 70d65778547..aeb29a45aad 100644 --- a/website/content/rules/require-description.mdx +++ b/website/content/rules/require-description.mdx @@ -148,5 +148,5 @@ Read more about this kind on ## Resources -- [Rule source](https://github.com/B2o5T/graphql-eslint/tree/master/packages/plugin/src/rules/require-description.ts) -- [Test source](https://github.com/B2o5T/graphql-eslint/tree/master/packages/plugin/__tests__/require-description.spec.ts) +- [Rule source](https://github.com/dimaMachina/graphql-eslint/tree/master/packages/plugin/src/rules/require-description.ts) +- [Test source](https://github.com/dimaMachina/graphql-eslint/tree/master/packages/plugin/__tests__/require-description.spec.ts) diff --git a/website/content/rules/require-field-of-type-query-in-mutation-result.mdx b/website/content/rules/require-field-of-type-query-in-mutation-result.mdx index b7e24493887..e6ce0ddd5e3 100644 --- a/website/content/rules/require-field-of-type-query-in-mutation-result.mdx +++ b/website/content/rules/require-field-of-type-query-in-mutation-result.mdx @@ -53,5 +53,5 @@ type Mutation { ## Resources -- [Rule source](https://github.com/B2o5T/graphql-eslint/tree/master/packages/plugin/src/rules/require-field-of-type-query-in-mutation-result.ts) -- [Test source](https://github.com/B2o5T/graphql-eslint/tree/master/packages/plugin/__tests__/require-field-of-type-query-in-mutation-result.spec.ts) +- [Rule source](https://github.com/dimaMachina/graphql-eslint/tree/master/packages/plugin/src/rules/require-field-of-type-query-in-mutation-result.ts) +- [Test source](https://github.com/dimaMachina/graphql-eslint/tree/master/packages/plugin/__tests__/require-field-of-type-query-in-mutation-result.spec.ts) diff --git a/website/content/rules/require-import-fragment.mdx b/website/content/rules/require-import-fragment.mdx index afd00181cb2..e7dd11740a3 100644 --- a/website/content/rules/require-import-fragment.mdx +++ b/website/content/rules/require-import-fragment.mdx @@ -71,5 +71,5 @@ query { ## Resources -- [Rule source](https://github.com/B2o5T/graphql-eslint/tree/master/packages/plugin/src/rules/require-import-fragment.ts) -- [Test source](https://github.com/B2o5T/graphql-eslint/tree/master/packages/plugin/__tests__/require-import-fragment.spec.ts) +- [Rule source](https://github.com/dimaMachina/graphql-eslint/tree/master/packages/plugin/src/rules/require-import-fragment.ts) +- [Test source](https://github.com/dimaMachina/graphql-eslint/tree/master/packages/plugin/__tests__/require-import-fragment.spec.ts) diff --git a/website/content/rules/require-nullable-fields-with-oneof.mdx b/website/content/rules/require-nullable-fields-with-oneof.mdx index 906f08c211c..69d02b58e83 100644 --- a/website/content/rules/require-nullable-fields-with-oneof.mdx +++ b/website/content/rules/require-nullable-fields-with-oneof.mdx @@ -39,5 +39,5 @@ input Input @oneOf { ## Resources -- [Rule source](https://github.com/B2o5T/graphql-eslint/tree/master/packages/plugin/src/rules/require-nullable-fields-with-oneof.ts) -- [Test source](https://github.com/B2o5T/graphql-eslint/tree/master/packages/plugin/__tests__/require-nullable-fields-with-oneof.spec.ts) +- [Rule source](https://github.com/dimaMachina/graphql-eslint/tree/master/packages/plugin/src/rules/require-nullable-fields-with-oneof.ts) +- [Test source](https://github.com/dimaMachina/graphql-eslint/tree/master/packages/plugin/__tests__/require-nullable-fields-with-oneof.spec.ts) diff --git a/website/content/rules/require-nullable-result-in-root.mdx b/website/content/rules/require-nullable-result-in-root.mdx index 5fed6be84ad..688dca13b39 100644 --- a/website/content/rules/require-nullable-result-in-root.mdx +++ b/website/content/rules/require-nullable-result-in-root.mdx @@ -42,5 +42,5 @@ type Query { ## Resources -- [Rule source](https://github.com/B2o5T/graphql-eslint/tree/master/packages/plugin/src/rules/require-nullable-result-in-root.ts) -- [Test source](https://github.com/B2o5T/graphql-eslint/tree/master/packages/plugin/__tests__/require-nullable-result-in-root.spec.ts) +- [Rule source](https://github.com/dimaMachina/graphql-eslint/tree/master/packages/plugin/src/rules/require-nullable-result-in-root.ts) +- [Test source](https://github.com/dimaMachina/graphql-eslint/tree/master/packages/plugin/__tests__/require-nullable-result-in-root.spec.ts) diff --git a/website/content/rules/require-selections.mdx b/website/content/rules/require-selections.mdx index ceb780fabbb..26ea95a5c94 100644 --- a/website/content/rules/require-selections.mdx +++ b/website/content/rules/require-selections.mdx @@ -98,5 +98,5 @@ conflict with another Relay rule: `relay/unused-fields`. ## Resources -- [Rule source](https://github.com/B2o5T/graphql-eslint/tree/master/packages/plugin/src/rules/require-selections.ts) -- [Test source](https://github.com/B2o5T/graphql-eslint/tree/master/packages/plugin/__tests__/require-selections.spec.ts) +- [Rule source](https://github.com/dimaMachina/graphql-eslint/tree/master/packages/plugin/src/rules/require-selections.ts) +- [Test source](https://github.com/dimaMachina/graphql-eslint/tree/master/packages/plugin/__tests__/require-selections.spec.ts) diff --git a/website/content/rules/require-type-pattern-with-oneof.mdx b/website/content/rules/require-type-pattern-with-oneof.mdx index 3b31c26d82f..30e28c6c0ff 100644 --- a/website/content/rules/require-type-pattern-with-oneof.mdx +++ b/website/content/rules/require-type-pattern-with-oneof.mdx @@ -40,5 +40,5 @@ type DoSomethingSuccess { ## Resources -- [Rule source](https://github.com/B2o5T/graphql-eslint/tree/master/packages/plugin/src/rules/require-type-pattern-with-oneof.ts) -- [Test source](https://github.com/B2o5T/graphql-eslint/tree/master/packages/plugin/__tests__/require-type-pattern-with-oneof.spec.ts) +- [Rule source](https://github.com/dimaMachina/graphql-eslint/tree/master/packages/plugin/src/rules/require-type-pattern-with-oneof.ts) +- [Test source](https://github.com/dimaMachina/graphql-eslint/tree/master/packages/plugin/__tests__/require-type-pattern-with-oneof.spec.ts) diff --git a/website/content/rules/selection-set-depth.mdx b/website/content/rules/selection-set-depth.mdx index af52b220f63..30d68058d2d 100644 --- a/website/content/rules/selection-set-depth.mdx +++ b/website/content/rules/selection-set-depth.mdx @@ -89,5 +89,5 @@ Additional restrictions: ## Resources -- [Rule source](https://github.com/B2o5T/graphql-eslint/tree/master/packages/plugin/src/rules/selection-set-depth.ts) -- [Test source](https://github.com/B2o5T/graphql-eslint/tree/master/packages/plugin/__tests__/selection-set-depth.spec.ts) +- [Rule source](https://github.com/dimaMachina/graphql-eslint/tree/master/packages/plugin/src/rules/selection-set-depth.ts) +- [Test source](https://github.com/dimaMachina/graphql-eslint/tree/master/packages/plugin/__tests__/selection-set-depth.spec.ts) diff --git a/website/content/rules/strict-id-in-types.mdx b/website/content/rules/strict-id-in-types.mdx index 57328c68c8a..cff446c9a88 100644 --- a/website/content/rules/strict-id-in-types.mdx +++ b/website/content/rules/strict-id-in-types.mdx @@ -131,5 +131,5 @@ Additional restrictions: ## Resources -- [Rule source](https://github.com/B2o5T/graphql-eslint/tree/master/packages/plugin/src/rules/strict-id-in-types.ts) -- [Test source](https://github.com/B2o5T/graphql-eslint/tree/master/packages/plugin/__tests__/strict-id-in-types.spec.ts) +- [Rule source](https://github.com/dimaMachina/graphql-eslint/tree/master/packages/plugin/src/rules/strict-id-in-types.ts) +- [Test source](https://github.com/dimaMachina/graphql-eslint/tree/master/packages/plugin/__tests__/strict-id-in-types.spec.ts) diff --git a/website/content/rules/unique-enum-value-names.mdx b/website/content/rules/unique-enum-value-names.mdx index 9d1b49e8f2d..2f3c712c472 100644 --- a/website/content/rules/unique-enum-value-names.mdx +++ b/website/content/rules/unique-enum-value-names.mdx @@ -49,5 +49,5 @@ enum MyEnum { ## Resources -- [Rule source](https://github.com/B2o5T/graphql-eslint/tree/master/packages/plugin/src/rules/unique-enum-value-names.ts) -- [Test source](https://github.com/B2o5T/graphql-eslint/tree/master/packages/plugin/__tests__/unique-enum-value-names.spec.ts) +- [Rule source](https://github.com/dimaMachina/graphql-eslint/tree/master/packages/plugin/src/rules/unique-enum-value-names.ts) +- [Test source](https://github.com/dimaMachina/graphql-eslint/tree/master/packages/plugin/__tests__/unique-enum-value-names.spec.ts) diff --git a/website/content/rules/unique-fragment-name.mdx b/website/content/rules/unique-fragment-name.mdx index 0bc3ac3eaff..04d5a7620b7 100644 --- a/website/content/rules/unique-fragment-name.mdx +++ b/website/content/rules/unique-fragment-name.mdx @@ -56,5 +56,5 @@ fragment UserFields on User { ## Resources -- [Rule source](https://github.com/B2o5T/graphql-eslint/tree/master/packages/plugin/src/rules/unique-fragment-name.ts) -- [Test source](https://github.com/B2o5T/graphql-eslint/tree/master/packages/plugin/__tests__/unique-fragment-name.spec.ts) +- [Rule source](https://github.com/dimaMachina/graphql-eslint/tree/master/packages/plugin/src/rules/unique-fragment-name.ts) +- [Test source](https://github.com/dimaMachina/graphql-eslint/tree/master/packages/plugin/__tests__/unique-fragment-name.spec.ts) diff --git a/website/content/rules/unique-operation-name.mdx b/website/content/rules/unique-operation-name.mdx index 4999ff0ed31..4ef2c02e6a4 100644 --- a/website/content/rules/unique-operation-name.mdx +++ b/website/content/rules/unique-operation-name.mdx @@ -60,5 +60,5 @@ query me { ## Resources -- [Rule source](https://github.com/B2o5T/graphql-eslint/tree/master/packages/plugin/src/rules/unique-operation-name.ts) -- [Test source](https://github.com/B2o5T/graphql-eslint/tree/master/packages/plugin/__tests__/unique-operation-name.spec.ts) +- [Rule source](https://github.com/dimaMachina/graphql-eslint/tree/master/packages/plugin/src/rules/unique-operation-name.ts) +- [Test source](https://github.com/dimaMachina/graphql-eslint/tree/master/packages/plugin/__tests__/unique-operation-name.spec.ts) From e77910804d84dbc6dd761332c6c81ad691b2e402 Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Fri, 29 Nov 2024 03:04:44 +0700 Subject: [PATCH 02/14] aa --- .../src/rules/naming-convention/index.ts | 4 +- website/content/rules/naming-convention.mdx | 42 ++++++++++++++++++- 2 files changed, 43 insertions(+), 3 deletions(-) diff --git a/packages/plugin/src/rules/naming-convention/index.ts b/packages/plugin/src/rules/naming-convention/index.ts index 657899f84dd..e6eaebab1c1 100644 --- a/packages/plugin/src/rules/naming-convention/index.ts +++ b/packages/plugin/src/rules/naming-convention/index.ts @@ -48,7 +48,9 @@ const schemaOption = { } as const; const descriptionPrefixesSuffixes = (name: 'forbiddenPattern' | 'requiredPattern') => - `> This option is deprecated and will be removed in next major release. Use "${name}" instead`; + `> [!WARNING] +> +> This option is deprecated and will be removed in the next major release. Use \`${name}\` instead`; const schema = { definitions: { diff --git a/website/content/rules/naming-convention.mdx b/website/content/rules/naming-convention.mdx index ed9bef931f5..1d85811af18 100644 --- a/website/content/rules/naming-convention.mdx +++ b/website/content/rules/naming-convention.mdx @@ -321,8 +321,31 @@ This element must be one of the following enum values: ### `suffix` (string) +### `forbiddenPattern` (array) + +The object is an array with all elements of the type `string`. + +Additional restrictions: + +- Minimum items: `1` +- Unique items: `true` + +### `requiredPattern` (array) + +The object is an array with all elements of the type `string`. + +Additional restrictions: + +- Minimum items: `1` +- Unique items: `true` + ### `forbiddenPrefixes` (array) +> [!WARNING] +> +> This option is deprecated and will be removed in the next major release. Use `forbiddenPattern` +> instead + The object is an array with all elements of the type `string`. Additional restrictions: @@ -332,6 +355,11 @@ Additional restrictions: ### `forbiddenSuffixes` (array) +> [!WARNING] +> +> This option is deprecated and will be removed in the next major release. Use `forbiddenPattern` +> instead + The object is an array with all elements of the type `string`. Additional restrictions: @@ -341,6 +369,11 @@ Additional restrictions: ### `requiredPrefixes` (array) +> [!WARNING] +> +> This option is deprecated and will be removed in the next major release. Use `requiredPattern` +> instead + The object is an array with all elements of the type `string`. Additional restrictions: @@ -350,6 +383,11 @@ Additional restrictions: ### `requiredSuffixes` (array) +> [!WARNING] +> +> This option is deprecated and will be removed in the next major release. Use `requiredPattern` +> instead + The object is an array with all elements of the type `string`. Additional restrictions: @@ -363,5 +401,5 @@ Option to skip validation of some words, e.g. acronyms ## Resources -- [Rule source](https://github.com/B2o5T/graphql-eslint/tree/master/packages/plugin/src/rules/naming-convention.ts) -- [Test source](https://github.com/B2o5T/graphql-eslint/tree/master/packages/plugin/__tests__/naming-convention.spec.ts) +- [Rule source](https://github.com/dimaMachina/graphql-eslint/tree/master/packages/plugin/src/rules/naming-convention.ts) +- [Test source](https://github.com/dimaMachina/graphql-eslint/tree/master/packages/plugin/__tests__/naming-convention.spec.ts) From ad55b6158cb25a38da61cde5a5b94805d8ee493a Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Fri, 29 Nov 2024 03:21:17 +0700 Subject: [PATCH 03/14] aa --- .changeset/happy-bottles-warn.md | 3 ++- .../src/rules/naming-convention/index.ts | 21 +++++++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/.changeset/happy-bottles-warn.md b/.changeset/happy-bottles-warn.md index 1dbe307d217..e1f077b8bd8 100644 --- a/.changeset/happy-bottles-warn.md +++ b/.changeset/happy-bottles-warn.md @@ -2,4 +2,5 @@ '@graphql-eslint/eslint-plugin': minor --- -introduce `forbiddenPattern` and `requiredPattern` options for `naming-convention` rule and deprecate `forbiddenPrefixes`, `forbiddenSuffixes` and `requiredPrefixes` and `requiredSuffixes` +introduce `forbiddenPattern` and `requiredPattern` options for `naming-convention` rule and +deprecate `forbiddenPrefixes`, `forbiddenSuffixes` and `requiredPrefixes` and `requiredSuffixes` diff --git a/packages/plugin/src/rules/naming-convention/index.ts b/packages/plugin/src/rules/naming-convention/index.ts index e6eaebab1c1..72431fbd635 100644 --- a/packages/plugin/src/rules/naming-convention/index.ts +++ b/packages/plugin/src/rules/naming-convention/index.ts @@ -5,6 +5,7 @@ import { GraphQLESLintRule, GraphQLESLintRuleListener, ValueOf } from '../../typ import { ARRAY_DEFAULT_OPTIONS, convertCase, + displayNodeName, englishJoinWords, truthy, TYPES_KINDS, @@ -137,6 +138,8 @@ type PropertySchema = { style?: AllowedStyle; suffix?: string; prefix?: string; + forbiddenPattern?: string[]; + requiredPattern?: string[]; forbiddenPrefixes?: string[]; forbiddenSuffixes?: string[]; requiredPrefixes?: string[]; @@ -360,8 +363,8 @@ export const rule: GraphQLESLintRule = { ignorePattern, requiredPrefixes, requiredSuffixes, + forbiddenPattern, } = normalisePropertyOption(selector); - const nodeType = KindToDisplayName[n.kind] || n.kind; const nodeName = node.value; const error = getError(); if (error) { @@ -371,7 +374,12 @@ export const rule: GraphQLESLintRule = { const suggestedNames = renameToNames.map( renameToName => leadingUnderscores + renameToName + trailingUnderscores, ); - report(node, `${nodeType} "${nodeName}" should ${errorMessage}`, suggestedNames); + const name = displayNodeName(n); + report( + node, + `${name[0].toUpperCase()}${name.slice(1)} should ${errorMessage}`, + suggestedNames, + ); } function getError(): { @@ -394,6 +402,15 @@ export const rule: GraphQLESLintRule = { renameToNames: [name + suffix], }; } + const forbidden = forbiddenPattern?.find((pattern: string) => + new RegExp(pattern).test(name), + ); + if (forbidden) { + return { + errorMessage: `not contain the forbidden pattern "${forbidden}"`, + renameToNames: [name.replace(new RegExp(forbidden), '')], + }; + } const forbiddenPrefix = forbiddenPrefixes?.find(prefix => name.startsWith(prefix)); if (forbiddenPrefix) { return { From 2e4f0c37c57a8a327eaf1ac4786f6440ad9070ba Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Fri, 29 Nov 2024 03:26:33 +0700 Subject: [PATCH 04/14] aa --- .../src/rules/naming-convention/index.test.ts | 94 +++++++------ .../src/rules/naming-convention/snapshot.md | 133 +++++++++++------- 2 files changed, 134 insertions(+), 93 deletions(-) diff --git a/packages/plugin/src/rules/naming-convention/index.test.ts b/packages/plugin/src/rules/naming-convention/index.test.ts index d7ea9eb403d..b7e8ce6a4ab 100644 --- a/packages/plugin/src/rules/naming-convention/index.test.ts +++ b/packages/plugin/src/rules/naming-convention/index.test.ts @@ -260,48 +260,48 @@ ruleTester.run('naming-convention', rule, { errors: [ { message: - 'Input type "_idOperatorsFilterFindManyUserInput" should be in PascalCase format', + 'Input "_idOperatorsFilterFindManyUserInput" should be in PascalCase format', }, { - message: 'Input type "_idOperatorsFilterFindOneUserInput" should be in PascalCase format', + message: 'Input "_idOperatorsFilterFindOneUserInput" should be in PascalCase format', }, { message: - 'Input type "_idOperatorsFilterRemoveManyUserInput" should be in PascalCase format', + 'Input "_idOperatorsFilterRemoveManyUserInput" should be in PascalCase format', }, { message: - 'Input type "_idOperatorsFilterRemoveOneUserInput" should be in PascalCase format', + 'Input "_idOperatorsFilterRemoveOneUserInput" should be in PascalCase format', }, { message: - 'Input type "_idOperatorsFilterUpdateManyUserInput" should be in PascalCase format', + 'Input "_idOperatorsFilterUpdateManyUserInput" should be in PascalCase format', }, { message: - 'Input type "_idOperatorsFilterUpdateOneUserInput" should be in PascalCase format', + 'Input "_idOperatorsFilterUpdateOneUserInput" should be in PascalCase format', }, - { message: 'Input type "_idOperatorsFilterUserInput" should be in PascalCase format' }, - { message: 'Enumeration value "male" should be in UPPER_CASE format' }, - { message: 'Enumeration value "female" should be in UPPER_CASE format' }, - { message: 'Enumeration value "ladyboy" should be in UPPER_CASE format' }, - { message: 'Enumeration value "basic" should be in UPPER_CASE format' }, - { message: 'Enumeration value "fluent" should be in UPPER_CASE format' }, - { message: 'Enumeration value "native" should be in UPPER_CASE format' }, - { message: 'Input property "OR" should be in camelCase format' }, - { message: 'Input property "AND" should be in camelCase format' }, - { message: 'Input property "OR" should be in camelCase format' }, - { message: 'Input property "AND" should be in camelCase format' }, - { message: 'Input property "OR" should be in camelCase format' }, - { message: 'Input property "AND" should be in camelCase format' }, - { message: 'Input property "OR" should be in camelCase format' }, - { message: 'Input property "AND" should be in camelCase format' }, - { message: 'Input property "OR" should be in camelCase format' }, - { message: 'Input property "AND" should be in camelCase format' }, - { message: 'Input property "OR" should be in camelCase format' }, - { message: 'Input property "AND" should be in camelCase format' }, - { message: 'Input property "OR" should be in camelCase format' }, - { message: 'Input property "AND" should be in camelCase format' }, + { message: 'Input "_idOperatorsFilterUserInput" should be in PascalCase format' }, + { message: 'Enum value "male" should be in UPPER_CASE format' }, + { message: 'Enum value "female" should be in UPPER_CASE format' }, + { message: 'Enum value "ladyboy" should be in UPPER_CASE format' }, + { message: 'Enum value "basic" should be in UPPER_CASE format' }, + { message: 'Enum value "fluent" should be in UPPER_CASE format' }, + { message: 'Enum value "native" should be in UPPER_CASE format' }, + { message: 'Input value "OR" should be in camelCase format' }, + { message: 'Input value "AND" should be in camelCase format' }, + { message: 'Input value "OR" should be in camelCase format' }, + { message: 'Input value "AND" should be in camelCase format' }, + { message: 'Input value "OR" should be in camelCase format' }, + { message: 'Input value "AND" should be in camelCase format' }, + { message: 'Input value "OR" should be in camelCase format' }, + { message: 'Input value "AND" should be in camelCase format' }, + { message: 'Input value "OR" should be in camelCase format' }, + { message: 'Input value "AND" should be in camelCase format' }, + { message: 'Input value "OR" should be in camelCase format' }, + { message: 'Input value "AND" should be in camelCase format' }, + { message: 'Input value "OR" should be in camelCase format' }, + { message: 'Input value "AND" should be in camelCase format' }, ], }, { @@ -313,16 +313,16 @@ ruleTester.run('naming-convention', rule, { }, ], errors: [ - { message: 'Enumerator "B" should be in camelCase format' }, - { message: 'Enumeration value "test" should be in UPPER_CASE format' }, + { message: 'Enum "B" should be in camelCase format' }, + { message: 'Enum value "test" should be in UPPER_CASE format' }, ], }, { code: 'input test { _Value: String }', options: [{ types: 'PascalCase', InputValueDefinition: 'snake_case' }], errors: [ - { message: 'Input type "test" should be in PascalCase format' }, - { message: 'Input property "_Value" should be in snake_case format' }, + { message: 'Input "test" should be in PascalCase format' }, + { message: 'Input value "_Value" should be in snake_case format' }, { message: 'Leading underscores are not allowed' }, ], }, @@ -338,8 +338,8 @@ ruleTester.run('naming-convention', rule, { errors: [ { message: 'Type "TypeOne" should be in camelCase format' }, { message: 'Field "aField" should have "AAA" suffix' }, - { message: 'Enumeration value "VALUE_ONE" should have "ENUM" suffix' }, - { message: 'Enumeration value "VALUE_TWO" should have "ENUM" suffix' }, + { message: 'Enum value "VALUE_ONE" should have "ENUM" suffix' }, + { message: 'Enum value "VALUE_TWO" should have "ENUM" suffix' }, ], }, { @@ -353,8 +353,8 @@ ruleTester.run('naming-convention', rule, { ], errors: [ { message: 'Field "aField" should have "Field" prefix' }, - { message: 'Enumeration value "A_ENUM_VALUE_ONE" should have "ENUM" prefix' }, - { message: 'Enumeration value "VALUE_TWO" should have "ENUM" prefix' }, + { message: 'Enum value "A_ENUM_VALUE_ONE" should have "ENUM" prefix' }, + { message: 'Enum value "VALUE_TWO" should have "ENUM" prefix' }, ], }, { @@ -385,8 +385,8 @@ ruleTester.run('naming-convention', rule, { code: 'query Foo { foo } query getBar { bar }', options: [{ OperationDefinition: { style: 'camelCase', forbiddenPrefixes: ['get'] } }], errors: [ - { message: 'Operation "Foo" should be in camelCase format' }, - { message: 'Operation "getBar" should not have "get" prefix' }, + { message: 'Query "Foo" should be in camelCase format' }, + { message: 'Query "getBar" should not have "get" prefix' }, ], }, { @@ -448,13 +448,13 @@ ruleTester.run('naming-convention', rule, { `, options: (rule.meta.docs!.configOptions as any).operations, errors: [ - { message: 'Operation "TestQuery" should not have "Query" suffix' }, - { message: 'Operation "QueryTest" should not have "Query" prefix' }, - { message: 'Operation "GetQuery" should not have "Get" prefix' }, - { message: 'Operation "TestMutation" should not have "Mutation" suffix' }, - { message: 'Operation "MutationTest" should not have "Mutation" prefix' }, - { message: 'Operation "TestSubscription" should not have "Subscription" suffix' }, - { message: 'Operation "SubscriptionTest" should not have "Subscription" prefix' }, + { message: 'Query "TestQuery" should not have "Query" suffix' }, + { message: 'Query "QueryTest" should not have "Query" prefix' }, + { message: 'Query "GetQuery" should not have "Get" prefix' }, + { message: 'Mutation "TestMutation" should not have "Mutation" suffix' }, + { message: 'Mutation "MutationTest" should not have "Mutation" prefix' }, + { message: 'Subscription "TestSubscription" should not have "Subscription" suffix' }, + { message: 'Subscription "SubscriptionTest" should not have "Subscription" prefix' }, { message: 'Fragment "TestFragment" should not have "Fragment" suffix' }, { message: 'Fragment "FragmentTest" should not have "Fragment" prefix' }, ], @@ -531,5 +531,11 @@ ruleTester.run('naming-convention', rule, { ], errors: 2, }, + { + name: 'forbiddenPattern', + code: 'query queryFoo { foo } query getBar { bar }', + options: [{ OperationDefinition: { forbiddenPattern: ['^get', '^query'] } }], + errors: 2, + }, ], }); diff --git a/packages/plugin/src/rules/naming-convention/snapshot.md b/packages/plugin/src/rules/naming-convention/snapshot.md index efd3190bf74..335ff728eb5 100644 --- a/packages/plugin/src/rules/naming-convention/snapshot.md +++ b/packages/plugin/src/rules/naming-convention/snapshot.md @@ -98,7 +98,7 @@ exports[`naming-convention > invalid > Invalid #5 1`] = ` #### ❌ Error 1/2 > 1 | enum B { test } - | ^ Enumerator "B" should be in camelCase format + | ^ Enum "B" should be in camelCase format #### 💡 Suggestion: Rename to \`b\` @@ -107,7 +107,7 @@ exports[`naming-convention > invalid > Invalid #5 1`] = ` #### ❌ Error 2/2 > 1 | enum B { test } - | ^^^^ Enumeration value "test" should be in UPPER_CASE format + | ^^^^ Enum value "test" should be in UPPER_CASE format #### 💡 Suggestion: Rename to \`TEST\` @@ -129,7 +129,7 @@ exports[`naming-convention > invalid > Invalid #6 1`] = ` #### ❌ Error 1/3 > 1 | input test { _Value: String } - | ^^^^ Input type "test" should be in PascalCase format + | ^^^^ Input "test" should be in PascalCase format #### 💡 Suggestion: Rename to \`Test\` @@ -138,7 +138,7 @@ exports[`naming-convention > invalid > Invalid #6 1`] = ` #### ❌ Error 2/3 > 1 | input test { _Value: String } - | ^^^^^^ Input property "_Value" should be in snake_case format + | ^^^^^^ Input value "_Value" should be in snake_case format #### 💡 Suggestion: Rename to \`_value\` @@ -196,7 +196,7 @@ exports[`naming-convention > invalid > Invalid #7 1`] = ` #### ❌ Error 3/4 > 1 | type TypeOne { aField: String } enum Z { VALUE_ONE VALUE_TWO } - | ^^^^^^^^^ Enumeration value "VALUE_ONE" should have "ENUM" suffix + | ^^^^^^^^^ Enum value "VALUE_ONE" should have "ENUM" suffix #### 💡 Suggestion: Rename to \`VALUE_ONEENUM\` @@ -205,7 +205,7 @@ exports[`naming-convention > invalid > Invalid #7 1`] = ` #### ❌ Error 4/4 > 1 | type TypeOne { aField: String } enum Z { VALUE_ONE VALUE_TWO } - | ^^^^^^^^^ Enumeration value "VALUE_TWO" should have "ENUM" suffix + | ^^^^^^^^^ Enum value "VALUE_TWO" should have "ENUM" suffix #### 💡 Suggestion: Rename to \`VALUE_TWOENUM\` @@ -245,7 +245,7 @@ exports[`naming-convention > invalid > Invalid #8 1`] = ` #### ❌ Error 2/3 > 1 | type One { aField: String } enum Z { A_ENUM_VALUE_ONE VALUE_TWO } - | ^^^^^^^^^^^^^^^^ Enumeration value "A_ENUM_VALUE_ONE" should have "ENUM" prefix + | ^^^^^^^^^^^^^^^^ Enum value "A_ENUM_VALUE_ONE" should have "ENUM" prefix #### 💡 Suggestion: Rename to \`ENUMA_ENUM_VALUE_ONE\` @@ -254,7 +254,7 @@ exports[`naming-convention > invalid > Invalid #8 1`] = ` #### ❌ Error 3/3 > 1 | type One { aField: String } enum Z { A_ENUM_VALUE_ONE VALUE_TWO } - | ^^^^^^^^^ Enumeration value "VALUE_TWO" should have "ENUM" prefix + | ^^^^^^^^^ Enum value "VALUE_TWO" should have "ENUM" prefix #### 💡 Suggestion: Rename to \`ENUMVALUE_TWO\` @@ -359,7 +359,7 @@ exports[`naming-convention > invalid > Invalid #10 1`] = ` #### ❌ Error 1/2 > 1 | query Foo { foo } query getBar { bar } - | ^^^ Operation "Foo" should be in camelCase format + | ^^^ Query "Foo" should be in camelCase format #### 💡 Suggestion: Rename to \`foo\` @@ -368,13 +368,48 @@ exports[`naming-convention > invalid > Invalid #10 1`] = ` #### ❌ Error 2/2 > 1 | query Foo { foo } query getBar { bar } - | ^^^^^^ Operation "getBar" should not have "get" prefix + | ^^^^^^ Query "getBar" should not have "get" prefix #### 💡 Suggestion: Rename to \`Bar\` 1 | query Foo { foo } query Bar { bar } `; +exports[`naming-convention > invalid > forbiddenPattern 1`] = ` +#### ⌨️ Code + + 1 | query queryFoo { foo } query getBar { bar } + +#### ⚙️ Options + + { + "OperationDefinition": { + "forbiddenPattern": [ + "^get", + "^query" + ] + } + } + +#### ❌ Error 1/2 + + > 1 | query queryFoo { foo } query getBar { bar } + | ^^^^^^^^ Query "queryFoo" should not contain the forbidden pattern "^query" + +#### 💡 Suggestion: Rename to \`Foo\` + + 1 | query Foo { foo } query getBar { bar } + +#### ❌ Error 2/2 + + > 1 | query queryFoo { foo } query getBar { bar } + | ^^^^^^ Query "getBar" should not contain the forbidden pattern "^get" + +#### 💡 Suggestion: Rename to \`Bar\` + + 1 | query queryFoo { foo } query Bar { bar } +`; + exports[`naming-convention > invalid > large graphql file 1`] = ` #### ⌨️ Code @@ -1501,189 +1536,189 @@ exports[`naming-convention > invalid > large graphql file 1`] = ` #### ❌ Error 1/27 > 1 | input _idOperatorsFilterFindManyUserInput { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Input type "_idOperatorsFilterFindManyUserInput" should be in PascalCase format + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Input "_idOperatorsFilterFindManyUserInput" should be in PascalCase format 2 | gt: MongoID #### ❌ Error 2/27 10 | > 11 | input _idOperatorsFilterFindOneUserInput { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Input type "_idOperatorsFilterFindOneUserInput" should be in PascalCase format + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Input "_idOperatorsFilterFindOneUserInput" should be in PascalCase format 12 | gt: MongoID #### ❌ Error 3/27 20 | > 21 | input _idOperatorsFilterRemoveManyUserInput { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Input type "_idOperatorsFilterRemoveManyUserInput" should be in PascalCase format + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Input "_idOperatorsFilterRemoveManyUserInput" should be in PascalCase format 22 | gt: MongoID #### ❌ Error 4/27 30 | > 31 | input _idOperatorsFilterRemoveOneUserInput { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Input type "_idOperatorsFilterRemoveOneUserInput" should be in PascalCase format + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Input "_idOperatorsFilterRemoveOneUserInput" should be in PascalCase format 32 | gt: MongoID #### ❌ Error 5/27 40 | > 41 | input _idOperatorsFilterUpdateManyUserInput { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Input type "_idOperatorsFilterUpdateManyUserInput" should be in PascalCase format + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Input "_idOperatorsFilterUpdateManyUserInput" should be in PascalCase format 42 | gt: MongoID #### ❌ Error 6/27 50 | > 51 | input _idOperatorsFilterUpdateOneUserInput { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Input type "_idOperatorsFilterUpdateOneUserInput" should be in PascalCase format + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Input "_idOperatorsFilterUpdateOneUserInput" should be in PascalCase format 52 | gt: MongoID #### ❌ Error 7/27 60 | > 61 | input _idOperatorsFilterUserInput { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Input type "_idOperatorsFilterUserInput" should be in PascalCase format + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Input "_idOperatorsFilterUserInput" should be in PascalCase format 62 | gt: MongoID #### ❌ Error 8/27 207 | enum EnumUserGender { > 208 | male - | ^^^^ Enumeration value "male" should be in UPPER_CASE format + | ^^^^ Enum value "male" should be in UPPER_CASE format 209 | female #### ❌ Error 9/27 208 | male > 209 | female - | ^^^^^^ Enumeration value "female" should be in UPPER_CASE format + | ^^^^^^ Enum value "female" should be in UPPER_CASE format 210 | ladyboy #### ❌ Error 10/27 209 | female > 210 | ladyboy - | ^^^^^^^ Enumeration value "ladyboy" should be in UPPER_CASE format + | ^^^^^^^ Enum value "ladyboy" should be in UPPER_CASE format 211 | } #### ❌ Error 11/27 213 | enum EnumUserLanguagesSkill { > 214 | basic - | ^^^^^ Enumeration value "basic" should be in UPPER_CASE format + | ^^^^^ Enum value "basic" should be in UPPER_CASE format 215 | fluent #### ❌ Error 12/27 214 | basic > 215 | fluent - | ^^^^^^ Enumeration value "fluent" should be in UPPER_CASE format + | ^^^^^^ Enum value "fluent" should be in UPPER_CASE format 216 | native #### ❌ Error 13/27 215 | fluent > 216 | native - | ^^^^^^ Enumeration value "native" should be in UPPER_CASE format + | ^^^^^^ Enum value "native" should be in UPPER_CASE format 217 | } #### ❌ Error 14/27 238 | _operators: OperatorsFilterFindManyUserInput > 239 | OR: [FilterFindManyUserInput!] - | ^^ Input property "OR" should be in camelCase format + | ^^ Input value "OR" should be in camelCase format 240 | AND: [FilterFindManyUserInput!] #### ❌ Error 15/27 239 | OR: [FilterFindManyUserInput!] > 240 | AND: [FilterFindManyUserInput!] - | ^^^ Input property "AND" should be in camelCase format + | ^^^ Input value "AND" should be in camelCase format 241 | #### ❌ Error 16/27 267 | _operators: OperatorsFilterFindOneUserInput > 268 | OR: [FilterFindOneUserInput!] - | ^^ Input property "OR" should be in camelCase format + | ^^ Input value "OR" should be in camelCase format 269 | AND: [FilterFindOneUserInput!] #### ❌ Error 17/27 268 | OR: [FilterFindOneUserInput!] > 269 | AND: [FilterFindOneUserInput!] - | ^^^ Input property "AND" should be in camelCase format + | ^^^ Input value "AND" should be in camelCase format 270 | } #### ❌ Error 18/27 291 | _operators: OperatorsFilterRemoveManyUserInput > 292 | OR: [FilterRemoveManyUserInput!] - | ^^ Input property "OR" should be in camelCase format + | ^^ Input value "OR" should be in camelCase format 293 | AND: [FilterRemoveManyUserInput!] #### ❌ Error 19/27 292 | OR: [FilterRemoveManyUserInput!] > 293 | AND: [FilterRemoveManyUserInput!] - | ^^^ Input property "AND" should be in camelCase format + | ^^^ Input value "AND" should be in camelCase format 294 | } #### ❌ Error 20/27 315 | _operators: OperatorsFilterRemoveOneUserInput > 316 | OR: [FilterRemoveOneUserInput!] - | ^^ Input property "OR" should be in camelCase format + | ^^ Input value "OR" should be in camelCase format 317 | AND: [FilterRemoveOneUserInput!] #### ❌ Error 21/27 316 | OR: [FilterRemoveOneUserInput!] > 317 | AND: [FilterRemoveOneUserInput!] - | ^^^ Input property "AND" should be in camelCase format + | ^^^ Input value "AND" should be in camelCase format 318 | } #### ❌ Error 22/27 339 | _operators: OperatorsFilterUpdateManyUserInput > 340 | OR: [FilterUpdateManyUserInput!] - | ^^ Input property "OR" should be in camelCase format + | ^^ Input value "OR" should be in camelCase format 341 | AND: [FilterUpdateManyUserInput!] #### ❌ Error 23/27 340 | OR: [FilterUpdateManyUserInput!] > 341 | AND: [FilterUpdateManyUserInput!] - | ^^^ Input property "AND" should be in camelCase format + | ^^^ Input value "AND" should be in camelCase format 342 | } #### ❌ Error 24/27 363 | _operators: OperatorsFilterUpdateOneUserInput > 364 | OR: [FilterUpdateOneUserInput!] - | ^^ Input property "OR" should be in camelCase format + | ^^ Input value "OR" should be in camelCase format 365 | AND: [FilterUpdateOneUserInput!] #### ❌ Error 25/27 364 | OR: [FilterUpdateOneUserInput!] > 365 | AND: [FilterUpdateOneUserInput!] - | ^^^ Input property "AND" should be in camelCase format + | ^^^ Input value "AND" should be in camelCase format 366 | } #### ❌ Error 26/27 387 | _operators: OperatorsFilterUserInput > 388 | OR: [FilterUserInput!] - | ^^ Input property "OR" should be in camelCase format + | ^^ Input value "OR" should be in camelCase format 389 | AND: [FilterUserInput!] #### ❌ Error 27/27 388 | OR: [FilterUserInput!] > 389 | AND: [FilterUserInput!] - | ^^^ Input property "AND" should be in camelCase format + | ^^^ Input value "AND" should be in camelCase format 390 | } `; @@ -1736,7 +1771,7 @@ exports[`naming-convention > invalid > operations-recommended config 1`] = ` #### ❌ Error 1/9 > 1 | query TestQuery { test } - | ^^^^^^^^^ Operation "TestQuery" should not have "Query" suffix + | ^^^^^^^^^ Query "TestQuery" should not have "Query" suffix 2 | query QueryTest { test } #### 💡 Suggestion: Rename to \`Test\` @@ -1759,7 +1794,7 @@ exports[`naming-convention > invalid > operations-recommended config 1`] = ` 1 | query TestQuery { test } > 2 | query QueryTest { test } - | ^^^^^^^^^ Operation "QueryTest" should not have "Query" prefix + | ^^^^^^^^^ Query "QueryTest" should not have "Query" prefix 3 | query GetQuery { test } #### 💡 Suggestion: Rename to \`Test\` @@ -1782,7 +1817,7 @@ exports[`naming-convention > invalid > operations-recommended config 1`] = ` 2 | query QueryTest { test } > 3 | query GetQuery { test } - | ^^^^^^^^ Operation "GetQuery" should not have "Get" prefix + | ^^^^^^^^ Query "GetQuery" should not have "Get" prefix 4 | query Test { test(CONTROLLED_BY_SCHEMA: 0) } #### 💡 Suggestion: Rename to \`Query\` @@ -1805,7 +1840,7 @@ exports[`naming-convention > invalid > operations-recommended config 1`] = ` 5 | > 6 | mutation TestMutation { test } - | ^^^^^^^^^^^^ Operation "TestMutation" should not have "Mutation" suffix + | ^^^^^^^^^^^^ Mutation "TestMutation" should not have "Mutation" suffix 7 | mutation MutationTest { test } #### 💡 Suggestion: Rename to \`Test\` @@ -1828,7 +1863,7 @@ exports[`naming-convention > invalid > operations-recommended config 1`] = ` 6 | mutation TestMutation { test } > 7 | mutation MutationTest { test } - | ^^^^^^^^^^^^ Operation "MutationTest" should not have "Mutation" prefix + | ^^^^^^^^^^^^ Mutation "MutationTest" should not have "Mutation" prefix 8 | #### 💡 Suggestion: Rename to \`Test\` @@ -1851,7 +1886,7 @@ exports[`naming-convention > invalid > operations-recommended config 1`] = ` 8 | > 9 | subscription TestSubscription { test } - | ^^^^^^^^^^^^^^^^ Operation "TestSubscription" should not have "Subscription" suffix + | ^^^^^^^^^^^^^^^^ Subscription "TestSubscription" should not have "Subscription" suffix 10 | subscription SubscriptionTest { test } #### 💡 Suggestion: Rename to \`Test\` @@ -1874,7 +1909,7 @@ exports[`naming-convention > invalid > operations-recommended config 1`] = ` 9 | subscription TestSubscription { test } > 10 | subscription SubscriptionTest { test } - | ^^^^^^^^^^^^^^^^ Operation "SubscriptionTest" should not have "Subscription" prefix + | ^^^^^^^^^^^^^^^^ Subscription "SubscriptionTest" should not have "Subscription" prefix 11 | #### 💡 Suggestion: Rename to \`Test\` @@ -2349,7 +2384,7 @@ exports[`naming-convention > invalid > schema-recommended config 1`] = ` 16 | > 17 | enum TestEnum - | ^^^^^^^^ Enumerator "TestEnum" should not have "Enum" suffix + | ^^^^^^^^ Enum "TestEnum" should not have "Enum" suffix 18 | extend enum EnumTest { #### 💡 Suggestion: Rename to \`Test\` @@ -2392,7 +2427,7 @@ exports[`naming-convention > invalid > schema-recommended config 1`] = ` 17 | enum TestEnum > 18 | extend enum EnumTest { - | ^^^^^^^^ EnumTypeExtension "EnumTest" should not have "Enum" prefix + | ^^^^^^^^ Enum "EnumTest" should not have "Enum" prefix 19 | A #### 💡 Suggestion: Rename to \`Test\` @@ -2478,7 +2513,7 @@ exports[`naming-convention > invalid > schema-recommended config 1`] = ` 22 | interface TestInterface > 23 | extend interface InterfaceTest { - | ^^^^^^^^^^^^^ InterfaceTypeExtension "InterfaceTest" should not have "Interface" prefix + | ^^^^^^^^^^^^^ Interface "InterfaceTest" should not have "Interface" prefix 24 | id: ID #### 💡 Suggestion: Rename to \`Test\` @@ -2564,7 +2599,7 @@ exports[`naming-convention > invalid > schema-recommended config 1`] = ` 27 | union TestUnion > 28 | extend union UnionTest = TestInterface - | ^^^^^^^^^ UnionTypeExtension "UnionTest" should not have "Union" prefix + | ^^^^^^^^^ Union "UnionTest" should not have "Union" prefix 29 | #### 💡 Suggestion: Rename to \`Test\` @@ -2650,7 +2685,7 @@ exports[`naming-convention > invalid > schema-recommended config 1`] = ` 30 | type TestType > 31 | extend type TypeTest { - | ^^^^^^^^ ObjectTypeExtension "TypeTest" should not have "Type" prefix + | ^^^^^^^^ Type "TypeTest" should not have "Type" prefix 32 | id: ID #### 💡 Suggestion: Rename to \`Test\` From 322f87d4a0501e806560baf0826b8875e6770634 Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Fri, 29 Nov 2024 03:30:02 +0700 Subject: [PATCH 05/14] aa --- .../src/rules/naming-convention/index.test.ts | 11 +++++++ .../src/rules/naming-convention/snapshot.md | 31 +++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/packages/plugin/src/rules/naming-convention/index.test.ts b/packages/plugin/src/rules/naming-convention/index.test.ts index b7e8ce6a4ab..43591941ec4 100644 --- a/packages/plugin/src/rules/naming-convention/index.test.ts +++ b/packages/plugin/src/rules/naming-convention/index.test.ts @@ -537,5 +537,16 @@ ruleTester.run('naming-convention', rule, { options: [{ OperationDefinition: { forbiddenPattern: ['^get', '^query'] } }], errors: 2, }, + { + name: 'requiredPattern', + code: 'type Test { enabled: Boolean! }', + options: [{ + 'FieldDefinition[gqlType.gqlType.name.value=Boolean]': { + style: 'camelCase', + requiredPattern: ['^is', '^has'], + }, + }], + errors: 1, + }, ], }); diff --git a/packages/plugin/src/rules/naming-convention/snapshot.md b/packages/plugin/src/rules/naming-convention/snapshot.md index 335ff728eb5..1692f3c6a99 100644 --- a/packages/plugin/src/rules/naming-convention/snapshot.md +++ b/packages/plugin/src/rules/naming-convention/snapshot.md @@ -1974,6 +1974,37 @@ exports[`naming-convention > invalid > operations-recommended config 1`] = ` 13 | fragment Test on Test { id } `; +exports[`naming-convention > invalid > requiredPattern 1`] = ` +#### ⌨️ Code + + 1 | type Test { enabled: Boolean! } + +#### ⚙️ Options + + { + "FieldDefinition[gqlType.gqlType.name.value=Boolean]": { + "style": "camelCase", + "requiredPrefixes": [ + "^is", + "^has" + ] + } + } + +#### ❌ Error + + > 1 | type Test { enabled: Boolean! } + | ^^^^^^^ Field "enabled" should have one of the following prefixes: ^is or ^has + +#### 💡 Suggestion 1/2: Rename to \`isEnabled\` + + 1 | type Test { isEnabled: Boolean! } + +#### 💡 Suggestion 2/2: Rename to \`hasEnabled\` + + 1 | type Test { hasEnabled: Boolean! } +`; + exports[`naming-convention > invalid > schema-recommended config 1`] = ` #### ⌨️ Code From 0fa2f5c8f5d85a7ce0b484475184eb8c2fc8a374 Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Fri, 29 Nov 2024 03:39:22 +0700 Subject: [PATCH 06/14] aa --- packages/plugin/src/rules/naming-convention/index.ts | 12 ++++++++++++ .../plugin/src/rules/naming-convention/snapshot.md | 12 ++---------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/packages/plugin/src/rules/naming-convention/index.ts b/packages/plugin/src/rules/naming-convention/index.ts index 72431fbd635..7aab987ba31 100644 --- a/packages/plugin/src/rules/naming-convention/index.ts +++ b/packages/plugin/src/rules/naming-convention/index.ts @@ -364,6 +364,7 @@ export const rule: GraphQLESLintRule = { requiredPrefixes, requiredSuffixes, forbiddenPattern, + requiredPattern } = normalisePropertyOption(selector); const nodeName = node.value; const error = getError(); @@ -411,6 +412,17 @@ export const rule: GraphQLESLintRule = { renameToNames: [name.replace(new RegExp(forbidden), '')], }; } + if ( + requiredPattern && + !requiredPattern.some(pattern => new RegExp(pattern).test(name)) + ) { + return { + errorMessage: `contain the required pattern: ${englishJoinWords( + requiredPattern, + )}`, + renameToNames: [] + }; + } const forbiddenPrefix = forbiddenPrefixes?.find(prefix => name.startsWith(prefix)); if (forbiddenPrefix) { return { diff --git a/packages/plugin/src/rules/naming-convention/snapshot.md b/packages/plugin/src/rules/naming-convention/snapshot.md index 1692f3c6a99..f8b9e84c527 100644 --- a/packages/plugin/src/rules/naming-convention/snapshot.md +++ b/packages/plugin/src/rules/naming-convention/snapshot.md @@ -1984,7 +1984,7 @@ exports[`naming-convention > invalid > requiredPattern 1`] = ` { "FieldDefinition[gqlType.gqlType.name.value=Boolean]": { "style": "camelCase", - "requiredPrefixes": [ + "requiredPattern": [ "^is", "^has" ] @@ -1994,15 +1994,7 @@ exports[`naming-convention > invalid > requiredPattern 1`] = ` #### ❌ Error > 1 | type Test { enabled: Boolean! } - | ^^^^^^^ Field "enabled" should have one of the following prefixes: ^is or ^has - -#### 💡 Suggestion 1/2: Rename to \`isEnabled\` - - 1 | type Test { isEnabled: Boolean! } - -#### 💡 Suggestion 2/2: Rename to \`hasEnabled\` - - 1 | type Test { hasEnabled: Boolean! } + | ^^^^^^^ Field "enabled" should contain the required pattern: ^is or ^has `; exports[`naming-convention > invalid > schema-recommended config 1`] = ` From 77a6d6b4158f7f891ae7c56176fec7acb23b1502 Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Fri, 29 Nov 2024 04:00:11 +0700 Subject: [PATCH 07/14] aa --- .../src/rules/naming-convention/index.test.ts | 27 +++++++-------- .../src/rules/naming-convention/index.ts | 33 ++++++++++++++----- 2 files changed, 36 insertions(+), 24 deletions(-) diff --git a/packages/plugin/src/rules/naming-convention/index.test.ts b/packages/plugin/src/rules/naming-convention/index.test.ts index 43591941ec4..68c62e47b75 100644 --- a/packages/plugin/src/rules/naming-convention/index.test.ts +++ b/packages/plugin/src/rules/naming-convention/index.test.ts @@ -259,27 +259,22 @@ ruleTester.run('naming-convention', rule, { ], errors: [ { - message: - 'Input "_idOperatorsFilterFindManyUserInput" should be in PascalCase format', + message: 'Input "_idOperatorsFilterFindManyUserInput" should be in PascalCase format', }, { message: 'Input "_idOperatorsFilterFindOneUserInput" should be in PascalCase format', }, { - message: - 'Input "_idOperatorsFilterRemoveManyUserInput" should be in PascalCase format', + message: 'Input "_idOperatorsFilterRemoveManyUserInput" should be in PascalCase format', }, { - message: - 'Input "_idOperatorsFilterRemoveOneUserInput" should be in PascalCase format', + message: 'Input "_idOperatorsFilterRemoveOneUserInput" should be in PascalCase format', }, { - message: - 'Input "_idOperatorsFilterUpdateManyUserInput" should be in PascalCase format', + message: 'Input "_idOperatorsFilterUpdateManyUserInput" should be in PascalCase format', }, { - message: - 'Input "_idOperatorsFilterUpdateOneUserInput" should be in PascalCase format', + message: 'Input "_idOperatorsFilterUpdateOneUserInput" should be in PascalCase format', }, { message: 'Input "_idOperatorsFilterUserInput" should be in PascalCase format' }, { message: 'Enum value "male" should be in UPPER_CASE format' }, @@ -540,12 +535,14 @@ ruleTester.run('naming-convention', rule, { { name: 'requiredPattern', code: 'type Test { enabled: Boolean! }', - options: [{ - 'FieldDefinition[gqlType.gqlType.name.value=Boolean]': { - style: 'camelCase', - requiredPattern: ['^is', '^has'], + options: [ + { + 'FieldDefinition[gqlType.gqlType.name.value=Boolean]': { + style: 'camelCase', + requiredPattern: ['^is', '^has'], + }, }, - }], + ], errors: 1, }, ], diff --git a/packages/plugin/src/rules/naming-convention/index.ts b/packages/plugin/src/rules/naming-convention/index.ts index 7aab987ba31..526c8720234 100644 --- a/packages/plugin/src/rules/naming-convention/index.ts +++ b/packages/plugin/src/rules/naming-convention/index.ts @@ -89,6 +89,26 @@ const schema = { description: 'Option to skip validation of some words, e.g. acronyms', }, }, + allOf: ['forbidden', 'required'].flatMap(name => [ + { + not: { + properties: { + [`${name}Pattern`]: { type: 'array' }, + [`${name}Prefixes`]: { type: 'array' }, + }, + required: [`${name}Pattern`, `${name}Prefixes`], + }, + }, + { + not: { + properties: { + [`${name}Pattern`]: { type: 'array' }, + [`${name}Suffixes`]: { type: 'array' }, + }, + required: [`${name}Pattern`, `${name}Suffixes`], + }, + }, + ]), }, }, type: 'array', @@ -364,7 +384,7 @@ export const rule: GraphQLESLintRule = { requiredPrefixes, requiredSuffixes, forbiddenPattern, - requiredPattern + requiredPattern, } = normalisePropertyOption(selector); const nodeName = node.value; const error = getError(); @@ -412,15 +432,10 @@ export const rule: GraphQLESLintRule = { renameToNames: [name.replace(new RegExp(forbidden), '')], }; } - if ( - requiredPattern && - !requiredPattern.some(pattern => new RegExp(pattern).test(name)) - ) { + if (requiredPattern && !requiredPattern.some(pattern => new RegExp(pattern).test(name))) { return { - errorMessage: `contain the required pattern: ${englishJoinWords( - requiredPattern, - )}`, - renameToNames: [] + errorMessage: `contain the required pattern: ${englishJoinWords(requiredPattern)}`, + renameToNames: [], }; } const forbiddenPrefix = forbiddenPrefixes?.find(prefix => name.startsWith(prefix)); From 0cacf02cab403617b8f71dfb73a969e42ae825a5 Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Fri, 29 Nov 2024 04:08:05 +0700 Subject: [PATCH 08/14] aa --- .../src/rules/naming-convention/index.test.ts | 4 +-- .../src/rules/naming-convention/index.ts | 30 ++++++++++++------- .../src/rules/naming-convention/snapshot.md | 6 ++-- website/content/rules/naming-convention.mdx | 8 +++-- 4 files changed, 31 insertions(+), 17 deletions(-) diff --git a/packages/plugin/src/rules/naming-convention/index.test.ts b/packages/plugin/src/rules/naming-convention/index.test.ts index 68c62e47b75..a605d20dac9 100644 --- a/packages/plugin/src/rules/naming-convention/index.test.ts +++ b/packages/plugin/src/rules/naming-convention/index.test.ts @@ -529,7 +529,7 @@ ruleTester.run('naming-convention', rule, { { name: 'forbiddenPattern', code: 'query queryFoo { foo } query getBar { bar }', - options: [{ OperationDefinition: { forbiddenPattern: ['^get', '^query'] } }], + options: [{ OperationDefinition: { forbiddenPattern: [/^(get|query)/] } }], errors: 2, }, { @@ -539,7 +539,7 @@ ruleTester.run('naming-convention', rule, { { 'FieldDefinition[gqlType.gqlType.name.value=Boolean]': { style: 'camelCase', - requiredPattern: ['^is', '^has'], + requiredPattern: [/^(is|has)/], }, }, ], diff --git a/packages/plugin/src/rules/naming-convention/index.ts b/packages/plugin/src/rules/naming-convention/index.ts index 526c8720234..ef790046842 100644 --- a/packages/plugin/src/rules/naming-convention/index.ts +++ b/packages/plugin/src/rules/naming-convention/index.ts @@ -66,8 +66,20 @@ const schema = { style: { enum: ALLOWED_STYLES }, prefix: { type: 'string' }, suffix: { type: 'string' }, - forbiddenPattern: ARRAY_DEFAULT_OPTIONS, - requiredPattern: ARRAY_DEFAULT_OPTIONS, + forbiddenPattern: { + ...ARRAY_DEFAULT_OPTIONS, + items: { + type: 'object', + description: 'RegEx', + }, + }, + requiredPattern: { + ...ARRAY_DEFAULT_OPTIONS, + items: { + type: 'object', + description: 'RegEx', + }, + }, forbiddenPrefixes: { ...ARRAY_DEFAULT_OPTIONS, description: descriptionPrefixesSuffixes('forbiddenPattern'), @@ -158,8 +170,8 @@ type PropertySchema = { style?: AllowedStyle; suffix?: string; prefix?: string; - forbiddenPattern?: string[]; - requiredPattern?: string[]; + forbiddenPattern?: RegExp[]; + requiredPattern?: RegExp[]; forbiddenPrefixes?: string[]; forbiddenSuffixes?: string[]; requiredPrefixes?: string[]; @@ -423,18 +435,16 @@ export const rule: GraphQLESLintRule = { renameToNames: [name + suffix], }; } - const forbidden = forbiddenPattern?.find((pattern: string) => - new RegExp(pattern).test(name), - ); + const forbidden = forbiddenPattern?.find(pattern => pattern.test(name)); if (forbidden) { return { errorMessage: `not contain the forbidden pattern "${forbidden}"`, - renameToNames: [name.replace(new RegExp(forbidden), '')], + renameToNames: [name.replace(forbidden, '')], }; } - if (requiredPattern && !requiredPattern.some(pattern => new RegExp(pattern).test(name))) { + if (requiredPattern && !requiredPattern.some(pattern => pattern.test(name))) { return { - errorMessage: `contain the required pattern: ${englishJoinWords(requiredPattern)}`, + errorMessage: `contain the required pattern: ${englishJoinWords(requiredPattern.map(re => re.source))}`, renameToNames: [], }; } diff --git a/packages/plugin/src/rules/naming-convention/snapshot.md b/packages/plugin/src/rules/naming-convention/snapshot.md index f8b9e84c527..efec8d9d804 100644 --- a/packages/plugin/src/rules/naming-convention/snapshot.md +++ b/packages/plugin/src/rules/naming-convention/snapshot.md @@ -394,7 +394,7 @@ exports[`naming-convention > invalid > forbiddenPattern 1`] = ` #### ❌ Error 1/2 > 1 | query queryFoo { foo } query getBar { bar } - | ^^^^^^^^ Query "queryFoo" should not contain the forbidden pattern "^query" + | ^^^^^^^^ Query "queryFoo" should not contain the forbidden pattern "/^(get|query)/" #### 💡 Suggestion: Rename to \`Foo\` @@ -403,7 +403,7 @@ exports[`naming-convention > invalid > forbiddenPattern 1`] = ` #### ❌ Error 2/2 > 1 | query queryFoo { foo } query getBar { bar } - | ^^^^^^ Query "getBar" should not contain the forbidden pattern "^get" + | ^^^^^^ Query "getBar" should not contain the forbidden pattern "/^(get|query)/" #### 💡 Suggestion: Rename to \`Bar\` @@ -1994,7 +1994,7 @@ exports[`naming-convention > invalid > requiredPattern 1`] = ` #### ❌ Error > 1 | type Test { enabled: Boolean! } - | ^^^^^^^ Field "enabled" should contain the required pattern: ^is or ^has + | ^^^^^^^ Field "enabled" should contain the required pattern: ^(is|has) `; exports[`naming-convention > invalid > schema-recommended config 1`] = ` diff --git a/website/content/rules/naming-convention.mdx b/website/content/rules/naming-convention.mdx index 1d85811af18..be77fd4aacb 100644 --- a/website/content/rules/naming-convention.mdx +++ b/website/content/rules/naming-convention.mdx @@ -323,7 +323,9 @@ This element must be one of the following enum values: ### `forbiddenPattern` (array) -The object is an array with all elements of the type `string`. +The object is an array with all elements of the type `object`. + +The array object has the following properties: Additional restrictions: @@ -332,7 +334,9 @@ Additional restrictions: ### `requiredPattern` (array) -The object is an array with all elements of the type `string`. +The object is an array with all elements of the type `object`. + +The array object has the following properties: Additional restrictions: From 1136c1cda94df18cb65e548c2589e5d56ff7fa62 Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Fri, 29 Nov 2024 04:18:12 +0700 Subject: [PATCH 09/14] aa --- packages/plugin/src/rules/naming-convention/index.ts | 4 ++-- packages/plugin/src/rules/naming-convention/snapshot.md | 6 ++---- packages/plugin/tsup.config.ts | 1 + packages/rule-tester/src/index.ts | 5 +++++ website/content/rules/naming-convention.mdx | 4 ++++ 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/packages/plugin/src/rules/naming-convention/index.ts b/packages/plugin/src/rules/naming-convention/index.ts index ef790046842..9cc87453f15 100644 --- a/packages/plugin/src/rules/naming-convention/index.ts +++ b/packages/plugin/src/rules/naming-convention/index.ts @@ -70,15 +70,15 @@ const schema = { ...ARRAY_DEFAULT_OPTIONS, items: { type: 'object', - description: 'RegEx', }, + description: 'RegEx', }, requiredPattern: { ...ARRAY_DEFAULT_OPTIONS, items: { type: 'object', - description: 'RegEx', }, + description: 'RegEx', }, forbiddenPrefixes: { ...ARRAY_DEFAULT_OPTIONS, diff --git a/packages/plugin/src/rules/naming-convention/snapshot.md b/packages/plugin/src/rules/naming-convention/snapshot.md index efec8d9d804..13075e5ba5f 100644 --- a/packages/plugin/src/rules/naming-convention/snapshot.md +++ b/packages/plugin/src/rules/naming-convention/snapshot.md @@ -385,8 +385,7 @@ exports[`naming-convention > invalid > forbiddenPattern 1`] = ` { "OperationDefinition": { "forbiddenPattern": [ - "^get", - "^query" + "/^(get|query)/" ] } } @@ -1985,8 +1984,7 @@ exports[`naming-convention > invalid > requiredPattern 1`] = ` "FieldDefinition[gqlType.gqlType.name.value=Boolean]": { "style": "camelCase", "requiredPattern": [ - "^is", - "^has" + "/^(is|has)/" ] } } diff --git a/packages/plugin/tsup.config.ts b/packages/plugin/tsup.config.ts index da16ef437e3..07684a9ee6f 100644 --- a/packages/plugin/tsup.config.ts +++ b/packages/plugin/tsup.config.ts @@ -63,6 +63,7 @@ export default defineConfig([ dts: false, bundle: true, env: { + ...opts.env, NODE_ENV: 'production', }, esbuildOptions(options, _context) { diff --git a/packages/rule-tester/src/index.ts b/packages/rule-tester/src/index.ts index 77816ed883a..bb315a22240 100644 --- a/packages/rule-tester/src/index.ts +++ b/packages/rule-tester/src/index.ts @@ -25,6 +25,11 @@ function applyFix(code: string, { range, text }: Rule.Fix): string { return [code.slice(0, range[0]), text, code.slice(range[1])].join(''); } +// @ts-expect-error -- Extend RegExp with a custom toJSON method +RegExp.prototype.toJSON = function() { + return `/${this.source}/${this.flags}` +}; + export class RuleTester extends ESLintRuleTester { fromMockFile(path: string): string { return readFileSync(resolve(__dirname, `../../plugin/__tests__/mocks/${path}`), 'utf-8'); diff --git a/website/content/rules/naming-convention.mdx b/website/content/rules/naming-convention.mdx index be77fd4aacb..16e66ebf3d5 100644 --- a/website/content/rules/naming-convention.mdx +++ b/website/content/rules/naming-convention.mdx @@ -323,6 +323,8 @@ This element must be one of the following enum values: ### `forbiddenPattern` (array) +RegEx + The object is an array with all elements of the type `object`. The array object has the following properties: @@ -334,6 +336,8 @@ Additional restrictions: ### `requiredPattern` (array) +RegEx + The object is an array with all elements of the type `object`. The array object has the following properties: From c470bd92df6de668e7101e56d6b368f61ffd5f8b Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Fri, 29 Nov 2024 04:21:24 +0700 Subject: [PATCH 10/14] aa --- .../src/rules/naming-convention/index.ts | 24 ++----------------- website/content/rules/naming-convention.mdx | 4 ++-- 2 files changed, 4 insertions(+), 24 deletions(-) diff --git a/packages/plugin/src/rules/naming-convention/index.ts b/packages/plugin/src/rules/naming-convention/index.ts index 9cc87453f15..1d3b7455c34 100644 --- a/packages/plugin/src/rules/naming-convention/index.ts +++ b/packages/plugin/src/rules/naming-convention/index.ts @@ -71,14 +71,14 @@ const schema = { items: { type: 'object', }, - description: 'RegEx', + description: 'Should be of instance of RegEx', }, requiredPattern: { ...ARRAY_DEFAULT_OPTIONS, items: { type: 'object', }, - description: 'RegEx', + description: 'Should be of instance of RegEx', }, forbiddenPrefixes: { ...ARRAY_DEFAULT_OPTIONS, @@ -101,26 +101,6 @@ const schema = { description: 'Option to skip validation of some words, e.g. acronyms', }, }, - allOf: ['forbidden', 'required'].flatMap(name => [ - { - not: { - properties: { - [`${name}Pattern`]: { type: 'array' }, - [`${name}Prefixes`]: { type: 'array' }, - }, - required: [`${name}Pattern`, `${name}Prefixes`], - }, - }, - { - not: { - properties: { - [`${name}Pattern`]: { type: 'array' }, - [`${name}Suffixes`]: { type: 'array' }, - }, - required: [`${name}Pattern`, `${name}Suffixes`], - }, - }, - ]), }, }, type: 'array', diff --git a/website/content/rules/naming-convention.mdx b/website/content/rules/naming-convention.mdx index 16e66ebf3d5..014c594820a 100644 --- a/website/content/rules/naming-convention.mdx +++ b/website/content/rules/naming-convention.mdx @@ -323,7 +323,7 @@ This element must be one of the following enum values: ### `forbiddenPattern` (array) -RegEx +Should be of instance of RegEx The object is an array with all elements of the type `object`. @@ -336,7 +336,7 @@ Additional restrictions: ### `requiredPattern` (array) -RegEx +Should be of instance of RegEx The object is an array with all elements of the type `object`. From 6c08475a17c787ad8a3727dc3a79de56a85d4261 Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Fri, 29 Nov 2024 04:21:47 +0700 Subject: [PATCH 11/14] aa --- packages/plugin/src/rules/naming-convention/index.ts | 4 ++-- website/content/rules/naming-convention.mdx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/plugin/src/rules/naming-convention/index.ts b/packages/plugin/src/rules/naming-convention/index.ts index 1d3b7455c34..9f3eb1cf21d 100644 --- a/packages/plugin/src/rules/naming-convention/index.ts +++ b/packages/plugin/src/rules/naming-convention/index.ts @@ -71,14 +71,14 @@ const schema = { items: { type: 'object', }, - description: 'Should be of instance of RegEx', + description: 'Should be of instance of `RegEx`', }, requiredPattern: { ...ARRAY_DEFAULT_OPTIONS, items: { type: 'object', }, - description: 'Should be of instance of RegEx', + description: 'Should be of instance of `RegEx`', }, forbiddenPrefixes: { ...ARRAY_DEFAULT_OPTIONS, diff --git a/website/content/rules/naming-convention.mdx b/website/content/rules/naming-convention.mdx index 014c594820a..dff7e598cc3 100644 --- a/website/content/rules/naming-convention.mdx +++ b/website/content/rules/naming-convention.mdx @@ -323,7 +323,7 @@ This element must be one of the following enum values: ### `forbiddenPattern` (array) -Should be of instance of RegEx +Should be of instance of `RegEx` The object is an array with all elements of the type `object`. @@ -336,7 +336,7 @@ Additional restrictions: ### `requiredPattern` (array) -Should be of instance of RegEx +Should be of instance of `RegEx` The object is an array with all elements of the type `object`. From 133b421ba884f8bd8ca52bbc853ad2ee6ca68edb Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Fri, 29 Nov 2024 04:26:26 +0700 Subject: [PATCH 12/14] upd snapshots --- .../__tests__/__snapshots__/examples.spec.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/plugin/__tests__/__snapshots__/examples.spec.md b/packages/plugin/__tests__/__snapshots__/examples.spec.md index cab5484eb18..d2be9d53da2 100644 --- a/packages/plugin/__tests__/__snapshots__/examples.spec.md +++ b/packages/plugin/__tests__/__snapshots__/examples.spec.md @@ -10,7 +10,7 @@ exports[`Examples > should work in monorepo 1`] = ` endColumn: 15, endLine: 1, line: 1, - message: Operation "getUsers" should be in PascalCase format, + message: Query "getUsers" should be in PascalCase format, nodeType: Name, ruleId: @graphql-eslint/naming-convention, severity: 2, @@ -198,7 +198,7 @@ exports[`Examples > should work in monorepo 2`] = ` endColumn: 15, endLine: 1, line: 1, - message: Operation "getUsers" should be in PascalCase format, + message: Query "getUsers" should be in PascalCase format, nodeType: Name, ruleId: @graphql-eslint/naming-convention, severity: 2, @@ -583,7 +583,7 @@ exports[`Examples > should work in svelte 1`] = ` { column: 0, line: 1, - message: Operation "UserQuery" should not have "Query" suffix, + message: Query "UserQuery" should not have "Query" suffix, nodeType: Name, ruleId: @graphql-eslint/naming-convention, severity: 2, @@ -610,7 +610,7 @@ exports[`Examples > should work in svelte 2`] = ` { column: 0, line: 1, - message: Operation "UserQuery" should not have "Query" suffix, + message: Query "UserQuery" should not have "Query" suffix, nodeType: Name, ruleId: @graphql-eslint/naming-convention, severity: 2, @@ -675,7 +675,7 @@ exports[`Examples > should work in vue 1`] = ` endColumn: 19, endLine: 16, line: 16, - message: Operation "UserQuery" should not have "Query" suffix, + message: Query "UserQuery" should not have "Query" suffix, nodeType: Name, ruleId: @graphql-eslint/naming-convention, severity: 2, @@ -714,7 +714,7 @@ exports[`Examples > should work in vue 2`] = ` { column: 0, line: 1, - message: Operation "UserQuery" should not have "Query" suffix, + message: Query "UserQuery" should not have "Query" suffix, nodeType: Name, ruleId: @graphql-eslint/naming-convention, severity: 2, @@ -822,7 +822,7 @@ exports[`Examples > should work on \`.js\` files 1`] = ` endColumn: 18, endLine: 12, line: 12, - message: Operation "UserQuery" should not have "Query" suffix, + message: Query "UserQuery" should not have "Query" suffix, nodeType: Name, ruleId: @graphql-eslint/naming-convention, severity: 2, @@ -920,7 +920,7 @@ exports[`Examples > should work on \`.js\` files 2`] = ` endColumn: 18, endLine: 12, line: 12, - message: Operation "UserQuery" should not have "Query" suffix, + message: Query "UserQuery" should not have "Query" suffix, nodeType: Name, ruleId: @graphql-eslint/naming-convention, severity: 2, From 54a25fdff8c3b794737fc3de1b8fc6a7df3827e3 Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Fri, 29 Nov 2024 04:30:15 +0700 Subject: [PATCH 13/14] missing dots --- packages/plugin/src/rules/naming-convention/index.ts | 2 +- website/content/rules/naming-convention.mdx | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/plugin/src/rules/naming-convention/index.ts b/packages/plugin/src/rules/naming-convention/index.ts index 9f3eb1cf21d..0c42de7504a 100644 --- a/packages/plugin/src/rules/naming-convention/index.ts +++ b/packages/plugin/src/rules/naming-convention/index.ts @@ -51,7 +51,7 @@ const schemaOption = { const descriptionPrefixesSuffixes = (name: 'forbiddenPattern' | 'requiredPattern') => `> [!WARNING] > -> This option is deprecated and will be removed in the next major release. Use \`${name}\` instead`; +> This option is deprecated and will be removed in the next major release. Use \`${name}\` instead.`; const schema = { definitions: { diff --git a/website/content/rules/naming-convention.mdx b/website/content/rules/naming-convention.mdx index dff7e598cc3..d85f4cfe132 100644 --- a/website/content/rules/naming-convention.mdx +++ b/website/content/rules/naming-convention.mdx @@ -352,7 +352,7 @@ Additional restrictions: > [!WARNING] > > This option is deprecated and will be removed in the next major release. Use `forbiddenPattern` -> instead +> instead. The object is an array with all elements of the type `string`. @@ -366,7 +366,7 @@ Additional restrictions: > [!WARNING] > > This option is deprecated and will be removed in the next major release. Use `forbiddenPattern` -> instead +> instead. The object is an array with all elements of the type `string`. @@ -380,7 +380,7 @@ Additional restrictions: > [!WARNING] > > This option is deprecated and will be removed in the next major release. Use `requiredPattern` -> instead +> instead. The object is an array with all elements of the type `string`. @@ -394,7 +394,7 @@ Additional restrictions: > [!WARNING] > > This option is deprecated and will be removed in the next major release. Use `requiredPattern` -> instead +> instead. The object is an array with all elements of the type `string`. From 47212e29bd7289aab6adc9e573221d04e2818bac Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Fri, 29 Nov 2024 04:31:34 +0700 Subject: [PATCH 14/14] yoyo --- .../plugin/src/rules/naming-convention/index.ts | 2 +- website/content/rules/naming-convention.mdx | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/plugin/src/rules/naming-convention/index.ts b/packages/plugin/src/rules/naming-convention/index.ts index 0c42de7504a..5d2068d3f2f 100644 --- a/packages/plugin/src/rules/naming-convention/index.ts +++ b/packages/plugin/src/rules/naming-convention/index.ts @@ -51,7 +51,7 @@ const schemaOption = { const descriptionPrefixesSuffixes = (name: 'forbiddenPattern' | 'requiredPattern') => `> [!WARNING] > -> This option is deprecated and will be removed in the next major release. Use \`${name}\` instead.`; +> This option is deprecated and will be removed in the next major release. Use [\`${name}\`](#${name.toLowerCase()}-array) instead.`; const schema = { definitions: { diff --git a/website/content/rules/naming-convention.mdx b/website/content/rules/naming-convention.mdx index d85f4cfe132..e63bfbc6ef6 100644 --- a/website/content/rules/naming-convention.mdx +++ b/website/content/rules/naming-convention.mdx @@ -351,8 +351,8 @@ Additional restrictions: > [!WARNING] > -> This option is deprecated and will be removed in the next major release. Use `forbiddenPattern` -> instead. +> This option is deprecated and will be removed in the next major release. Use +> [`forbiddenPattern`](#forbiddenpattern-array) instead. The object is an array with all elements of the type `string`. @@ -365,8 +365,8 @@ Additional restrictions: > [!WARNING] > -> This option is deprecated and will be removed in the next major release. Use `forbiddenPattern` -> instead. +> This option is deprecated and will be removed in the next major release. Use +> [`forbiddenPattern`](#forbiddenpattern-array) instead. The object is an array with all elements of the type `string`. @@ -379,8 +379,8 @@ Additional restrictions: > [!WARNING] > -> This option is deprecated and will be removed in the next major release. Use `requiredPattern` -> instead. +> This option is deprecated and will be removed in the next major release. Use +> [`requiredPattern`](#requiredpattern-array) instead. The object is an array with all elements of the type `string`. @@ -393,8 +393,8 @@ Additional restrictions: > [!WARNING] > -> This option is deprecated and will be removed in the next major release. Use `requiredPattern` -> instead. +> This option is deprecated and will be removed in the next major release. Use +> [`requiredPattern`](#requiredpattern-array) instead. The object is an array with all elements of the type `string`.