Skip to content

Commit

Permalink
Revert "chore: run 'npm run lint:fix'"
Browse files Browse the repository at this point in the history
This reverts commit 27e8ada.
  • Loading branch information
TatsuyaYamamoto committed May 7, 2023
1 parent 41b22e1 commit adf77e9
Show file tree
Hide file tree
Showing 89 changed files with 341 additions and 421 deletions.
6 changes: 3 additions & 3 deletions eslint-internal-rules/no-invalid-meta-docs-categories.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,15 @@ function checkMetaValidity(context, exportsNode) {
// fixes.push(fixer.insertTextBefore(category.value, '['), fixer.insertTextAfter(category.value, ']'))

// for vue3 migration
if (category.value.value === 'base') {
fixes.push(fixer.insertTextBefore(category.value, '['))
} else {
if (category.value.value !== 'base') {
fixes.push(
fixer.insertTextBefore(
category.value,
`['vue3-${category.value.value}', `
)
)
} else {
fixes.push(fixer.insertTextBefore(category.value, '['))
}
fixes.push(fixer.insertTextAfter(category.value, ']'))
}
Expand Down
30 changes: 10 additions & 20 deletions lib/processor.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,50 +46,40 @@ module.exports = {
const directiveType = message.messageId
const data = message.message.split(' ')
switch (directiveType) {
case 'disableBlock': {
case 'disableBlock':
state.block.disableAllKeys.add(data[1])
break
}
case 'disableLine': {
case 'disableLine':
state.line.disableAllKeys.add(data[1])
break
}
case 'enableBlock': {
case 'enableBlock':
state.block.disableAllKeys.clear()
break
}
case 'enableLine': {
case 'enableLine':
state.line.disableAllKeys.clear()
break
}
case 'disableBlockRule': {
case 'disableBlockRule':
addDisableRule(state.block.disableRuleKeys, data[1], data[2])
break
}
case 'disableLineRule': {
case 'disableLineRule':
addDisableRule(state.line.disableRuleKeys, data[1], data[2])
break
}
case 'enableBlockRule': {
case 'enableBlockRule':
state.block.disableRuleKeys.delete(data[1])
break
}
case 'enableLineRule': {
case 'enableLineRule':
state.line.disableRuleKeys.delete(data[1])
break
}
case 'clear': {
case 'clear':
state.block.disableAllKeys.clear()
state.block.disableRuleKeys.clear()
state.line.disableAllKeys.clear()
state.line.disableRuleKeys.clear()
break
}
default: {
default:
// unused eslint-disable comments report
unusedDisableDirectiveReports.set(messageToKey(message), message)
break
}
}
return false
} else {
Expand Down
48 changes: 17 additions & 31 deletions lib/rules/attributes-order.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,39 +120,30 @@ function getAttributeType(attribute) {
if (!isVBind(attribute)) {
const name = attribute.key.name.name
switch (name) {
case 'for': {
case 'for':
return ATTRS.LIST_RENDERING
}
case 'if':
case 'else-if':
case 'else':
case 'show':
case 'cloak': {
case 'cloak':
return ATTRS.CONDITIONALS
}
case 'pre':
case 'once': {
case 'once':
return ATTRS.RENDER_MODIFIERS
}
case 'model': {
case 'model':
return ATTRS.TWO_WAY_BINDING
}
case 'on': {
case 'on':
return ATTRS.EVENTS
}
case 'html':
case 'text': {
case 'text':
return ATTRS.CONTENT
}
case 'slot': {
case 'slot':
return ATTRS.SLOT
}
case 'is': {
case 'is':
return ATTRS.DEFINITION
}
default: {
default:
return ATTRS.OTHER_DIRECTIVES
}
}
}
propName =
Expand All @@ -163,29 +154,24 @@ function getAttributeType(attribute) {
propName = attribute.key.name
}
switch (propName) {
case 'is': {
case 'is':
return ATTRS.DEFINITION
}
case 'id': {
case 'id':
return ATTRS.GLOBAL
}
case 'ref':
case 'key': {
case 'key':
return ATTRS.UNIQUE
}
case 'slot':
case 'slot-scope': {
case 'slot-scope':
return ATTRS.SLOT
}
default: {
default:
if (isVBind(attribute)) {
return ATTRS.ATTR_DYNAMIC
}
if (isVShorthandBoolean(attribute)) {
return ATTRS.ATTR_SHORTHAND_BOOL
}
return ATTRS.ATTR_STATIC
}
}
}

Expand All @@ -196,9 +182,9 @@ function getAttributeType(attribute) {
*/
function getPosition(attribute, attributePosition) {
const attributeType = getAttributeType(attribute)
return attributePosition[attributeType] == null
? null
: attributePosition[attributeType]
return attributePosition[attributeType] != null
? attributePosition[attributeType]
: null
}

/**
Expand Down
8 changes: 3 additions & 5 deletions lib/rules/block-lang.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,10 @@ const DEFAULT_LANGUAGES = {
function getAllowsLangPhrase(lang) {
const langs = [...lang].map((s) => `"${s}"`)
switch (langs.length) {
case 1: {
case 1:
return langs[0]
}
default: {
return `${langs.slice(0, -1).join(', ')}, and ${langs.at(-1)}`
}
default:
return `${langs.slice(0, -1).join(', ')}, and ${langs[langs.length - 1]}`
}
}

Expand Down
18 changes: 8 additions & 10 deletions lib/rules/block-tag-newline.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,10 @@ function getLinebreakCount(text) {
*/
function getPhrase(lineBreaks) {
switch (lineBreaks) {
case 1: {
case 1:
return '1 line break'
}
default: {
default:
return `${lineBreaks} line breaks`
}
}
}

Expand Down Expand Up @@ -326,17 +324,17 @@ module.exports = {
return (element) => {
const { name } = element
const elementsOptions = blocks[name]
if (elementsOptions) {
if (!elementsOptions) {
verifyElement(element, options)
} else {
normalizeOptionValue({
singleline: elementsOptions.singleline || options.singleline,
multiline: elementsOptions.multiline || options.multiline,
maxEmptyLines:
elementsOptions.maxEmptyLines == null
? options.maxEmptyLines
: elementsOptions.maxEmptyLines
elementsOptions.maxEmptyLines != null
? elementsOptions.maxEmptyLines
: options.maxEmptyLines
})(element)
} else {
verifyElement(element, options)
}
}
}
Expand Down
18 changes: 9 additions & 9 deletions lib/rules/comment-directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,16 @@ function parse(pattern, comment) {
* @returns {void}
*/
function enable(context, loc, group, rule) {
if (rule) {
if (!rule) {
context.report({
loc,
messageId: group === 'block' ? 'enableBlockRule' : 'enableLineRule',
data: { rule }
messageId: group === 'block' ? 'enableBlock' : 'enableLine'
})
} else {
context.report({
loc,
messageId: group === 'block' ? 'enableBlock' : 'enableLine'
messageId: group === 'block' ? 'enableBlockRule' : 'enableLineRule',
data: { rule }
})
}
}
Expand All @@ -94,17 +94,17 @@ function enable(context, loc, group, rule) {
* @returns {void}
*/
function disable(context, loc, group, rule, key) {
if (rule) {
if (!rule) {
context.report({
loc,
messageId: group === 'block' ? 'disableBlockRule' : 'disableLineRule',
data: { rule, key }
messageId: group === 'block' ? 'disableBlock' : 'disableLine',
data: { key }
})
} else {
context.report({
loc,
messageId: group === 'block' ? 'disableBlock' : 'disableLine',
data: { key }
messageId: group === 'block' ? 'disableBlockRule' : 'disableLineRule',
data: { rule, key }
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/component-api-style.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ function buildAllowedPhrase(allowsOpt) {
phrases.push('Options API')
}
return phrases.length > 2
? `${phrases.slice(0, -1).join(', ')} or ${phrases.at(-1)}`
? `${phrases.slice(0, -1).join(', ')} or ${phrases.slice(-1)[0]}`
: phrases.join(' or ')
}

Expand Down
6 changes: 2 additions & 4 deletions lib/rules/define-emits-declaration.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,23 @@ module.exports = {
return utils.defineScriptSetupVisitor(context, {
onDefineEmitsEnter(node) {
switch (defineType) {
case 'type-based': {
case 'type-based':
if (node.arguments.length > 0) {
context.report({
node,
messageId: 'hasArg'
})
}
break
}

case 'runtime': {
case 'runtime':
if (node.typeParameters && node.typeParameters.params.length > 0) {
context.report({
node,
messageId: 'hasTypeArg'
})
}
break
}
}
}
})
Expand Down
6 changes: 2 additions & 4 deletions lib/rules/define-props-declaration.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,23 @@ module.exports = {
return utils.defineScriptSetupVisitor(context, {
onDefinePropsEnter(node) {
switch (defineType) {
case 'type-based': {
case 'type-based':
if (node.arguments.length > 0) {
context.report({
node,
messageId: 'hasArg'
})
}
break
}

case 'runtime': {
case 'runtime':
if (node.typeParameters && node.typeParameters.params.length > 0) {
context.report({
node,
messageId: 'hasTypeArg'
})
}
break
}
}
}
})
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 @@ -69,7 +69,7 @@ module.exports = {
const firstAttribute = node.attributes[0]
if (!firstAttribute) return

const lastAttribute = node.attributes.at(-1)
const lastAttribute = node.attributes[node.attributes.length - 1]

const location =
firstAttribute.loc.start.line === lastAttribute.loc.end.line
Expand Down
9 changes: 3 additions & 6 deletions lib/rules/html-closing-bracket-newline.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,12 @@ const utils = require('../utils')
*/
function getPhrase(lineBreaks) {
switch (lineBreaks) {
case 0: {
case 0:
return 'no line breaks'
}
case 1: {
case 1:
return '1 line break'
}
default: {
default:
return `${lineBreaks} line breaks`
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/rules/html-self-closing.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ function getElementType(node) {
*/
function isEmpty(node, sourceCode) {
const start = node.startTag.range[1]
const end = node.endTag == null ? node.range[1] : node.endTag.range[0]
const end = node.endTag != null ? node.endTag.range[0] : node.range[1]

return sourceCode.text.slice(start, end).trim() === ''
}
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/match-component-file-name.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

const utils = require('../utils')
const casing = require('../utils/casing')
const path = require('node:path')
const path = require('path')

/**
* @param {Expression | SpreadElement} node
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/max-attributes-per-line.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function groupAttrsByLine(attributes) {
const current = attributes[index]

if (previous.loc.end.line === current.loc.start.line) {
propsPerLine.at(-1).push(current)
propsPerLine[propsPerLine.length - 1].push(current)
} else {
propsPerLine.push([current])
}
Expand Down

0 comments on commit adf77e9

Please sign in to comment.