From 13b1d3c3ef6ffac42c3bebca11aabfda3cabd320 Mon Sep 17 00:00:00 2001 From: enisdenjo Date: Sun, 22 Jan 2023 19:26:09 +0100 Subject: [PATCH 1/9] specify extensions --- packages/prettier-config/index.cjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/prettier-config/index.cjs b/packages/prettier-config/index.cjs index 19d1e282..a6777ffb 100644 --- a/packages/prettier-config/index.cjs +++ b/packages/prettier-config/index.cjs @@ -39,8 +39,8 @@ module.exports = { '^(@|d|_)', // Anything that starts with a dot and doesnt have an extension (relative imports). '^\\.[^\\.]+$', - // Files with extensions. - '^.+\\.', + // Other files with extensions. + '^.+\\.(graphql|css|png|svg|jpe?g|webp|avif|wasm|mp4|webm)', ], importOrderSeparation: false, // import order groups wont be separated by a new line importOrderSortSpecifiers: true, // sorts the import specifiers alphabetically From af5b5c0fd198d7c8677634fbbabe6b843934c26d Mon Sep 17 00:00:00 2001 From: enisdenjo Date: Sun, 22 Jan 2023 19:36:57 +0100 Subject: [PATCH 2/9] must end with ext --- packages/prettier-config/index.cjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/prettier-config/index.cjs b/packages/prettier-config/index.cjs index a6777ffb..cba51766 100644 --- a/packages/prettier-config/index.cjs +++ b/packages/prettier-config/index.cjs @@ -40,7 +40,7 @@ module.exports = { // Anything that starts with a dot and doesnt have an extension (relative imports). '^\\.[^\\.]+$', // Other files with extensions. - '^.+\\.(graphql|css|png|svg|jpe?g|webp|avif|wasm|mp4|webm)', + '^.+\\.(graphql|css|png|svg|jpe?g|webp|avif|wasm|mp4|webm)$', ], importOrderSeparation: false, // import order groups wont be separated by a new line importOrderSortSpecifiers: true, // sorts the import specifiers alphabetically From c854c203232dbdcf3b0472c541bcca3f5139b4ca Mon Sep 17 00:00:00 2001 From: enisdenjo Date: Sun, 22 Jan 2023 19:37:05 +0100 Subject: [PATCH 3/9] anything starting with a dot --- packages/prettier-config/index.cjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/prettier-config/index.cjs b/packages/prettier-config/index.cjs index cba51766..ff81586c 100644 --- a/packages/prettier-config/index.cjs +++ b/packages/prettier-config/index.cjs @@ -37,8 +37,8 @@ module.exports = { '', // Things that start with `@` or digit or underscore. '^(@|d|_)', - // Anything that starts with a dot and doesnt have an extension (relative imports). - '^\\.[^\\.]+$', + // Anything that starts with a dot (relative imports). + '^\\.+', // Other files with extensions. '^.+\\.(graphql|css|png|svg|jpe?g|webp|avif|wasm|mp4|webm)$', ], From 53a5c887004575edb1bdaa29ea25bdbda975a554 Mon Sep 17 00:00:00 2001 From: enisdenjo Date: Sun, 22 Jan 2023 19:40:42 +0100 Subject: [PATCH 4/9] match digit, not letter d --- packages/prettier-config/index.cjs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/prettier-config/index.cjs b/packages/prettier-config/index.cjs index ff81586c..3f721406 100644 --- a/packages/prettier-config/index.cjs +++ b/packages/prettier-config/index.cjs @@ -24,8 +24,6 @@ module.exports = { require('@trivago/prettier-plugin-sort-imports'), ], importOrder: [ - // Side effect imports. - '^\\u0000', // Node.js builtins `^(node:)?(${builtinModules .filter(mod => !mod.startsWith('_') && !mod.includes('/')) @@ -36,7 +34,7 @@ module.exports = { // Anything not matched in other groups. '', // Things that start with `@` or digit or underscore. - '^(@|d|_)', + '^(@|\\d|_)', // Anything that starts with a dot (relative imports). '^\\.+', // Other files with extensions. From d5cf565ecbd104e18df2f1acaeb751514746141f Mon Sep 17 00:00:00 2001 From: enisdenjo Date: Sun, 22 Jan 2023 19:42:29 +0100 Subject: [PATCH 5/9] unnecessary match --- packages/prettier-config/index.cjs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/prettier-config/index.cjs b/packages/prettier-config/index.cjs index 3f721406..2d02a80c 100644 --- a/packages/prettier-config/index.cjs +++ b/packages/prettier-config/index.cjs @@ -24,6 +24,8 @@ module.exports = { require('@trivago/prettier-plugin-sort-imports'), ], importOrder: [ + // Side effect imports. + '^\\u0000', // Node.js builtins `^(node:)?(${builtinModules .filter(mod => !mod.startsWith('_') && !mod.includes('/')) From 6ee15e21c48438e1dab40671ab886813c7ddfe81 Mon Sep 17 00:00:00 2001 From: enisdenjo Date: Sun, 22 Jan 2023 19:43:33 +0100 Subject: [PATCH 6/9] comment --- packages/prettier-config/index.cjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/prettier-config/index.cjs b/packages/prettier-config/index.cjs index 2d02a80c..ad4c33c8 100644 --- a/packages/prettier-config/index.cjs +++ b/packages/prettier-config/index.cjs @@ -37,7 +37,7 @@ module.exports = { '', // Things that start with `@` or digit or underscore. '^(@|\\d|_)', - // Anything that starts with a dot (relative imports). + // Anything that starts with a dot, or multiple dots (relative imports). '^\\.+', // Other files with extensions. '^.+\\.(graphql|css|png|svg|jpe?g|webp|avif|wasm|mp4|webm)$', From 820944d708644f78a5c79503102f5d6aa7dc9555 Mon Sep 17 00:00:00 2001 From: enisdenjo Date: Sun, 22 Jan 2023 19:43:59 +0100 Subject: [PATCH 7/9] changeset --- .changeset/stupid-birds-glow.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/stupid-birds-glow.md diff --git a/.changeset/stupid-birds-glow.md b/.changeset/stupid-birds-glow.md new file mode 100644 index 00000000..7f4775bd --- /dev/null +++ b/.changeset/stupid-birds-glow.md @@ -0,0 +1,5 @@ +--- +'@theguild/prettier-config': patch +--- + +Even prettier imports From 317516d689c896842a8f7b362815e5d269b02d5e Mon Sep 17 00:00:00 2001 From: enisdenjo Date: Sun, 22 Jan 2023 19:58:16 +0100 Subject: [PATCH 8/9] side-effects --- packages/prettier-config/index.cjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/prettier-config/index.cjs b/packages/prettier-config/index.cjs index ad4c33c8..52297845 100644 --- a/packages/prettier-config/index.cjs +++ b/packages/prettier-config/index.cjs @@ -24,8 +24,8 @@ module.exports = { require('@trivago/prettier-plugin-sort-imports'), ], importOrder: [ - // Side effect imports. - '^\\u0000', + // TODO: Sort side effects on the top + // See more: https://github.com/trivago/prettier-plugin-sort-imports/issues/110 // Node.js builtins `^(node:)?(${builtinModules .filter(mod => !mod.startsWith('_') && !mod.includes('/')) From 15481fbae6f5f489e1bc5b219e636d55d527fbc5 Mon Sep 17 00:00:00 2001 From: enisdenjo Date: Sun, 22 Jan 2023 20:28:20 +0100 Subject: [PATCH 9/9] starts with dot and doesnt have "other files" extension --- packages/prettier-config/index.cjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/prettier-config/index.cjs b/packages/prettier-config/index.cjs index 52297845..dd541eb8 100644 --- a/packages/prettier-config/index.cjs +++ b/packages/prettier-config/index.cjs @@ -37,8 +37,8 @@ module.exports = { '', // Things that start with `@` or digit or underscore. '^(@|\\d|_)', - // Anything that starts with a dot, or multiple dots (relative imports). - '^\\.+', + // Anything that starts with a dot, or multiple dots, and doesnt have the "other files" extensions. + '^(?=\\.+)(.(?!\\.(graphql|css|png|svg|jpe?g|webp|avif|wasm|mp4|webm)))+$', // Other files with extensions. '^.+\\.(graphql|css|png|svg|jpe?g|webp|avif|wasm|mp4|webm)$', ],