Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump eslint-plugin-eslint-plugin to v5 #2241

Merged
merged 18 commits into from
Jul 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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
15 changes: 12 additions & 3 deletions eslint-internal-rules/no-invalid-meta-docs-categories.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function checkMetaValidity(context, exportsNode) {
if (!categories) {
context.report({
node: metaDocs,
message: 'Rule is missing a meta.docs.categories property.',
messageId: 'missingCategories',
fix(fixer) {
const category = getPropertyFromObject('category', metaDocs.value)
if (!category) {
Expand Down Expand Up @@ -98,18 +98,27 @@ function checkMetaValidity(context, exportsNode) {
categories.value.name === 'undefined'
)
) {
context.report(categories.value, 'meta.docs.categories must be an array.')
context.report({
node: categories.value,
messageId: 'categoriesMustBeArray'
})
}
}

module.exports = {
meta: {
type: 'problem',
docs: {
description: 'enforce correct use of `meta` property in core rules',
categories: ['Internal']
},
fixable: 'code',
schema: []
schema: [],
messages: {
missingCategories: 'Rule is missing a meta.docs.categories property.',
// eslint-disable-next-line eslint-plugin/report-message-format
categoriesMustBeArray: 'meta.docs.categories must be an array.'
}
},

create(context) {
Expand Down
28 changes: 20 additions & 8 deletions eslint-internal-rules/no-invalid-meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,32 +67,44 @@ function checkMetaValidity(context, exportsNode) {
const metaProperty = getMetaPropertyFromExportsNode(exportsNode)

if (!metaProperty) {
context.report(exportsNode, 'Rule is missing a meta property.')
context.report({
node: exportsNode,
messageId: 'missingMeta'
})
return
}

if (!hasMetaDocs(metaProperty)) {
context.report(metaProperty, 'Rule is missing a meta.docs property.')
context.report({
node: 'metaDocs',
messageId: 'missingMetaDocs'
})
return
}

if (!hasMetaDocsCategories(metaProperty)) {
context.report(
metaProperty,
'Rule is missing a meta.docs.categories property.'
)
context.report({
node: metaProperty,
messageId: 'missingMetaDocsCategories'
})
return
}
}

module.exports = {
meta: {
type: 'problem',
docs: {
description: 'enforce correct use of `meta` property in core rules',
categories: ['Internal']
},

schema: []
schema: [],
messages: {
missingMeta: 'Rule is missing a meta property.',
missingMetaDocs: 'Rule is missing a meta.docs property.',
missingMetaDocsCategories:
'Rule is missing a meta.docs.categories property.'
}
},

create(context) {
Expand Down
5 changes: 3 additions & 2 deletions eslint-internal-rules/require-eslint-community.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@

module.exports = {
meta: {
type: 'problem',
docs: {
description: 'enforce use of the `@eslint-community/*` package',
categories: ['Internal']
},
fixable: 'code',
schema: [],
messages: {
useCommunityPackageInstead:
'Please use `@eslint-community/{{name}}` instead.'
},
schema: []
}
},

/** @param {import('eslint').Rule.RuleContext} context */
Expand Down
21 changes: 8 additions & 13 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module.exports = [
},
...eslintrc.plugins('eslint-plugin', 'prettier', 'unicorn'),
...eslintrc.extends(
'plugin:eslint-plugin/recommended',
'plugin:eslint-plugin/all',
'prettier',
'plugin:node-dependencies/recommended',
'plugin:jsonc/recommended-with-jsonc',
Expand Down Expand Up @@ -143,8 +143,6 @@ module.exports = [

'prettier/prettier': 'error',
'eslint-plugin/report-message-format': ['error', "^[A-Z`'{].*\\.$"],
'eslint-plugin/prefer-placeholders': 'error',
'eslint-plugin/consistent-output': 'error',

'no-debugger': 'error',
'no-console': 'error',
Expand Down Expand Up @@ -199,23 +197,20 @@ module.exports = [
{
files: ['lib/rules/*.js'],
rules: {
'eslint-plugin/no-deprecated-context-methods': 'error',
'eslint-plugin/no-only-tests': 'error',
'eslint-plugin/prefer-object-rule': 'error',
'eslint-plugin/require-meta-docs-description': 'error',
'eslint-plugin/require-meta-docs-url': [
'error',
{
pattern: `https://eslint.vuejs.org/rules/{{name}}.html`
}
{ pattern: 'https://eslint.vuejs.org/rules/{{name}}.html' }
],
'eslint-plugin/require-meta-has-suggestions': 'error',
'eslint-plugin/require-meta-schema': 'error',
'eslint-plugin/require-meta-type': 'error',
'internal/no-invalid-meta': 'error',
'internal/no-invalid-meta-docs-categories': 'error'
}
},
{
files: ['eslint-internal-rules/*.js'],
rules: {
'eslint-plugin/require-meta-docs-url': 'off'
}
},
{
files: ['**/*.json'],
rules: {
Expand Down
10 changes: 6 additions & 4 deletions lib/rules/attribute-hyphenation.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ module.exports = {
},
additionalProperties: false
}
]
],
messages: {
mustBeHyphenated: "Attribute '{{text}}' must be hyphenated.",
cannotBeHyphenated: "Attribute '{{text}}' can't be hyphenated."
}
},
/** @param {RuleContext} context */
create(context) {
Expand Down Expand Up @@ -88,9 +92,7 @@ module.exports = {
context.report({
node: node.key,
loc: node.loc,
message: useHyphenated
? "Attribute '{{text}}' must be hyphenated."
: "Attribute '{{text}}' can't be hyphenated.",
messageId: useHyphenated ? 'mustBeHyphenated' : 'cannotBeHyphenated',
data: {
text
},
Expand Down
10 changes: 7 additions & 3 deletions lib/rules/attributes-order.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,10 @@ function create(context) {
const prevNode = sourceCode.getText(previousNode.key)
context.report({
node,
message: `Attribute "${currentNode}" should go before "${prevNode}".`,
messageId: 'expectedOrder',
data: {
currentNode
currentNode,
prevNode
},

fix(fixer) {
Expand Down Expand Up @@ -439,7 +440,10 @@ module.exports = {
},
additionalProperties: false
}
]
],
messages: {
expectedOrder: `Attribute "{{currentNode}}" should go before "{{prevNode}}".`
}
},
create
}
2 changes: 0 additions & 2 deletions lib/rules/block-tag-newline.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ module.exports = {
messages: {
unexpectedOpeningLinebreak:
"There should be no line break after '<{{tag}}>'.",
unexpectedClosingLinebreak:
"There should be no line break before '</{{tag}}>'.",
expectedOpeningLinebreak:
"Expected {{expected}} after '<{{tag}}>', but {{actual}} found.",
expectedClosingLinebreak:
Expand Down
9 changes: 6 additions & 3 deletions lib/rules/component-definition-name-casing.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,15 @@ module.exports = {
categories: ['vue3-strongly-recommended', 'strongly-recommended'],
url: 'https://eslint.vuejs.org/rules/component-definition-name-casing.html'
},
fixable: 'code', // or "code" or "whitespace"
fixable: 'code',
schema: [
{
enum: allowedCaseOptions
}
]
],
messages: {
incorrectCase: 'Property name "{{value}}" is not {{caseType}}.'
}
},
/** @param {RuleContext} context */
create(context) {
Expand Down Expand Up @@ -63,7 +66,7 @@ module.exports = {
if (!casing.getChecker(caseType)(nodeValue)) {
context.report({
node,
message: 'Property name "{{value}}" is not {{caseType}}.',
messageId: 'incorrectCase',
data: {
value: nodeValue,
caseType
Expand Down
7 changes: 5 additions & 2 deletions lib/rules/component-name-in-template-casing.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ module.exports = {
},
additionalProperties: false
}
]
],
messages: {
incorrectCase: 'Component name "{{name}}" is not {{caseType}}.'
}
},
/** @param {RuleContext} context */
create(context) {
Expand Down Expand Up @@ -156,7 +159,7 @@ module.exports = {
context.report({
node: open,
loc: open.loc,
message: 'Component name "{{name}}" is not {{caseType}}.',
messageId: 'incorrectCase',
data: {
name,
caseType
Expand Down
10 changes: 5 additions & 5 deletions lib/rules/define-emits-declaration.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ module.exports = {
url: 'https://eslint.vuejs.org/rules/define-emits-declaration.html'
},
fixable: null,
messages: {
hasArg: 'Use type-based declaration instead of runtime declaration.',
hasTypeArg: 'Use runtime declaration instead of type-based declaration.'
},
schema: [
{
enum: ['type-based', 'runtime']
}
]
],
messages: {
hasArg: 'Use type-based declaration instead of runtime declaration.',
hasTypeArg: 'Use runtime declaration instead of type-based declaration.'
}
},
/** @param {RuleContext} context */
create(context) {
Expand Down
10 changes: 5 additions & 5 deletions lib/rules/define-props-declaration.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ module.exports = {
url: 'https://eslint.vuejs.org/rules/define-props-declaration.html'
},
fixable: null,
messages: {
hasArg: 'Use type-based declaration instead of runtime declaration.',
hasTypeArg: 'Use runtime declaration instead of type-based declaration.'
},
schema: [
{
enum: ['type-based', 'runtime']
}
]
],
messages: {
hasArg: 'Use type-based declaration instead of runtime declaration.',
hasTypeArg: 'Use runtime declaration instead of type-based declaration.'
}
},
/** @param {RuleContext} context */
create(context) {
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/first-attribute-linebreak.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module.exports = {
categories: ['vue3-strongly-recommended', 'strongly-recommended'],
url: 'https://eslint.vuejs.org/rules/first-attribute-linebreak.html'
},
fixable: 'whitespace', // or "code" or "whitespace"
fixable: 'whitespace',
schema: [
{
type: 'object',
Expand Down
9 changes: 6 additions & 3 deletions lib/rules/html-closing-bracket-newline.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ module.exports = {
},
additionalProperties: false
}
]
],
messages: {
expectedBeforeClosingBracket:
'Expected {{expected}} before closing bracket, but {{actual}} found.'
}
},
/** @param {RuleContext} context */
create(context) {
Expand Down Expand Up @@ -83,8 +87,7 @@ module.exports = {
start: prevToken.loc.end,
end: closingBracketToken.loc.start
},
message:
'Expected {{expected}} before closing bracket, but {{actual}} found.',
messageId: 'expectedBeforeClosingBracket',
data: {
expected: getPhrase(expectedLineBreaks),
actual: getPhrase(actualLineBreaks)
Expand Down
10 changes: 7 additions & 3 deletions lib/rules/html-closing-bracket-spacing.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ module.exports = {
categories: ['vue3-strongly-recommended', 'strongly-recommended'],
url: 'https://eslint.vuejs.org/rules/html-closing-bracket-spacing.html'
},
fixable: 'whitespace',
schema: [
{
type: 'object',
Expand All @@ -70,7 +71,10 @@ module.exports = {
additionalProperties: false
}
],
fixable: 'whitespace'
messages: {
missing: "Expected a space before '{{bracket}}', but not found.",
unexpected: "Expected no space before '{{bracket}}', but found."
}
},
/** @param {RuleContext} context */
create(context) {
Expand Down Expand Up @@ -102,7 +106,7 @@ module.exports = {
context.report({
node,
loc: lastToken.loc,
message: "Expected a space before '{{bracket}}', but not found.",
messageId: 'missing',
data: { bracket: sourceCode.getText(lastToken) },
fix: (fixer) => fixer.insertTextBefore(lastToken, ' ')
})
Expand All @@ -113,7 +117,7 @@ module.exports = {
start: prevToken.loc.end,
end: lastToken.loc.end
},
message: "Expected no space before '{{bracket}}', but found.",
messageId: 'unexpected',
data: { bracket: sourceCode.getText(lastToken) },
fix: (fixer) =>
fixer.removeRange([prevToken.range[1], lastToken.range[0]])
Expand Down
7 changes: 5 additions & 2 deletions lib/rules/html-end-tags.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ module.exports = {
url: 'https://eslint.vuejs.org/rules/html-end-tags.html'
},
fixable: 'code',
schema: []
schema: [],
messages: {
missingEndTag: "'<{{name}}>' should have end tag."
}
},
/** @param {RuleContext} context */
create(context) {
Expand All @@ -39,7 +42,7 @@ module.exports = {
context.report({
node: node.startTag,
loc: node.startTag.loc,
message: "'<{{name}}>' should have end tag.",
messageId: 'missingEndTag',
data: { name },
fix: (fixer) => fixer.insertTextAfter(node, `</${name}>`)
})
Expand Down
Loading
Loading