ESLint: Add and configure import plugin #219
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a first pass for #84, making use of the already available ESLint
import
plugin (and not thesort-imports
rule).I decided to only pull in rules that are considered errors:
import/default
import/export
import/named
import/namespace
import/no-unresolved
As indicated, I disabled the last rule,
no-unresolved
, as we make use ofexternals
, mostly for@wordpress/**
packages and things such asreact
orlodash
.Another way to go about this would be to add exceptions to the
no-unresolved
rule. This is easily possible, but since this might differ, both between various projects, and over time, in general, I thought it best to disable therule.I also manually added and configured the
import/order
rule, and, unless I madea mistake, here's how it should expect import statements to occur:path
.package.json
file.@wordpress/**
packages.Each block has to be ordered alphabetically, case-insensitive, with regard to the package name and file path, respectively. And there has to be single blank line between any two subsequent blocks from the above list.
I also added two fixture files:
Please provide some feedback, and maybe even try this out. Thanks! 馃檹