Skip to content

Commit

Permalink
refactor: deprecated method
Browse files Browse the repository at this point in the history
  • Loading branch information
mshanemc committed Dec 13, 2023
1 parent e886ec9 commit 058b380
Show file tree
Hide file tree
Showing 13 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/rules/esm-message-import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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' &&
Expand Down
2 changes: 1 addition & 1 deletion src/rules/id-flag-suggestions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,');
Expand Down
4 changes: 2 additions & 2 deletions src/rules/migration/no-this-flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/rules/migration/no-this-org.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/rules/migration/no-this-ux.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)}`),
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/rules/migration/no-time-flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}',`)
Expand Down
2 changes: 1 addition & 1 deletion src/rules/migration/no-username-properties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/rules/migration/should-parse-flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/rules/no-execCmd-double-quotes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
4 changes: 2 additions & 2 deletions src/rules/no-oclif-flags-command-import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/rules/no-unnecessary-aliases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/rules/read-only-properties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion src/rules/run-matches-class-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]);

Expand Down

0 comments on commit 058b380

Please sign in to comment.