Skip to content

Commit

Permalink
fix(lint): fix Literal import processing & update eslint 9.11.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ala-n committed Sep 26, 2024
1 parent 1dc1707 commit 3345564
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 19 deletions.
4 changes: 3 additions & 1 deletion eslint/src/core/deprecated-alias.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function buildRule({deprecation, alias}: ESLintDeprecationCfg): Rule.Rule
const create = (context: Rule.RuleContext): Rule.RuleListener => ({
ImportSpecifier(node: ImportNode): null {
const importedValue = node.imported;
if (importedValue.name === deprecation) {
if (importedValue.type === 'Identifier' && importedValue.name === deprecation) {
context.report({
node,
message: `[ESL Lint]: Deprecated alias ${deprecation} for ${alias}`,
Expand Down Expand Up @@ -61,6 +61,8 @@ function buildFixer(node: ImportNode, context: Rule.RuleContext, alias: string):
// eslint-disable-next-line sonarjs/cognitive-complexity
function getIdentifierRanges(importNode: ImportNode, context: Rule.RuleContext): (AST.Range | undefined)[] {
const root = findRoot(importNode);
if (importNode.imported.type !== 'Identifier' || !root) return [];

const {name} = importNode.imported;
const identifiers = findAllBy(context, root, {type: 'Identifier', name});

Expand Down
2 changes: 2 additions & 0 deletions eslint/src/core/deprecated-path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ export function buildRule(configs: ESLintDeprecationImportCfg | ESLintDeprecatio
const create = (context: Rule.RuleContext): Rule.RuleListener => ({
ImportSpecifier(node: ImportNode): null {
const importedValue = node.imported;
if (importedValue.type !== 'Identifier') return null;

const importedSource = (node.parent as ESTree.ImportDeclaration).source.value;

for (const cfg of configs) {
Expand Down
36 changes: 19 additions & 17 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
"concurrently": "^9.0.1",
"copyfiles": "^2.4.1",
"cross-env": "^7.0.3",
"eslint": "^9.11.0",
"eslint": "^9.11.1",
"eslint-plugin-editorconfig": "^4.0.3",
"eslint-plugin-import-x": "^4.3.0",
"eslint-plugin-sonarjs": "^1.0.4",
Expand Down

0 comments on commit 3345564

Please sign in to comment.