Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Generic Import Callback] Make callback for all import once in rules #1237

Merged
merged 1 commit into from
Jan 23, 2021

Conversation

ljqx
Copy link
Contributor

@ljqx ljqx commented Nov 19, 2018

This PR fixes #1230.

Not only for import/extensions, this PR also adds supports of all

  1. ImportDeclaration,
  2. ExportNamedDeclaration,
  3. ExportAllDeclaration,
  4. static require CallExpression

for rules import/extensions, import/max-dependencies, import/no-extraneous-dependencies, import/no-internal-modules, import/no-nodejs-modules, import/no-restricted-paths, import/no-self-import, import/no-webpack-loader-syntax by abstracting out the common part for these callbacks.

Tests are added for import/extensions.

lastNode = node.source
},

CallExpression(node) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

here this PR changes the behavior, but according to the code, it should be a hidden bug and this change fixes it

@coveralls
Copy link

coveralls commented Nov 19, 2018

Coverage Status

Coverage increased (+0.03%) to 97.986% when pulling 93e060f on ljqx:generic-import-callback into 2ae68c1 on benmosher:master.

@ljqx
Copy link
Contributor Author

ljqx commented Nov 19, 2018

Coverage check fails because this PR reduces sources lines, though uncovered lines don't increase...

CallExpression = noop,
} = allCallbacks

return Object.assign({}, allCallbacks, {
Copy link
Member

Choose a reason for hiding this comment

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

can this use object spread?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, but we need add the babel plugin for that. If it's ok, I can add it in this PR
https://github.com/benmosher/eslint-plugin-import/blob/798eed7e559adab2eac07bf1b3e3518d4b7a4296/.babelrc#L2

Copy link
Member

Choose a reason for hiding this comment

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

In that case, let's do that in a separate PR, that also lints using prefer-object-spread.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure :)

@ljharb
Copy link
Member

ljharb commented Apr 12, 2019

@ljqx i've rebased this, but some tests are failing now. could you take a look?

@brodycj
Copy link

brodycj commented Aug 5, 2020

This update could help with a lint task on Prettier. Is there anything we can do to help get this update finalized and ready for an upcoming release?

I did take a quick look at the build failures from last year, found messages like this:

AssertionError [ERR_ASSERTION]: A fatal parsing error occurred: Parsing error: Export 'bar' is not defined

I wonder if something in the stack had become stricter over time.

Copy link
Member

@benmosher benmosher left a comment

Choose a reason for hiding this comment

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

sorry it's 23 months later, but LGTM 👍🏼😅

@ljharb ljharb self-assigned this Oct 20, 2020
@ljharb
Copy link
Member

ljharb commented Oct 20, 2020

@ljqx any chance you'd be able to rebase this? it's a bit hairy.

@ljharb ljharb assigned ljqx and unassigned ljharb Oct 20, 2020
@ljqx
Copy link
Contributor Author

ljqx commented Nov 17, 2020

Hi, Ben and Jordan, updated, and replaced the introduced helper function with existing eslint-module-utils/moduleVisitor

@ljqx

This comment has been minimized.

@ljqx
Copy link
Contributor Author

ljqx commented Nov 19, 2020

The travis and coverage have passed :)

@ljharb ljharb force-pushed the generic-import-callback branch 2 times, most recently from 5037470 to 93e060f Compare January 22, 2021 17:00
@ljharb ljharb merged commit 93e060f into import-js:master Jan 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

import/extensions doesn't work for require('./file-without-extension')
5 participants