Skip to content

Commit

Permalink
Make it easier to find how to ignore the rule
Browse files Browse the repository at this point in the history
Fixes #38.
  • Loading branch information
lydell committed Feb 16, 2020
1 parent 577dc10 commit 9c98729
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
### Version 5.0.1 (2020-01-24)

- Fixed: Side effect imports now correctly keep their original order in
Node.js <12. Thanks to Irvin Zhan (@izhan)!
- Fixed: Side effect imports now correctly keep their original order in Node.js
<12. Thanks to Irvin Zhan (@izhan)!

### Version 5.0.0 (2019-11-22)

Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ forget about sorting imports!
- [Is sorting imports safe?](#is-sorting-imports-safe)
- [The sorting autofix causes some odd whitespace!](#the-sorting-autofix-causes-some-odd-whitespace)
- [Can I use this without autofix?](#can-i-use-this-without-autofix)
- [How do I use eslint-ignore for this rule?](#how-do-i-use-eslint-ignore-for-this-rule)
- [Development](#development)
- [npm scripts](#npm-scripts)
- [Directories](#directories)
Expand Down Expand Up @@ -632,6 +633,11 @@ rules one by one, not realizing they could have been autofixed. Finally, not
trying to make more detailed messages makes the code of this plugin _much_
easier to work with.

### How do I use eslint-ignore for this rule?

Looking for `/* eslint-disable */` for this rule? Read all about **[ignoring
(parts of) sorting][example-ignore].**

## Development

You need [Node.js] ~12 and npm 6.
Expand Down
8 changes: 8 additions & 0 deletions examples/ignore.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ separator();
import d from "d";
import c from "c";

// Note that putting a `eslint-disable-next-line simple-import-sort/sort`
// comment in the middle of a chunk of imports WON’T WORK. It HAS to be at the
// very start!

separator();

// If you lant to both import something from a module _and_ import it for its
Expand All @@ -30,3 +34,7 @@ import Other from "another";
// especially useful for long chunks of imports, where you don’t want one little
// edge case disable sorting for the whole thing. Even better is to try to fix
// the issue with the side effects – relying on import order is pretty brittle.

// If all else fails, you can use this trick of inserting code between imports
// to separate chunks of imports.
separator();
8 changes: 8 additions & 0 deletions test/__snapshots__/examples.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ separator();
import d from "d";
import c from "c";
// Note that putting a \`eslint-disable-next-line simple-import-sort/sort\`
// comment in the middle of a chunk of imports WON’T WORK. It HAS to be at the
// very start!
separator();
// If you lant to both import something from a module _and_ import it for its
Expand All @@ -157,6 +161,10 @@ import Thing from "side-effects";
// edge case disable sorting for the whole thing. Even better is to try to fix
// the issue with the side effects – relying on import order is pretty brittle.
// If all else fails, you can use this trick of inserting code between imports
// to separate chunks of imports.
separator();
`;

exports[`examples markdown.md 1`] = `
Expand Down

0 comments on commit 9c98729

Please sign in to comment.