Skip to content

Commit

Permalink
Remove use of deprecated methods
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker committed Jul 11, 2023
1 parent 61234af commit 35fd4e5
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion rules/filename-case.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ const create = context => {
return new RegExp(item, 'u');
});
const chosenCasesFunctions = chosenCases.map(case_ => ignoreNumbers(cases[case_].fn));
const filenameWithExtension = context.getPhysicalFilename();
const filenameWithExtension = context.physicalFilename;

if (filenameWithExtension === '<input>' || filenameWithExtension === '<text>') {
return;
Expand Down
2 changes: 1 addition & 1 deletion rules/no-empty-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const hasTripeSlashDirectives = comments =>

/** @param {import('eslint').Rule.RuleContext} context */
const create = context => {
const filename = context.getPhysicalFilename();
const filename = context.physicalFilename;

if (!/\.(?:js|mjs|cjs|jsx|ts|mts|cts|tsx)$/i.test(filename)) {
return;
Expand Down
4 changes: 2 additions & 2 deletions rules/no-instanceof-array.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ const create = context => {
const {left, right} = node;
let tokenStore = sourceCode;
let instanceofToken = tokenStore.getTokenAfter(left, isInstanceofToken);
if (!instanceofToken && context.parserServices.getTemplateBodyTokenStore) {
tokenStore = context.parserServices.getTemplateBodyTokenStore();
if (!instanceofToken && sourceCode.parserServices.getTemplateBodyTokenStore) {
tokenStore = sourceCode.parserServices.getTemplateBodyTokenStore();
instanceofToken = tokenStore.getTokenAfter(left, isInstanceofToken);
}

Expand Down
2 changes: 1 addition & 1 deletion rules/no-useless-undefined.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const isFunctionBindCall = node =>
&& node.callee.property.name === 'bind';

const isTypeScriptFile = context =>
/\.(?:ts|mts|cts|tsx)$/i.test(context.getPhysicalFilename());
/\.(?:ts|mts|cts|tsx)$/i.test(context.physicalFilename);

/** @param {import('eslint').Rule.RuleContext} context */
const create = context => {
Expand Down
2 changes: 1 addition & 1 deletion rules/prefer-module.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ function fixModuleExports(node, sourceCode) {
}

function create(context) {
const filename = context.getFilename().toLowerCase();
const filename = context.filename.toLowerCase();

if (filename.endsWith('.cjs')) {
return;
Expand Down
2 changes: 1 addition & 1 deletion rules/prefer-top-level-await.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const isInPromiseMethods = node =>

/** @param {import('eslint').Rule.RuleContext} context */
function create(context) {
if (context.getFilename().toLowerCase().endsWith('.cjs')) {
if (context.filename.toLowerCase().endsWith('.cjs')) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion rules/prevent-abbreviations.js
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ const isInternalImport = node => {
/** @param {import('eslint').Rule.RuleContext} context */
const create = context => {
const options = prepareOptions(context.options[0]);
const filenameWithExtension = context.getPhysicalFilename();
const filenameWithExtension = context.physicalFilename;

// A `class` declaration produces two variables in two scopes:
// the inner class scope, and the outer one (wherever the class is declared).
Expand Down
7 changes: 4 additions & 3 deletions rules/utils/rule.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,13 @@ function checkVueTemplate(create, options) {

const wrapped = context => {
const listeners = create(context);
const {parserServices} = context.sourceCode;

// `vue-eslint-parser`
if (context.parserServices?.defineTemplateBodyVisitor) {
if (parserServices?.defineTemplateBodyVisitor) {
return visitScriptBlock
? context.parserServices.defineTemplateBodyVisitor(listeners, listeners)
: context.parserServices.defineTemplateBodyVisitor(listeners);
? parserServices.defineTemplateBodyVisitor(listeners, listeners)
: parserServices.defineTemplateBodyVisitor(listeners);
}

return listeners;
Expand Down
2 changes: 1 addition & 1 deletion scripts/internal-rules/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module.exports = {
{
...rule,
create(context) {
const filename = context.getPhysicalFilename();
const filename = context.physicalFilename;
if (directories.every(directory => !isFileInsideDirectory(filename, directory))) {
return {};
}
Expand Down

0 comments on commit 35fd4e5

Please sign in to comment.