Skip to content
Draft
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
d9ce10c
refactor: migrate `utils/comments`
9romise Jan 20, 2026
0ea53c0
utils/html-comments
9romise Jan 20, 2026
1f7e7a4
keycode-to-key
9romise Jan 20, 2026
6d400f7
regexp
9romise Jan 20, 2026
33cbb2f
style-variables
9romise Jan 20, 2026
42f319a
vue2-builtin-components
9romise Jan 20, 2026
0872b25
vue3-builtin-components
9romise Jan 20, 2026
f2dc1a0
vue-builtin-elements
9romise Jan 20, 2026
d967e45
indent-utils
9romise Jan 20, 2026
2da6f3e
casing
9romise Jan 20, 2026
25e8258
scope
9romise Jan 20, 2026
c544408
Merge branch 'master' into utils
9romise Jan 20, 2026
2597b13
cleanup comments, improve type assertion
9romise Jan 21, 2026
d136c8a
property-references
9romise Jan 21, 2026
2000ef7
typescript
9romise Jan 21, 2026
b9a146a
ts-types
9romise Jan 21, 2026
65fb66f
ts-ast
9romise Jan 21, 2026
e3badf0
ts-utils/index
9romise Jan 21, 2026
d39daa1
indent-ts
9romise Jan 21, 2026
5949fd0
indent-common
9romise Jan 21, 2026
5709082
add some comments back
9romise Jan 22, 2026
e97be7e
utils/index
9romise Jan 22, 2026
7da8353
ref-object-references
9romise Jan 22, 2026
6be22fd
selector
9romise Jan 22, 2026
6fb3374
Merge branch 'master' into utils
9romise Feb 14, 2026
d84b740
lint
9romise Feb 14, 2026
2c4dc84
fix: export getLeftOfDefineProps
9romise Feb 14, 2026
3683847
Merge branch 'master' into utils
9romise Feb 18, 2026
00c498c
wip: import `.ts`
9romise Feb 18, 2026
6e0bee5
chore: don't bundle json files
9romise Feb 18, 2026
361576f
wip: prefer named imports
9romise Feb 18, 2026
083ce3f
ci: fix test
9romise Feb 18, 2026
8f530fe
wip: prefer named import
9romise Feb 18, 2026
4b67d02
fix: use createRequire instead of require
9romise Feb 18, 2026
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
6 changes: 3 additions & 3 deletions lib/rules/attribute-hyphenation.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
'use strict'

const utils = require('../utils')
const casing = require('../utils/casing')
const { toRegExpGroupMatcher } = require('../utils/regexp')
const { getExactConverter } = require('../utils/casing.ts')
const { toRegExpGroupMatcher } = require('../utils/regexp.ts')
const svgAttributes = require('../utils/svg-attributes-weird-case.json')

/**
Expand Down Expand Up @@ -86,7 +86,7 @@ module.exports = {
ignoredAttributes.push(...optionsPayload.ignore)
}

const caseConverter = casing.getExactConverter(
const caseConverter = getExactConverter(
useHyphenated ? 'kebab-case' : 'camelCase'
)

Expand Down
6 changes: 3 additions & 3 deletions lib/rules/component-definition-name-casing.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
'use strict'

const utils = require('../utils')
const casing = require('../utils/casing')
const { getChecker, getExactConverter } = require('../utils/casing.ts')
const allowedCaseOptions = ['PascalCase', 'kebab-case']

/**
Expand Down Expand Up @@ -63,7 +63,7 @@ module.exports = {
range = node.range
}

if (!casing.getChecker(caseType)(nodeValue)) {
if (!getChecker(caseType)(nodeValue)) {
context.report({
node,
messageId: 'incorrectCase',
Expand All @@ -74,7 +74,7 @@ module.exports = {
fix: (fixer) =>
fixer.replaceTextRange(
[range[0] + 1, range[1] - 1],
casing.getExactConverter(caseType)(nodeValue)
getExactConverter(caseType)(nodeValue)
)
})
}
Expand Down
16 changes: 10 additions & 6 deletions lib/rules/component-name-in-template-casing.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@
'use strict'

const utils = require('../utils')
const casing = require('../utils/casing')
const { toRegExpGroupMatcher, isRegExp } = require('../utils/regexp')
const {
pascalCase,
getChecker,
getExactConverter
} = require('../utils/casing.ts')
const { toRegExpGroupMatcher, isRegExp } = require('../utils/regexp.ts')

const allowedCaseOptions = ['PascalCase', 'kebab-case']
const defaultCase = 'PascalCase'
Expand Down Expand Up @@ -101,7 +105,7 @@ module.exports = {
sourceCode.parserServices.getTemplateBodyTokenStore()

/** @type { Set<string> } */
const registeredComponents = new Set(globalStrings.map(casing.pascalCase))
const registeredComponents = new Set(globalStrings.map(pascalCase))

