Skip to content

Commit

Permalink
Update everything
Browse files Browse the repository at this point in the history
  • Loading branch information
lydell committed Apr 4, 2020
1 parent d2fb91a commit d5118b5
Show file tree
Hide file tree
Showing 19 changed files with 982 additions and 1,342 deletions.
3 changes: 1 addition & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ const baseRules = require("eslint-config-lydell");

module.exports = {
root: true,
plugins: ["import", "jest", "prettier"],
plugins: ["import", "jest"],
env: { es6: true, node: true },
rules: Object.assign({}, baseRules({ import: true }), {
"import/order": ["error", { "newlines-between": "always" }],
"no-console": "error",
"prefer-template": "off",
"prettier/prettier": "error",
}),
overrides: [
{
Expand Down
39 changes: 39 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: CI

on: [push]

jobs:
build:
runs-on: ${{ matrix.os }}

strategy:
matrix:
node-version: [10.x, 12.x]
os: [ubuntu-latest, windows-latest, macOS-latest]

steps:
- name: Set git to use LF
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- uses: actions/checkout@v2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- name: Cache node_modules
uses: actions/cache@v1
with:
path: node_modules
key: node_modules-${{ matrix.node-version }}-${{ matrix.os }}-${{ hashFiles('package-lock.json') }}

- name: Run workflow
shell: bash
run: |
test -d node_modules || npm ci
npm test
env:
CI: true
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
coverage
examples
3 changes: 3 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"proseWrap": "never"
}
5 changes: 0 additions & 5 deletions .travis.yml

This file was deleted.

69 changes: 13 additions & 56 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,73 +1,40 @@
### Version 5.0.2 (2020-03-11)

- Fixed: The plugin now works with TypeScript 3.8 type imports. Thanks to Liwen
Guo (@Livven) and Brandon Chinn (@brandon-leapyear)!
- Fixed: The plugin now works with TypeScript 3.8 type imports. Thanks to Liwen Guo (@Livven) and Brandon Chinn (@brandon-leapyear)!

### 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)

- Added: The `groups` option for [custom sorting].
- Changed: Due to the new `groups` option, the default grouping is ever so
slightly different. Now, not only _valid_ npm package names are placed in the
“packages” group, but also things that _look_ like npm package names, such as
`@ui/Section`. And anything starting with `.` is now considered to be a
relative import. See [custom sorting] for more information.
- Removed: Built-in support for webpack loader syntax. It didn’t fit well with
the new `groups` option, and since I don’t use it myself I decided to remove
it. Please open an issue if you have something to say about this!
- Changed: Due to the new `groups` option, the default grouping is ever so slightly different. Now, not only _valid_ npm package names are placed in the “packages” group, but also things that _look_ like npm package names, such as `@ui/Section`. And anything starting with `.` is now considered to be a relative import. See [custom sorting] for more information.
- Removed: Built-in support for webpack loader syntax. It didn’t fit well with the new `groups` option, and since I don’t use it myself I decided to remove it. Please open an issue if you have something to say about this!

### Version 4.0.0 (2019-06-19)

- Changed: Sorting is now more human – it is case insensitive (matching the
default behavior of TSLint, as well as many IDEs) and numbers are sorted by
their numeric values. This might cause some churn but feels a lot nicer. See
[#7] for more discussion.
- Improved: `from` paths ending with dots in various ways used to be treated
specially. This has now been simplified, which gives a more consistent
sorting. Now, `"."` and `".."` are treated as `"./"` and `"../"` – and those
are the only special cases for “dotty” paths. For example, you might see
`import x from "."` now sorting before `import y from "./y"`.
- Fixed: `".x"` is no longer considered to be a relative import. Only `from`
paths equal to `"."` or `".."`, or that start with `"./"` or `"../"` are truly
relative. This is a bit of an edge case, but if you do have “weird” imports
starting with dots in unusual ways you might notice them jumping up to another
group of imports.
- Fixed: `import {} from "a"` is no longer considered a side-effect import. Only
imports completely lacking the `{...} from` part are. Remove `{} from` if you
relied on this from earlier versions.
- Improved: Trailing spaces after imports are now preserved. Before, if you
accidentally added some trailing spaces it would result in a “Run autofix to
sort these imports!” error, but the autofix wouldn’t actually sort anything –
it would only remove some spaces. That was a bit weird. Now, those spaces are
preserved. It is up to other rules or [Prettier] to take care of trailing
spaces.
- Changed: Sorting is now more human – it is case insensitive (matching the default behavior of TSLint, as well as many IDEs) and numbers are sorted by their numeric values. This might cause some churn but feels a lot nicer. See [#7] for more discussion.
- Improved: `from` paths ending with dots in various ways used to be treated specially. This has now been simplified, which gives a more consistent sorting. Now, `"."` and `".."` are treated as `"./"` and `"../"` – and those are the only special cases for “dotty” paths. For example, you might see `import x from "."` now sorting before `import y from "./y"`.
- Fixed: `".x"` is no longer considered to be a relative import. Only `from` paths equal to `"."` or `".."`, or that start with `"./"` or `"../"` are truly relative. This is a bit of an edge case, but if you do have “weird” imports starting with dots in unusual ways you might notice them jumping up to another group of imports.
- Fixed: `import {} from "a"` is no longer considered a side-effect import. Only imports completely lacking the `{...} from` part are. Remove `{} from` if you relied on this from earlier versions.
- Improved: Trailing spaces after imports are now preserved. Before, if you accidentally added some trailing spaces it would result in a “Run autofix to sort these imports!” error, but the autofix wouldn’t actually sort anything – it would only remove some spaces. That was a bit weird. Now, those spaces are preserved. It is up to other rules or [Prettier] to take care of trailing spaces.

### Version 3.1.1 (2019-05-16)

- Fixed: Semicolon-free code style is now supported. The plugin now leaves a
semicolon at the start of a line of code after an import alone.
- Fixed: Semicolon-free code style is now supported. The plugin now leaves a semicolon at the start of a line of code after an import alone.

### Version 3.1.0 (2019-03-30)

- Added: Support for indentation in Vue `<script>` tags.

### Version 3.0.0 (2019-02-02)

- Changed: `@/foo` imports and similar are now treated as absolute imports. This
is a common convention in Vue to avoid `../../../foo` imports. Previously,
`@/foo` ended up among npm packages. This was fixed by turning the absolute
imports group into the “rest / trash can” group instead of the packages group.
The packages group now only contain valid npm package names and Node.js
builtins. The new grouping logic is:
- Changed: `@/foo` imports and similar are now treated as absolute imports. This is a common convention in Vue to avoid `../../../foo` imports. Previously, `@/foo` ended up among npm packages. This was fixed by turning the absolute imports group into the “rest / trash can” group instead of the packages group. The packages group now only contain valid npm package names and Node.js builtins. The new grouping logic is:

1. `import "./setup"`: Side effect imports. (These are not sorted internally.)
2. `import react from "react"`: Packages (npm packages and Node.js builtins).
3. `import Error from "@/components/error.vue"`: Absolute imports, full URLs
and other imports (such as Vue-style `@/foo` ones).
3. `import Error from "@/components/error.vue"`: Absolute imports, full URLs and other imports (such as Vue-style `@/foo` ones).
4. `import a from "./a"`: Relative imports.

### Version 2.1.0 (2019-01-26)
Expand All @@ -76,15 +43,7 @@

### Version 2.0.0 (2018-11-30)

- Changed: [Flow type imports] are no longer put in their own group at the top.
Type imports from npm packages are grouped among regular npm imports, relative
type imports are group among regular relative imports, and so on. The reason
for this change is the same as for [sorting on `from`] – to avoid import
“jumps” when they change. Previously, changing
`import type { User } from "./user"` into
`import { type User, getUser } from "./user"` caused the line to jump from the
top of the file (the type imports group) to further down (the relative imports
group). Now it stays in the relative imports group in both cases.
- Changed: [Flow type imports] are no longer put in their own group at the top. Type imports from npm packages are grouped among regular npm imports, relative type imports are group among regular relative imports, and so on. The reason for this change is the same as for [sorting on `from`] – to avoid import “jumps” when they change. Previously, changing `import type { User } from "./user"` into `import { type User, getUser } from "./user"` caused the line to jump from the top of the file (the type imports group) to further down (the relative imports group). Now it stays in the relative imports group in both cases.

### Version 1.0.2 (2018-11-18)

Expand All @@ -98,12 +57,10 @@

- Initial release.

<!-- prettier-ignore-start -->
[@typescript-eslint/parser]: https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/parser
[#7]: https://github.com/lydell/eslint-plugin-simple-import-sort/issues/7
[custom sorting]: https://github.com/lydell/eslint-plugin-simple-import-sort/tree/06c4db7d92a82ec2e265ad1bbb0c0a3d76566222#custom-grouping
[flow type imports]: https://flow.org/en/docs/types/modules/
[prettier]: https://prettier.io/
[sort-from]: README.md#why-sort-on-from
[typescript]: https://www.typescriptlang.org/
<!-- prettier-ignore-end -->
Loading

0 comments on commit d5118b5

Please sign in to comment.