Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion lib/rules/attribute-hyphenation.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ module.exports = {
},
/** @param {RuleContext} context */
create(context) {
const sourceCode = context.getSourceCode()
const sourceCode = context.sourceCode
const option = context.options[0]
const optionsPayload = context.options[1]
const useHyphenated = option !== 'never'
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/attributes-order.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ function isAlphabetical(prevNode, currNode, sourceCode) {
* @returns {RuleListener} AST event handlers.
*/
function create(context) {
const sourceCode = context.getSourceCode()
const sourceCode = context.sourceCode
const otherAttrs = [
ATTRS.ATTR_DYNAMIC,
ATTRS.ATTR_STATIC,
Expand Down
3 changes: 1 addition & 2 deletions lib/rules/block-order.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ module.exports = {
function getOrderElement(element) {
return orders.find((o) => o.selector.test(element))
}
const sourceCode = context.getSourceCode()
const sourceCode = context.sourceCode
const documentFragment =
sourceCode.parserServices.getDocumentFragment &&
sourceCode.parserServices.getDocumentFragment()
Expand All @@ -129,7 +129,6 @@ module.exports = {
const order = getOrderElement(element)
return order ? [{ order, element }] : []
})
const sourceCode = context.getSourceCode()
for (const [index, elementWithOrders] of elementsWithOrder.entries()) {
const { order: expected, element } = elementWithOrders
const firstUnordered = elementsWithOrder
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/block-tag-newline.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ module.exports = {
},
/** @param {RuleContext} context */
create(context) {
const sourceCode = context.getSourceCode()
const sourceCode = context.sourceCode
const df =
sourceCode.parserServices.getDocumentFragment &&
sourceCode.parserServices.getDocumentFragment()
Expand Down
4 changes: 2 additions & 2 deletions lib/rules/comment-directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ function reportUnused(context, comment, kind) {
* @returns { { ruleId: string, key: string }[] }
*/
function reportUnusedRules(context, comment, kind, rules) {
const sourceCode = context.getSourceCode()
const sourceCode = context.sourceCode
const commentStart = comment.range[0] + 4 /* <!-- */

return rules.map((rule) => {
Expand Down Expand Up @@ -313,7 +313,7 @@ module.exports = {
const options = context.options[0] || {}
/** @type {boolean} */
const reportUnusedDisableDirectives = options.reportUnusedDisableDirectives
const sourceCode = context.getSourceCode()
const sourceCode = context.sourceCode
const documentFragment =
sourceCode.parserServices.getDocumentFragment &&
sourceCode.parserServices.getDocumentFragment()
Expand Down
4 changes: 2 additions & 2 deletions lib/rules/component-name-in-template-casing.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ module.exports = {

const isGlobalPattern = toRegExpGroupMatcher(globalPatterns)
const registeredComponentsOnly = options.registeredComponentsOnly !== false
const sourceCode = context.getSourceCode()
const sourceCode = context.sourceCode
const tokens =
sourceCode.parserServices.getTemplateBodyTokenStore &&
sourceCode.parserServices.getTemplateBodyTokenStore()
Expand All @@ -105,7 +105,7 @@ module.exports = {

if (utils.isScriptSetup(context)) {
// For <script setup>
const globalScope = context.getSourceCode().scopeManager.globalScope
const globalScope = context.sourceCode.scopeManager.globalScope
if (globalScope) {
// Only check find the import module
const moduleScope = globalScope.childScopes.find(
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/custom-event-name-casing.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ module.exports = {
})
}

const programNode = context.getSourceCode().ast
const programNode = context.sourceCode.ast

const callVisitor = {
/**
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/define-macros-order.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ function create(context) {
return {}
}

const sourceCode = context.getSourceCode()
const sourceCode = context.sourceCode
const options = context.options
/** @type {[string, string]} */
const order = (options[0] && options[0].order) || DEFAULT_ORDER
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/enforce-style-attribute.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ module.exports = {

/** @param {RuleContext} context */
create(context) {
const sourceCode = context.getSourceCode()
const sourceCode = context.sourceCode
if (!sourceCode.parserServices.getDocumentFragment) {
return {}
}
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 @@ -39,7 +39,7 @@ module.exports = {
const multiline =
(context.options[0] && context.options[0].multiline) || 'below'

const sourceCode = context.getSourceCode()
const sourceCode = context.sourceCode
const template =
sourceCode.parserServices.getTemplateBodyTokenStore &&
sourceCode.parserServices.getTemplateBodyTokenStore()
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/html-closing-bracket-newline.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ module.exports = {
},
context.options[0] || {}
)
const sourceCode = context.getSourceCode()
const sourceCode = context.sourceCode
const template =
sourceCode.parserServices.getTemplateBodyTokenStore &&
sourceCode.parserServices.getTemplateBodyTokenStore()
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/html-closing-bracket-spacing.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ module.exports = {
},
/** @param {RuleContext} context */
create(context) {
const sourceCode = context.getSourceCode()
const sourceCode = context.sourceCode
const tokens =
sourceCode.parserServices.getTemplateBodyTokenStore &&
sourceCode.parserServices.getTemplateBodyTokenStore()
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/html-comment-indent.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ module.exports = {
/** @param {RuleContext} context */
create(context) {
const options = parseOptions(context.options[0])
const sourceCode = context.getSourceCode()
const sourceCode = context.sourceCode
return htmlComments.defineVisitor(
context,
null,
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/html-indent.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const utils = require('../utils')
module.exports = {
/** @param {RuleContext} context */
create(context) {
const sourceCode = context.getSourceCode()
const sourceCode = context.sourceCode
const tokenStore =
sourceCode.parserServices.getTemplateBodyTokenStore &&
sourceCode.parserServices.getTemplateBodyTokenStore()
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/html-quotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ module.exports = {
},
/** @param {RuleContext} context */
create(context) {
const sourceCode = context.getSourceCode()
const sourceCode = context.sourceCode
const double = context.options[0] !== 'single'
const avoidEscape =
context.options[1] && context.options[1].avoidEscape === true
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 @@ -129,7 +129,7 @@ module.exports = {
},
/** @param {RuleContext} context */
create(context) {
const sourceCode = context.getSourceCode()
const sourceCode = context.sourceCode
const options = parseOptions(context.options[0])
let hasInvalidEOF = false

Expand Down
4 changes: 1 addition & 3 deletions lib/rules/jsx-uses-vars.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ SOFTWARE.
*/
'use strict'

const utils = require('../utils')

module.exports = {
// eslint-disable-next-line eslint-plugin/prefer-message-ids
meta: {
Expand Down Expand Up @@ -65,7 +63,7 @@ module.exports = {
return
}

utils.markVariableAsUsed(context, name, node)
context.sourceCode.markVariableAsUsed(name, node)
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions lib/rules/match-component-file-name.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ module.exports = {
? extensionsArray
: ['jsx']

const extension = path.extname(context.getFilename())
const filename = path.basename(context.getFilename(), extension)
const extension = path.extname(context.filename)
const filename = path.basename(context.filename, extension)

/** @type {Rule.ReportDescriptor[]} */
const errors = []
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 @@ -119,7 +119,7 @@ module.exports = {
},
/** @param {RuleContext} context */
create(context) {
const sourceCode = context.getSourceCode()
const sourceCode = context.sourceCode
const configuration = parseOptions(context.options[0])
const multilineMaximum = configuration.multiline
const singlelinemMaximum = configuration.singleline
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/max-len.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ module.exports = {
*/
const URL_REGEXP = /[^:/?#]:\/\/[^?#]/u

const sourceCode = context.getSourceCode()
const sourceCode = context.sourceCode
/** @type {Token[]} */
const tokens = []
/** @type {(HTMLComment | HTMLBogusComment | Comment)[]} */
Expand Down
5 changes: 2 additions & 3 deletions lib/rules/max-lines-per-block.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ module.exports = {
style: option.style
}

const code = context.getSourceCode()
const sourceCode = context.getSourceCode()
const sourceCode = context.sourceCode
const documentFragment =
sourceCode.parserServices.getDocumentFragment &&
sourceCode.parserServices.getDocumentFragment()
Expand All @@ -89,7 +88,7 @@ module.exports = {
let lineCount = block.loc.end.line - block.loc.start.line - 1

if (option.skipBlankLines) {
const lines = SourceCode.splitLines(code.getText(block))
const lines = SourceCode.splitLines(sourceCode.getText(block))
lineCount -= lines.filter(isEmptyLine).length
}

Expand Down
2 changes: 1 addition & 1 deletion lib/rules/multi-word-component-names.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ module.exports = {
'Program:exit'(node) {
if (hasName) return
if (!hasVue && node.body.length > 0) return
const fileName = context.getFilename()
const fileName = context.filename
const componentName = path.basename(fileName, path.extname(fileName))
if (
utils.isVueFile(fileName) &&
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/multiline-html-element-content-newline.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ module.exports = {
const ignores = options.ignores
const ignoreWhenEmpty = options.ignoreWhenEmpty
const allowEmptyLines = options.allowEmptyLines
const sourceCode = context.getSourceCode()
const sourceCode = context.sourceCode
const template =
sourceCode.parserServices.getTemplateBodyTokenStore &&
sourceCode.parserServices.getTemplateBodyTokenStore()
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/mustache-interpolation-spacing.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ module.exports = {
/** @param {RuleContext} context */
create(context) {
const options = context.options[0] || 'always'
const sourceCode = context.getSourceCode()
const sourceCode = context.sourceCode
const template =
sourceCode.parserServices.getTemplateBodyTokenStore &&
sourceCode.parserServices.getTemplateBodyTokenStore()
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/new-line-between-multi-line-property.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ module.exports = {

/** @type {CallExpression[]} */
const callStack = []
const sourceCode = context.getSourceCode()
const sourceCode = context.sourceCode
return Object.assign(
utils.defineVueVisitor(context, {
CallExpression(node) {
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-child-content.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ module.exports = {
if (elementNode.endTag === null) {
return
}
const sourceCode = context.getSourceCode()
const sourceCode = context.sourceCode
const tokenStore = sourceCode.parserServices.getTemplateBodyTokenStore()
const elementComments = tokenStore.getTokensBetween(
elementNode.startTag,
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-deprecated-data-object-declaration.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ module.exports = {
},
/** @param {RuleContext} context */
create(context) {
const sourceCode = context.getSourceCode()
const sourceCode = context.sourceCode

return utils.executeOnVue(context, (obj) => {
const invalidData = utils.findProperty(
Expand Down
4 changes: 1 addition & 3 deletions lib/rules/no-deprecated-v-bind-sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ module.exports = {
return null
}

const bindArgument = context
.getSourceCode()
.getText(node.key.argument)
const bindArgument = context.sourceCode.getText(node.key.argument)
return fixer.replaceText(node.key, `v-model:${bindArgument}`)
}
})
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-dupe-v-else-if.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ module.exports = {
},
/** @param {RuleContext} context */
create(context) {
const sourceCode = context.getSourceCode()
const sourceCode = context.sourceCode
const tokenStore =
sourceCode.parserServices.getTemplateBodyTokenStore &&
sourceCode.parserServices.getTemplateBodyTokenStore()
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-duplicate-class-names.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ module.exports = {
plural: duplicates.size > 1 ? 's' : ''
},
fix: (fixer) => {
const sourceCode = context.getSourceCode()
const sourceCode = context.sourceCode
const raw = sourceCode.text.slice(node.range[0], node.range[1])
return fixer.replaceText(node, removeDuplicateClassNames(raw))
}
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-empty-component-block.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ module.exports = {
* @returns {RuleListener} AST event handlers.
*/
create(context) {
const sourceCode = context.getSourceCode()
const sourceCode = context.sourceCode
if (!sourceCode.parserServices.getDocumentFragment) {
return {}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-export-in-script-setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ module.exports = {
ExportNamedDeclaration: (node) => {
// export let foo = 'foo', export class Foo {}, export function foo() {}
if (node.declaration) {
verify(node, context.getSourceCode().getFirstToken(node).loc)
verify(node, context.sourceCode.getFirstToken(node).loc)
}
// export { foo }, export { foo } from 'bar'
else {
Expand Down
4 changes: 2 additions & 2 deletions lib/rules/no-extra-parens.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function isIIFE(node) {
* @returns {TemplateListener} AST event handlers.
*/
function createForVueSyntax(context) {
const sourceCode = context.getSourceCode()
const sourceCode = context.sourceCode
if (!sourceCode.parserServices.getTemplateBodyTokenStore) {
return {}
}
Expand Down Expand Up @@ -175,7 +175,7 @@ function createForVueSyntax(context) {
* @private
*/
function report(node) {
const sourceCode = context.getSourceCode()
const sourceCode = context.sourceCode
const leftParenToken = tokenStore.getTokenBefore(node)
const rightParenToken = tokenStore.getTokenAfter(node)

Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-import-compiler-macros.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ module.exports = {
* @returns {RuleListener}
*/
create(context) {
const sourceCode = context.getSourceCode()
const sourceCode = context.sourceCode

return {
ImportDeclaration(node) {
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-irregular-whitespace.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ module.exports = {
const skipHTMLAttributeValues = !!options.skipHTMLAttributeValues
const skipHTMLTextContents = !!options.skipHTMLTextContents

const sourceCode = context.getSourceCode()
const sourceCode = context.sourceCode

/**
* Removes errors that occur inside a string node
Expand Down
6 changes: 3 additions & 3 deletions lib/rules/no-multi-spaces.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const path = require('path')
* @param {Token} node
*/
const isProperty = (context, node) => {
const sourceCode = context.getSourceCode()
const sourceCode = context.sourceCode
return node.type === 'Punctuator' && sourceCode.getText(node) === ':'
}

Expand Down Expand Up @@ -52,9 +52,9 @@ module.exports = {

return {
Program(node) {
const sourceCode = context.getSourceCode()
const sourceCode = context.sourceCode
if (sourceCode.parserServices.getTemplateBodyTokenStore == null) {
const filename = context.getFilename()
const filename = context.filename
if (path.extname(filename) === '.vue') {
context.report({
loc: { line: 1, column: 0 },
Expand Down
Loading
Loading