if (utils.isScriptSetup(context)) {
// For <script setup>
Expand Down Expand Up @@ -148,7 +152,7 @@ module.exports = {
}

return (
registeredComponents.has(casing.pascalCase(node.rawName)) ||
registeredComponents.has(pascalCase(node.rawName)) ||
isGlobalPattern(node.rawName)
)
}
Expand All @@ -168,10 +172,10 @@ module.exports = {
}

const name = node.rawName
if (!casing.getChecker(caseType)(name)) {
if (!getChecker(caseType)(name)) {
const startTag = node.startTag
const open = tokens.getFirstToken(startTag)
const casingName = casing.getExactConverter(caseType)(name)
const casingName = getExactConverter(caseType)(name)
context.report({
node: open,
loc: open.loc,
Expand Down
12 changes: 8 additions & 4 deletions lib/rules/component-options-name-casing.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
'use strict'

const utils = require('../utils')
const casing = require('../utils/casing')
const {
allowedCaseOptions,
getChecker,
getConverter
} = require('../utils/casing.ts')

/**
* @param {import('../../typings/eslint-plugin-vue/util-types/ast').Expression} node
Expand All @@ -32,7 +36,7 @@ module.exports = {
},
fixable: 'code',
hasSuggestions: true,
schema: [{ enum: casing.allowedCaseOptions }],
schema: [{ enum: allowedCaseOptions }],
messages: {
caseNotMatched: 'Component name "{{component}}" is not {{caseType}}.',
possibleRenaming: 'Rename component name to be in {{caseType}}.'
Expand All @@ -43,8 +47,8 @@ module.exports = {
const caseType = context.options[0] || 'PascalCase'

const canAutoFix = caseType === 'PascalCase'
const checkCase = casing.getChecker(caseType)
const convert = casing.getConverter(caseType)
const checkCase = getChecker(caseType)
const convert = getConverter(caseType)

return utils.executeOnVue(context, (obj) => {
const node = utils.findProperty(obj, 'components')
Expand Down
6 changes: 3 additions & 3 deletions lib/rules/custom-event-name-casing.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

const { findVariable } = require('@eslint-community/eslint-utils')
const utils = require('../utils')
const casing = require('../utils/casing')
const { toRegExpGroupMatcher } = require('../utils/regexp')
const { getChecker } = require('../utils/casing.ts')
const { toRegExpGroupMatcher } = require('../utils/regexp.ts')

/**
* @typedef {import('../utils').VueObjectData} VueObjectData
Expand Down Expand Up @@ -91,7 +91,7 @@ module.exports = {
let emitParamName = ''
const caseType = context.options[0] || DEFAULT_CASE
const objectOption = context.options[1] || {}
const caseChecker = casing.getChecker(caseType)
const caseChecker = getChecker(caseType)
const isIgnored = toRegExpGroupMatcher(objectOption.ignores)

/**
Expand Down
42 changes: 19 additions & 23 deletions lib/rules/html-comment-content-newline.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/
'use strict'

const htmlComments = require('../utils/html-comments')
const { defineVisitor } = require('../utils/html-comments.ts')

/**
* @typedef { import('../utils/html-comments').ParsedHTMLComment } ParsedHTMLComment
Expand Down Expand Up @@ -81,30 +81,26 @@ module.exports = {
/** @param {RuleContext} context */
create(context) {
const option = parseOption(context.options[0])
return htmlComments.defineVisitor(
context,
context.options[1],
(comment) => {
const { value, openDecoration, closeDecoration } = comment
if (!value) {
return
}
return defineVisitor(context, context.options[1], (comment) => {
const { value, openDecoration, closeDecoration } = comment
if (!value) {
return
}

const startLine = openDecoration
? openDecoration.loc.end.line
: value.loc.start.line
const endLine = closeDecoration
? closeDecoration.loc.start.line
: value.loc.end.line
const newlineType =
startLine === endLine ? option.singleline : option.multiline
if (newlineType === 'ignore') {
return
}
checkCommentOpen(comment, newlineType !== 'never')
checkCommentClose(comment, newlineType !== 'never')
const startLine = openDecoration
? openDecoration.loc.end.line
: value.loc.start.line
const endLine = closeDecoration
? closeDecoration.loc.start.line
: value.loc.end.line
const newlineType =
startLine === endLine ? option.singleline : option.multiline
if (newlineType === 'ignore') {
return
}
)
checkCommentOpen(comment, newlineType !== 'never')
checkCommentClose(comment, newlineType !== 'never')
})

/**
* Reports the newline before the contents of a given comment if it's invalid.
Expand Down
4 changes: 2 additions & 2 deletions lib/rules/html-comment-content-spacing.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/
'use strict'

const htmlComments = require('../utils/html-comments')
const { defineVisitor } = require('../utils/html-comments.ts')

/**
* @typedef { import('../utils/html-comments').ParsedHTMLComment } ParsedHTMLComment
Expand Down Expand Up @@ -50,7 +50,7 @@ module.exports = {
create(context) {
// Unless the first option is never, require a space
const requireSpace = context.options[0] !== 'never'
return htmlComments.defineVisitor(
return defineVisitor(
context,
context.options[1],
(comment) => {
Expand Down
4 changes: 2 additions & 2 deletions lib/rules/html-comment-indent.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/
'use strict'

const htmlComments = require('../utils/html-comments')
const { defineVisitor } = require('../utils/html-comments.ts')

/**
* Normalize options.
Expand Down Expand Up @@ -88,7 +88,7 @@ module.exports = {
create(context) {
const options = parseOptions(context.options[0])
const sourceCode = context.sourceCode
return htmlComments.defineVisitor(
return defineVisitor(
context,
null,
(comment) => {
Expand Down
4 changes: 2 additions & 2 deletions lib/rules/html-indent.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
'use strict'

const indentCommon = require('../utils/indent-common')
const { defineVisitor } = require('../utils/indent-common.ts')
const utils = require('../utils')

module.exports = {
Expand All @@ -15,7 +15,7 @@ module.exports = {
const tokenStore =
sourceCode.parserServices.getTemplateBodyTokenStore &&
sourceCode.parserServices.getTemplateBodyTokenStore()
const visitor = indentCommon.defineVisitor(context, tokenStore, {
const visitor = defineVisitor(context, tokenStore, {
baseIndent: 1
})

Expand Down
7 changes: 2 additions & 5 deletions lib/rules/match-component-file-name.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
'use strict'

const utils = require('../utils')
const casing = require('../utils/casing')
const { pascalCase, kebabCase } = require('../utils/casing.ts')
const path = require('node:path')

/**
Expand Down Expand Up @@ -84,10 +84,7 @@ module.exports = {
return name === filename
}

return (
casing.pascalCase(name) === filename ||
casing.kebabCase(name) === filename
)
return pascalCase(name) === filename || kebabCase(name) === filename
}

/**
Expand Down
4 changes: 2 additions & 2 deletions lib/rules/match-component-import-name.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
'use strict'

const utils = require('../utils')
const casing = require('../utils/casing')
const { pascalCase, kebabCase } = require('../utils/casing.ts')

/**
* @param {Identifier} identifier
* @return {Array<String>}
*/
function getExpectedNames(identifier) {
return [casing.pascalCase(identifier.name), casing.kebabCase(identifier.name)]
return [pascalCase(identifier.name), kebabCase(identifier.name)]
}

module.exports = {
Expand Down
10 changes: 5 additions & 5 deletions lib/rules/multi-word-component-names.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
'use strict'

const path = require('node:path')
const casing = require('../utils/casing')
const { isPascalCase, kebabCase } = require('../utils/casing.ts')
const utils = require('../utils')

const RESERVED_NAMES_IN_VUE3 = new Set(
require('../utils/vue3-builtin-components')
require('../utils/vue3-builtin-components.ts').default
)

module.exports = {
Expand Down Expand Up @@ -45,9 +45,9 @@ module.exports = {
for (const ignore of (context.options[0] && context.options[0].ignores) ||
[]) {
ignores.add(ignore)
if (casing.isPascalCase(ignore)) {
if (isPascalCase(ignore)) {
// PascalCase
ignores.add(casing.kebabCase(ignore))
ignores.add(kebabCase(ignore))
}
}
let hasVue = utils.isScriptSetup(context)
Expand All @@ -61,7 +61,7 @@ module.exports = {
if (ignores.has(name) || RESERVED_NAMES_IN_VUE3.has(name)) {
return true
}
const elements = casing.kebabCase(name).split('-')
const elements = kebabCase(name).split('-')
return elements.length > 1
}

Expand Down
6 changes: 3 additions & 3 deletions lib/rules/multiline-html-element-content-newline.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
'use strict'

const utils = require('../utils')
const casing = require('../utils/casing')
const { pascalCase, kebabCase } = require('../utils/casing.ts')
const INLINE_ELEMENTS = require('../utils/inline-non-void-elements.json')

/**
Expand Down Expand Up @@ -112,8 +112,8 @@ module.exports = {
function isIgnoredElement(node) {
return (
ignores.includes(node.name) ||
ignores.includes(casing.pascalCase(node.rawName)) ||
ignores.includes(casing.kebabCase(node.rawName))
ignores.includes(pascalCase(node.rawName)) ||
ignores.includes(kebabCase(node.rawName))
)
}

Expand Down
8 changes: 4 additions & 4 deletions lib/rules/no-bare-strings-in-template.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
'use strict'

const utils = require('../utils')
const regexp = require('../utils/regexp')
const casing = require('../utils/casing')
const regexp = require('../utils/regexp.ts')
const { isKebabCase, pascalCase } = require('../utils/casing.ts')

/**
* @typedef { { names: { [tagName in string]: Set<string> }, regexps: { name: RegExp, attrs: Set<string> }[], cache: { [tagName in string]: Set<string> } } } TargetAttrs
Expand Down Expand Up @@ -221,8 +221,8 @@ module.exports = {
result.push(...attrs)
}
}
if (casing.isKebabCase(tagName)) {
result.push(...getTargetAttrs(casing.pascalCase(tagName)))
if (isKebabCase(tagName)) {
result.push(...getTargetAttrs(pascalCase(tagName)))
}

return (attributes.cache[tagName] = new Set(result))
Expand Down
6 changes: 3 additions & 3 deletions lib/rules/no-deprecated-router-link-tag-prop.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
'use strict'

const utils = require('../utils')
const casing = require('../utils/casing')
const { kebabCase, pascalCase } = require('../utils/casing.ts')

/** @param {RuleContext} context */
function getComponentNames(context) {
Expand All @@ -17,8 +17,8 @@ function getComponentNames(context) {

return new Set(
components.flatMap((component) => [
casing.kebabCase(component),
casing.pascalCase(component)
kebabCase(component),
pascalCase(component)
])
)
}
Expand Down
Loading
Loading