Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

Add noImportAssign lint rule #118

Merged
merged 4 commits into from
Mar 3, 2020
Merged

Conversation

emmatown
Copy link
Contributor

@emmatown emmatown commented Mar 3, 2020

I've excluded something that the ESLint rule does which is handling cases like this:

import * as x from 'y';
x.something = true;

because from #20 (comment) I got the impression that these linting rules are intended to be rules that can be reliably checked without a type system and cases similar to the above can't be. I'm happy to add the cases that ESLint supports if that's what people want.

((node.type === 'AssignmentIdentifier' && isAssignment(path)) ||
(node.type === 'ReferenceIdentifier' &&
path.parentPath.node.type === 'UpdateExpression')) &&
scope.getBindingAssert(node.name).kind === 'import'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getBindingAssert likely isn't the right call here. Setting a property on a known global shouldn't trigger this, which would be the case since getBinding doesn't return anything. Could you change this to getBinding and check the result for undefined? Other than that, looks good!

@sebmck sebmck mentioned this pull request Mar 3, 2020
27 tasks
@sebmck sebmck merged commit 105fd77 into rome:master Mar 3, 2020
@sebmck
Copy link
Contributor

sebmck commented Mar 3, 2020

Thank you!

@emmatown emmatown deleted the add-no-import-assign branch March 3, 2020 23:37
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants