From 058b380e264e386c9131594c089356da3c1d3f20 Mon Sep 17 00:00:00 2001 From: mshanemc Date: Wed, 13 Dec 2023 10:23:13 -0600 Subject: [PATCH] refactor: deprecated method --- src/rules/esm-message-import.ts | 4 ++-- src/rules/id-flag-suggestions.ts | 2 +- src/rules/migration/no-this-flags.ts | 4 ++-- src/rules/migration/no-this-org.ts | 4 ++-- src/rules/migration/no-this-ux.ts | 2 +- src/rules/migration/no-time-flags.ts | 2 +- src/rules/migration/no-username-properties.ts | 2 +- src/rules/migration/should-parse-flags.ts | 2 +- src/rules/no-execCmd-double-quotes.ts | 2 +- src/rules/no-oclif-flags-command-import.ts | 4 ++-- src/rules/no-unnecessary-aliases.ts | 2 +- src/rules/read-only-properties.ts | 2 +- src/rules/run-matches-class-type.ts | 2 +- 13 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/rules/esm-message-import.ts b/src/rules/esm-message-import.ts index 23c27597..2cbefa0d 100644 --- a/src/rules/esm-message-import.ts +++ b/src/rules/esm-message-import.ts @@ -33,7 +33,7 @@ export const esmMessageImport = RuleCreator.withoutDocs({ node.property.type === AST_NODE_TYPES.Identifier && node.property.name === 'importMessagesDirectory' && node.parent?.parent && - context.getSourceCode().getText(node.parent.parent).includes('dirname(fileURLToPath(import.meta.url))') + context.sourceCode.getText(node.parent.parent).includes('dirname(fileURLToPath(import.meta.url))') ) { const toReplace = node.parent.parent; // we never found the message at all, we can report and exit @@ -46,7 +46,7 @@ export const esmMessageImport = RuleCreator.withoutDocs({ } }, ImportDeclaration(node): void { - const allCode = context.getSourceCode().getText(); + const allCode = context.sourceCode.getText(); // true for all cases if ( ((node.source.value === 'node:url' && diff --git a/src/rules/id-flag-suggestions.ts b/src/rules/id-flag-suggestions.ts index fda55214..812e7c48 100644 --- a/src/rules/id-flag-suggestions.ts +++ b/src/rules/id-flag-suggestions.ts @@ -48,7 +48,7 @@ export const idFlagSuggestions = RuleCreator.withoutDocs({ const hasLength = argProps.some((property) => flagPropertyIsNamed(property, 'length')); if (!hasStartsWith || !hasLength) { - const existing = context.getSourceCode().getText(node); + const existing = context.sourceCode.getText(node); const fixedStartsWith = existing.replace('salesforceId({', "salesforceId({startsWith: '000',"); const fixer15 = existing.replace('salesforceId({', 'salesforceId({length: 15,'); const fixer18 = existing.replace('salesforceId({', 'salesforceId({length: 18,'); diff --git a/src/rules/migration/no-this-flags.ts b/src/rules/migration/no-this-flags.ts index 45b82cd4..1d776a12 100644 --- a/src/rules/migration/no-this-flags.ts +++ b/src/rules/migration/no-this-flags.ts @@ -62,10 +62,10 @@ export const noThisFlags = RuleCreator.withoutDocs({ ? runMethod.value.body?.body.find( (b) => b.type === AST_NODE_TYPES.VariableDeclaration && - context.getSourceCode().getText(b).includes('this.parse') + context.sourceCode.getText(b).includes('this.parse') ) : undefined; - const source = context.getSourceCode().getText(); + const source = context.sourceCode.getText(); if (!source.includes('this.flags = ') && flagsParse) { context.report({ node, diff --git a/src/rules/migration/no-this-org.ts b/src/rules/migration/no-this-org.ts index 433c10cc..c0e2fb48 100644 --- a/src/rules/migration/no-this-org.ts +++ b/src/rules/migration/no-this-org.ts @@ -55,9 +55,9 @@ export const noThisOrg = RuleCreator.withoutDocs({ runMethod?.type === AST_NODE_TYPES.MethodDefinition ? runMethod.value.body?.body .filter(ASTUtils.isNodeOfType(AST_NODE_TYPES.VariableDeclaration)) - .find((b) => context.getSourceCode().getText(b).includes('this.parse')) + .find((b) => context.sourceCode.getText(b).includes('this.parse')) : undefined; - const source = context.getSourceCode().getText(); + const source = context.sourceCode.getText(); if (flagsParse && !source.includes('this.org = ')) { context.report({ node, diff --git a/src/rules/migration/no-this-ux.ts b/src/rules/migration/no-this-ux.ts index 07634075..9baa3fad 100644 --- a/src/rules/migration/no-this-ux.ts +++ b/src/rules/migration/no-this-ux.ts @@ -63,7 +63,7 @@ export const noThisUx = RuleCreator.withoutDocs({ context.report({ node, messageId: 'message', - fix: (fixer) => fixer.replaceText(toRemove, `this.${context.getSourceCode().getText(node.property)}`), + fix: (fixer) => fixer.replaceText(toRemove, `this.${context.sourceCode.getText(node.property)}`), }); } } diff --git a/src/rules/migration/no-time-flags.ts b/src/rules/migration/no-time-flags.ts index ccc5703d..ca274adf 100644 --- a/src/rules/migration/no-time-flags.ts +++ b/src/rules/migration/no-time-flags.ts @@ -37,7 +37,7 @@ export const noTimeFlags = RuleCreator.withoutDocs({ node.value.callee.property.type === AST_NODE_TYPES.Identifier && timeFlags.includes(node.value.callee.property.name) ) { - const original = context.getSourceCode().getText(node); + const original = context.sourceCode.getText(node); const unit = node.value.callee.property.name; const fixed = original .replace(`Flags.${unit}({`, `Flags.duration({ unit: '${unit}',`) diff --git a/src/rules/migration/no-username-properties.ts b/src/rules/migration/no-username-properties.ts index 172a5d41..e1a79bfe 100644 --- a/src/rules/migration/no-username-properties.ts +++ b/src/rules/migration/no-username-properties.ts @@ -70,7 +70,7 @@ export const noUsernameProperties = RuleCreator.withoutDocs({ // ensure the import exists const ancestors = context.getAncestors(); - const source = context.getSourceCode(); + const source = context.sourceCode; const importDeclaration = getSfImportFromProgram(ancestors[0]); if (importDeclaration && !source.getText(importDeclaration).includes(mappedMetadata.flag)) { const fixedImport = source diff --git a/src/rules/migration/should-parse-flags.ts b/src/rules/migration/should-parse-flags.ts index be4927ab..e53e2c6c 100644 --- a/src/rules/migration/should-parse-flags.ts +++ b/src/rules/migration/should-parse-flags.ts @@ -36,7 +36,7 @@ export const shouldParseFlags = RuleCreator.withoutDocs({ classDeclaration?.body?.body?.some((prop) => isFlagsStaticProperty(prop)) ) { // get the text for the two nodes - const sourceCode = context.getSourceCode(); + const sourceCode = context.sourceCode; const runBody = sourceCode.getText(node.value.body); const className = classDeclaration.id?.name; diff --git a/src/rules/no-execCmd-double-quotes.ts b/src/rules/no-execCmd-double-quotes.ts index 009935e3..57642cd2 100644 --- a/src/rules/no-execCmd-double-quotes.ts +++ b/src/rules/no-execCmd-double-quotes.ts @@ -37,7 +37,7 @@ export const noExecCmdDoubleQuotes = RuleCreator.withoutDocs({ messageId: 'message', }); } else if (node.arguments[0].type === AST_NODE_TYPES.TemplateLiteral) { - const source = context.getSourceCode().getText(node.arguments[0]); + const source = context.sourceCode.getText(node.arguments[0]); if (source.includes('"')) context.report({ node: node.arguments[0], diff --git a/src/rules/no-oclif-flags-command-import.ts b/src/rules/no-oclif-flags-command-import.ts index dee28d71..e3349626 100644 --- a/src/rules/no-oclif-flags-command-import.ts +++ b/src/rules/no-oclif-flags-command-import.ts @@ -34,7 +34,7 @@ export const noOclifFlagsCommandImport = RuleCreator.withoutDocs({ node: specifier, messageId: 'flags', fix: (fixer) => { - const comma = context.getSourceCode().getTokenAfter(specifier); + const comma = context.sourceCode.getTokenAfter(specifier); return comma?.value === ',' ? fixer.removeRange([specifier.range[0], specifier.range[1] + 1]) : fixer.remove(specifier); @@ -46,7 +46,7 @@ export const noOclifFlagsCommandImport = RuleCreator.withoutDocs({ node: specifier, messageId: 'command', fix: (fixer) => { - const comma = context.getSourceCode().getTokenAfter(specifier); + const comma = context.sourceCode.getTokenAfter(specifier); return comma?.value === ',' ? fixer.removeRange([specifier.range[0], specifier.range[1] + 1]) : fixer.remove(specifier); diff --git a/src/rules/no-unnecessary-aliases.ts b/src/rules/no-unnecessary-aliases.ts index f7303d73..3fcde16d 100644 --- a/src/rules/no-unnecessary-aliases.ts +++ b/src/rules/no-unnecessary-aliases.ts @@ -47,7 +47,7 @@ export const noUnnecessaryAliases = RuleCreator.withoutDocs({ node, messageId: 'summary', fix: (fixer) => { - const comma = context.getSourceCode().getTokenAfter(node); + const comma = context.sourceCode.getTokenAfter(node); if (parentLength === 1 && node.parent?.parent) { return fixer.remove(node.parent.parent); } diff --git a/src/rules/read-only-properties.ts b/src/rules/read-only-properties.ts index e9cae87e..d0dcd8cf 100644 --- a/src/rules/read-only-properties.ts +++ b/src/rules/read-only-properties.ts @@ -45,7 +45,7 @@ export const readOnlyProperties = RuleCreator.withoutDocs({ fix: (fixer) => fixer.insertTextBefore(node.key, 'readonly '), }); } else if (node.accessibility && node.accessibility !== 'public') { - const replacementText = context.getSourceCode().getText(node).replace(node.accessibility, 'public'); + const replacementText = context.sourceCode.getText(node).replace(node.accessibility, 'public'); context.report({ node, messageId: 'public', diff --git a/src/rules/run-matches-class-type.ts b/src/rules/run-matches-class-type.ts index 7224cb46..406475dd 100644 --- a/src/rules/run-matches-class-type.ts +++ b/src/rules/run-matches-class-type.ts @@ -35,7 +35,7 @@ export const runMatchesClassType = RuleCreator.withoutDocs({ if (classDeclaration) { // get the text for the two nodes - const sourceCode = context.getSourceCode(); + const sourceCode = context.sourceCode; const runType = sourceCode.getText(node.value.returnType?.typeAnnotation.typeParameters?.params[0]); const classType = sourceCode.getText(classDeclaration.superTypeParameters?.params[0]);