Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix(eslint-plugin): correct rule schemas to pass ajv validation#5531

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 21 additions & 18 deletionspackages/eslint-plugin/src/rules/array-type.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -102,27 +102,30 @@ export default util.createRule<Options, MessageIds>({
errorStringGenericSimple:
"Array type using '{{readonlyPrefix}}{{type}}[]' is forbidden for non-simple types. Use '{{className}}<{{type}}>' instead.",
},
schema: [
{
$defs: {
arrayOption: {
enum: ['array', 'generic', 'array-simple'],
},
schema: {
$defs: {
arrayOption: {
enum: ['array', 'generic', 'array-simple'],
},
properties: {
default: {
$ref: '#/$defs/arrayOption',
description: 'The array type expected for mutable cases...',
},
readonly: {
$ref: '#/$defs/arrayOption',
description:
'The array type expected for readonly cases. If omitted, the value for `default` will be used.',
},
prefixItems: [
Copy link
MemberAuthor

@JoshuaKGoldbergJoshuaKGoldbergAug 23, 2022
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This syntax is a little more heavyweight thanschema: [ ... ] arrays. It would be nice if someone could figure out a way to use$refs within arrays. I couldn't.

cc@bchery 😁

{
properties: {
default: {
$ref: '#/$defs/arrayOption',
description: 'The array type expected for mutable cases...',
},
readonly: {
$ref: '#/$defs/arrayOption',
description:
'The array type expected for readonly cases. If omitted, the value for `default` will be used.',
},
},
type: 'object',
},
type: 'object',
},
],
],
type: 'array',
},
},
defaultOptions: [
{
Expand Down
68 changes: 35 additions & 33 deletionspackages/eslint-plugin/src/rules/ban-ts-comment.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -38,43 +38,45 @@ export default util.createRule<[Options], MessageIds>({
tsDirectiveCommentDescriptionNotMatchPattern:
'The description for the "@ts-{{directive}}" directive must match the {{format}} format.',
},
schema: [
{
$defs: {
directiveConfigSchema: {
oneOf: [
{
type: 'boolean',
default: true,
schema: {
$defs: {
directiveConfigSchema: {
oneOf: [
{
type: 'boolean',
default: true,
},
{
enum: ['allow-with-description'],
},
{
type: 'object',
properties: {
descriptionFormat: { type: 'string' },
},
{
enum: ['allow-with-description'],
},
{
type: 'object',
properties: {
descriptionFormat: { type: 'string' },
},
},
],
},
},
],
},
type: 'object',
properties: {
'ts-expect-error': {
$ref: '#/$defs/directiveConfigSchema',
},
'ts-ignore': { $ref: '#/$defs/directiveConfigSchema' },
'ts-nocheck': { $ref: '#/$defs/directiveConfigSchema' },
'ts-check': { $ref: '#/$defs/directiveConfigSchema' },
minimumDescriptionLength: {
type: 'number',
default: defaultMinimumDescriptionLength,
},
prefixItems: [
{
properties: {
'ts-expect-error': {
$ref: '#/$defs/directiveConfigSchema',
},
'ts-ignore': { $ref: '#/$defs/directiveConfigSchema' },
'ts-nocheck': { $ref: '#/$defs/directiveConfigSchema' },
'ts-check': { $ref: '#/$defs/directiveConfigSchema' },
minimumDescriptionLength: {
type: 'number',
default: defaultMinimumDescriptionLength,
},
},
additionalProperties: false,
},
additionalProperties: false,
},
],
],
type: 'array',
},
},
defaultOptions: [
{
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -66,36 +66,41 @@ export default util.createRule<Options, MessageIds>({
'Public accessibility modifier on {{type}} {{name}}.',
addExplicitAccessibility: "Add '{{ type }}' accessibility modifier",
},
schema: [
{
$defs: {
accessibilityLevel,
},
type: 'object',
properties: {
accessibility: { $ref: '#/$defs/accessibilityLevel' },
overrides: {
type: 'object',
properties: {
accessors: { $ref: '#/$defs/accessibilityLevel' },
constructors: { $ref: '#/$defs/accessibilityLevel' },
methods: { $ref: '#/$defs/accessibilityLevel' },
properties: { $ref: '#/$defs/accessibilityLevel' },
parameterProperties: { $ref: '#/$defs/accessibilityLevel' },
},
schema: {
$defs: {
accessibilityLevel,
},
prefixItems: [
{
type: 'object',
properties: {
accessibility: { $ref: '#/$defs/accessibilityLevel' },
overrides: {
type: 'object',
properties: {
accessors: { $ref: '#/$defs/accessibilityLevel' },
constructors: { $ref: '#/$defs/accessibilityLevel' },
methods: { $ref: '#/$defs/accessibilityLevel' },
properties: { $ref: '#/$defs/accessibilityLevel' },
parameterProperties: {
$ref: '#/$defs/accessibilityLevel',
},
},

additionalProperties: false,
},
ignoredMethodNames: {
type: 'array',
items: {
type: 'string',
additionalProperties: false,
},
ignoredMethodNames: {
type: 'array',
items: {
type: 'string',
},
},
},
additionalProperties: false,
},
additionalProperties: false,
},
],
],
type: 'array',
},
},
defaultOptions: [{ accessibility: 'explicit' }],
create(context, [option]) {
Expand Down
57 changes: 30 additions & 27 deletionspackages/eslint-plugin/src/rules/parameter-properties.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -36,37 +36,40 @@ export default util.createRule<Options, MessageIds>({
preferParameterProperty:
'Property {{parameter}} should be declared as a parameter property.',
},
schema: [
{
$defs: {
modifier: {
enum: [
'readonly',
'private',
'protected',
'public',
'private readonly',
'protected readonly',
'public readonly',
],
},
schema: {
$defs: {
modifier: {
enum: [
'readonly',
'private',
'protected',
'public',
'private readonly',
'protected readonly',
'public readonly',
],
},
type: 'object',
properties: {
allow: {
type: 'array',
items: {
$ref: '#/$defs/modifier',
},
prefixItems: [
{
type: 'object',
properties: {
allow: {
type: 'array',
items: {
$ref: '#/$defs/modifier',
},
minItems: 1,
},
prefer: {
enum: ['class-property', 'parameter-property'],
},
minItems: 1,
},
prefer: {
enum: ['class-property', 'parameter-property'],
},
additionalProperties: false,
},
additionalProperties: false,
},
],
],
type: 'array',
},
},
defaultOptions: [
{
Expand Down
19 changes: 16 additions & 3 deletionspackages/website/plugins/generated-rule-docs.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,11 +4,12 @@ import * as mdast from 'mdast';
import * as path from 'path';
import { format } from 'prettier';
import type { Plugin } from 'unified';
import { compile } from 'json-schema-to-typescript';
import { compile, JSONSchema } from 'json-schema-to-typescript';

import * as tseslintParser from '@typescript-eslint/parser';
import * as eslintPlugin from '@typescript-eslint/eslint-plugin';
import { EOL } from 'os';
import { JSONSchema7 } from 'json-schema';

/**
* Rules whose options schema generate annoyingly complex schemas.
Expand DownExpand Up@@ -213,8 +214,20 @@ export const generatedRuleDocs: Plugin = () => {
type: 'paragraph',
} as mdast.Paragraph);
} else if (!COMPLICATED_RULE_OPTIONS.has(file.stem)) {
const optionsSchema =
meta.schema instanceof Array ? meta.schema[0] : meta.schema;
const optionsSchema: JSONSchema =
meta.schema instanceof Array
? meta.schema[0]
: meta.schema.type === 'array'
? {
...(meta.schema.definitions
? { definitions: meta.schema.definitions }
: {}),
...(meta.schema.$defs
? { $defs: (meta.schema as JSONSchema7).$defs }
: {}),
...(meta.schema.prefixItems as [JSONSchema])[0],
}
: meta.schema;

parent.children.splice(
optionsH2Index + 2,
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp