From a2cd3f610a10f949d224887f4d9cada4f149bcc6 Mon Sep 17 00:00:00 2001 From: Keith Cirkel Date: Fri, 13 Jan 2023 14:27:48 +0000 Subject: [PATCH] move schemas into meta --- .../define-tag-after-class-definition.js | 2 +- lib/rules/expose-class-on-global.js | 2 +- lib/rules/extends-correct-class.js | 16 +++---- lib/rules/file-name-matches-element.js | 46 +++++++++---------- lib/rules/no-constructor.js | 2 +- lib/rules/no-customized-built-in-elements.js | 2 +- ...m-traversal-in-attributechangedcallback.js | 2 +- .../no-dom-traversal-in-connectedcallback.js | 2 +- lib/rules/no-exports-with-element.js | 2 +- lib/rules/no-method-prefixed-with-on.js | 2 +- lib/rules/no-unchecked-define.js | 2 +- lib/rules/one-element-per-file.js | 2 +- lib/rules/tag-name-matches-class.js | 24 +++++----- lib/rules/valid-tag-name.js | 28 +++++------ test/check-rules.js | 2 +- 15 files changed, 68 insertions(+), 68 deletions(-) diff --git a/lib/rules/define-tag-after-class-definition.js b/lib/rules/define-tag-after-class-definition.js index 28e83f4..d3879f6 100644 --- a/lib/rules/define-tag-after-class-definition.js +++ b/lib/rules/define-tag-after-class-definition.js @@ -4,8 +4,8 @@ module.exports = { meta: { type: 'suggestion', docs: {description: '', url: require('../url')(module)}, + schema: [], }, - schema: [], create(context) { const classes = ClassRefTracker.customElements(context) return { diff --git a/lib/rules/expose-class-on-global.js b/lib/rules/expose-class-on-global.js index ca76cfb..bbec1e0 100644 --- a/lib/rules/expose-class-on-global.js +++ b/lib/rules/expose-class-on-global.js @@ -4,8 +4,8 @@ module.exports = { meta: { type: 'suggestion', docs: {description: '', url: require('../url')(module)}, + schema: [], }, - schema: [], create(context) { const classes = ClassRefTracker.customElements(context) return { diff --git a/lib/rules/extends-correct-class.js b/lib/rules/extends-correct-class.js index 79735b8..c59b080 100644 --- a/lib/rules/extends-correct-class.js +++ b/lib/rules/extends-correct-class.js @@ -33,15 +33,15 @@ module.exports = { meta: { type: 'problem', docs: {description: '', url: require('../url')(module)}, - }, - schema: [ - { - type: 'object', - properties: { - allowedSuperNames: {type: 'array', items: {type: 'string'}}, + schema: [ + { + type: 'object', + properties: { + allowedSuperNames: {type: 'array', items: {type: 'string'}}, + }, }, - }, - ], + ], + }, create(context) { const classes = new ClassRefTracker(context) return { diff --git a/lib/rules/file-name-matches-element.js b/lib/rules/file-name-matches-element.js index a5ff4ef..a7b7dc9 100644 --- a/lib/rules/file-name-matches-element.js +++ b/lib/rules/file-name-matches-element.js @@ -19,31 +19,31 @@ module.exports = { meta: { type: 'suggestion', docs: {description: '', url: require('../url')(module)}, - }, - schema: [ - { - type: 'object', - properties: { - transform: { - oneOf: [ - {enum: ['none', 'snake', 'kebab', 'pascal']}, - { - type: 'array', - items: {enum: ['none', 'snake', 'kebab', 'pascal']}, - minItems: 1, - maxItems: 4, - }, - ], - }, - suffix: { - onfOf: [{type: 'string'}, {type: 'array', items: {type: 'string'}}], - }, - matchDirectory: { - type: 'boolean', + schema: [ + { + type: 'object', + properties: { + transform: { + oneOf: [ + {enum: ['none', 'snake', 'kebab', 'pascal']}, + { + type: 'array', + items: {enum: ['none', 'snake', 'kebab', 'pascal']}, + minItems: 1, + maxItems: 4, + }, + ], + }, + suffix: { + onfOf: [{type: 'string'}, {type: 'array', items: {type: 'string'}}], + }, + matchDirectory: { + type: 'boolean', + }, }, }, - }, - ], + ], + }, create(context) { if (!hasFileName(context)) return {} return { diff --git a/lib/rules/no-constructor.js b/lib/rules/no-constructor.js index 1c7e349..476c377 100644 --- a/lib/rules/no-constructor.js +++ b/lib/rules/no-constructor.js @@ -3,8 +3,8 @@ module.exports = { meta: { type: 'suggestion', docs: {description: '', url: require('../url')(module)}, + schema: [], }, - schema: [], create(context) { return { [`${s.HTMLElementClass} MethodDefinition[key.name="constructor"]`](node) { diff --git a/lib/rules/no-customized-built-in-elements.js b/lib/rules/no-customized-built-in-elements.js index 39e2d09..c3d7dc4 100644 --- a/lib/rules/no-customized-built-in-elements.js +++ b/lib/rules/no-customized-built-in-elements.js @@ -5,8 +5,8 @@ module.exports = { meta: { type: 'problem', docs: {description: '', url: require('../url')(module)}, + schema: [], }, - schema: [], create(context) { return { [s.HTMLElementClass](node) { diff --git a/lib/rules/no-dom-traversal-in-attributechangedcallback.js b/lib/rules/no-dom-traversal-in-attributechangedcallback.js index 1f1e606..4475d3b 100644 --- a/lib/rules/no-dom-traversal-in-attributechangedcallback.js +++ b/lib/rules/no-dom-traversal-in-attributechangedcallback.js @@ -4,8 +4,8 @@ module.exports = { meta: { type: 'suggestion', docs: {description: '', url: require('../url')(module)}, + schema: [], }, - schema: [], create(context) { return { [`${s.HTMLElementClass} MethodDefinition[key.name="attributeChangedCallback"] MemberExpression`](node) { diff --git a/lib/rules/no-dom-traversal-in-connectedcallback.js b/lib/rules/no-dom-traversal-in-connectedcallback.js index 19dafc3..df0d8ed 100644 --- a/lib/rules/no-dom-traversal-in-connectedcallback.js +++ b/lib/rules/no-dom-traversal-in-connectedcallback.js @@ -4,8 +4,8 @@ module.exports = { meta: { type: 'suggestion', docs: {description: '', url: require('../url')(module)}, + schema: [], }, - schema: [], create(context) { return { [`${s.HTMLElementClass} MethodDefinition[key.name="connectedCallback"] MemberExpression`](node) { diff --git a/lib/rules/no-exports-with-element.js b/lib/rules/no-exports-with-element.js index e1549b0..81b6291 100644 --- a/lib/rules/no-exports-with-element.js +++ b/lib/rules/no-exports-with-element.js @@ -5,8 +5,8 @@ module.exports = { meta: { type: 'layout', docs: {description: '', url: require('../url')(module)}, + schema: [], }, - schema: [], create(context) { const classes = ClassRefTracker.customElements(context) const eventClasses = ClassRefTracker.customEvents(context) diff --git a/lib/rules/no-method-prefixed-with-on.js b/lib/rules/no-method-prefixed-with-on.js index 73bd859..881a014 100644 --- a/lib/rules/no-method-prefixed-with-on.js +++ b/lib/rules/no-method-prefixed-with-on.js @@ -4,8 +4,8 @@ module.exports = { meta: { type: 'suggestion', docs: {description: '', url: require('../url')(module)}, + schema: [], }, - schema: [], create(context) { return { [`${s.HTMLElementClass} MethodDefinition[key.name=/^on.*$/i]`](node) { diff --git a/lib/rules/no-unchecked-define.js b/lib/rules/no-unchecked-define.js index 8e95905..d36a995 100644 --- a/lib/rules/no-unchecked-define.js +++ b/lib/rules/no-unchecked-define.js @@ -6,8 +6,8 @@ module.exports = { meta: { type: 'layout', docs: {description: '', url: require('../url')(module)}, + schema: [], }, - schema: [], create(context) { definedCustomElements = new Map() return { diff --git a/lib/rules/one-element-per-file.js b/lib/rules/one-element-per-file.js index 8d19c2f..7bfe1ae 100644 --- a/lib/rules/one-element-per-file.js +++ b/lib/rules/one-element-per-file.js @@ -3,8 +3,8 @@ module.exports = { meta: { type: 'layout', docs: {description: '', url: require('../url')(module)}, + schema: [], }, - schema: [], create(context) { let classCount = 0 return { diff --git a/lib/rules/tag-name-matches-class.js b/lib/rules/tag-name-matches-class.js index 41f8480..12f0bf8 100644 --- a/lib/rules/tag-name-matches-class.js +++ b/lib/rules/tag-name-matches-class.js @@ -19,20 +19,20 @@ module.exports = { meta: { type: 'suggestion', docs: {description: '', url: require('../url')(module)}, - }, - schema: [ - { - type: 'object', - properties: { - suffix: { - onfOf: [{type: 'string'}, {type: 'array', items: {type: 'string'}}], - }, - prefix: { - onfOf: [{type: 'string'}, {type: 'array', items: {type: 'string'}}], + schema: [ + { + type: 'object', + properties: { + suffix: { + onfOf: [{type: 'string'}, {type: 'array', items: {type: 'string'}}], + }, + prefix: { + onfOf: [{type: 'string'}, {type: 'array', items: {type: 'string'}}], + }, }, }, - }, - ], + ], + }, create(context) { return { [s.customElements.define](node) { diff --git a/lib/rules/valid-tag-name.js b/lib/rules/valid-tag-name.js index 4aaa912..1c2e2a0 100644 --- a/lib/rules/valid-tag-name.js +++ b/lib/rules/valid-tag-name.js @@ -4,22 +4,22 @@ module.exports = { meta: { type: 'problem', docs: {description: '', url: require('../url')(module)}, - }, - schema: [ - { - type: 'object', - properties: { - disallowNamespaces: {type: 'boolean'}, - onlyAlphanum: {type: 'boolean'}, - prefix: { - oneOf: [{type: 'string'}, {type: 'array', items: {type: 'string'}}], - }, - suffix: { - oneOf: [{type: 'string'}, {type: 'array', items: {type: 'string'}}], + schema: [ + { + type: 'object', + properties: { + disallowNamespaces: {type: 'boolean'}, + onlyAlphanum: {type: 'boolean'}, + prefix: { + oneOf: [{type: 'string'}, {type: 'array', items: {type: 'string'}}], + }, + suffix: { + oneOf: [{type: 'string'}, {type: 'array', items: {type: 'string'}}], + }, }, }, - }, - ], + ], + }, create(context) { return { [s.customElements.define](node) { diff --git a/test/check-rules.js b/test/check-rules.js index 164ccdd..5e3cf87 100644 --- a/test/check-rules.js +++ b/test/check-rules.js @@ -124,7 +124,7 @@ describe('documentation', () => { '## Rule Details', '👎 Examples of **incorrect** code for this rule:', '👍 Examples of **correct** code for this rule:', - config.rules?.[doc]?.schema?.length ? '### Options' : '', + config.rules?.[doc]?.meta.schema?.length ? '### Options' : '', '## When Not To Use It', '## Version', ].filter(Boolean)