Skip to content

Commit

Permalink
feat: Sort imports (#172)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Updated the prettier config to also sort imports.
  • Loading branch information
jhnns committed Sep 13, 2024
1 parent 649b6f0 commit 0c1eb54
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 122 deletions.
151 changes: 35 additions & 116 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"@babel/core": "^7.24.9",
"@babel/eslint-parser": "^7.24.8",
"@babel/eslint-plugin": "^7.24.7",
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
"@ianvs/prettier-plugin-sort-imports": "^4.3.1",
"@typescript-eslint/eslint-plugin": "^7.16.1",
"@typescript-eslint/parser": "^7.16.1",
"eslint-config-prettier": "^9.1.0",
Expand Down
19 changes: 14 additions & 5 deletions prettier.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
"use strict";

module.exports = {
// TODO: Re-add this plugin once it's fixed, https://github.com/peerigon/eslint-config-peerigon/issues/141
// This plugin breaks with import attributes like `import ... with { type: "json" }
// See https://github.com/trivago/prettier-plugin-sort-imports/issues/270
// plugins: ["@trivago/prettier-plugin-sort-imports"],
// importOrder: ["^node:", "<THIRD_PARTY_MODULES>", "^[./]"],
plugins: ["@ianvs/prettier-plugin-sort-imports"],
// Overwriting the default configuration because of "importAttributes".
// TODO: Remove this once "importAttributes" is added to the default configuration.
importOrderParserPlugins: [
"typescript",
"jsx",
"decorators",
"importAttributes",
],
// Overwrites the default TS version of "1.0.0".
// It's a little bit annoying to specify the TS version here as we don't know
// the project's TS version (and we also don't want to update this file every time).
// Specifying the most major version should be enough for now.
importOrderTypeScriptVersion: "5.0.0",
};

0 comments on commit 0c1eb54

Please sign in to comment.