From fe7326f3c387fb7ce93597840a71efff7751be70 Mon Sep 17 00:00:00 2001 From: Johannes Ewald Date: Mon, 29 Apr 2024 16:24:39 +0200 Subject: [PATCH] fix: Disable @trivago/prettier-plugin-sort-imports temporarily See https://github.com/peerigon/eslint-config-peerigon/issues/141 --- .prettierignore | 1 + package-lock.json | 90 ++++++++++++++++++------------ package.json | 6 +- prettier.config.js | 7 ++- tests/javascript/babel.config.json | 5 +- tests/javascript/main.js | 4 +- tests/javascript/test.json | 1 + tests/typescript/main.ts | 4 +- tests/typescript/test.json | 1 + tests/typescript/tsconfig.json | 3 +- 10 files changed, 78 insertions(+), 44 deletions(-) create mode 100644 .prettierignore create mode 100644 tests/javascript/test.json create mode 100644 tests/typescript/test.json diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..1b763b1 --- /dev/null +++ b/.prettierignore @@ -0,0 +1 @@ +CHANGELOG.md diff --git a/package-lock.json b/package-lock.json index 0507294..a0c6b32 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "0.0.0-semantically-released", "license": "Unlicense", "dependencies": { - "@babel/core": "^7.24.3", + "@babel/core": "^7.24.4", "@babel/eslint-parser": "^7.24.1", "@babel/eslint-plugin": "^7.23.5", "@trivago/prettier-plugin-sort-imports": "^4.3.0", @@ -24,7 +24,8 @@ }, "devDependencies": { "@babel/plugin-proposal-class-properties": "^7.18.6", - "@babel/preset-env": "^7.24.3", + "@babel/plugin-syntax-import-attributes": "^7.24.1", + "@babel/preset-env": "^7.24.4", "@semantic-release/changelog": "^6.0.3", "@semantic-release/git": "^10.0.1", "@types/react": "^18.2.69", @@ -81,25 +82,25 @@ } }, "node_modules/@babel/compat-data": { - "version": "7.24.1", - "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.24.1.tgz", - "integrity": "sha512-Pc65opHDliVpRHuKfzI+gSA4zcgr65O4cl64fFJIWEEh8JoHIHh0Oez1Eo8Arz8zq/JhgKodQaxEwUPRtZylVA==", + "version": "7.24.4", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.24.4.tgz", + "integrity": "sha512-vg8Gih2MLK+kOkHJp4gBEIkyaIi00jgWot2D9QOmmfLC8jINSOzmCLta6Bvz/JSBCqnegV0L80jhxkol5GWNfQ==", "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/core": { - "version": "7.24.3", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.24.3.tgz", - "integrity": "sha512-5FcvN1JHw2sHJChotgx8Ek0lyuh4kCKelgMTTqhYJJtloNvUfpAFMeNQUtdlIaktwrSV9LtCdqwk48wL2wBacQ==", + "version": "7.24.4", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.24.4.tgz", + "integrity": "sha512-MBVlMXP+kkl5394RBLSxxk/iLTeVGuXTV3cIDXavPpMMqnSnt6apKgan/U8O3USWZCWZT/TbgfEpKa4uMgN4Dg==", "dependencies": { "@ampproject/remapping": "^2.2.0", "@babel/code-frame": "^7.24.2", - "@babel/generator": "^7.24.1", + "@babel/generator": "^7.24.4", "@babel/helper-compilation-targets": "^7.23.6", "@babel/helper-module-transforms": "^7.23.3", - "@babel/helpers": "^7.24.1", - "@babel/parser": "^7.24.1", + "@babel/helpers": "^7.24.4", + "@babel/parser": "^7.24.4", "@babel/template": "^7.24.0", "@babel/traverse": "^7.24.1", "@babel/types": "^7.24.0", @@ -150,9 +151,9 @@ } }, "node_modules/@babel/generator": { - "version": "7.24.1", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.24.1.tgz", - "integrity": "sha512-DfCRfZsBcrPEHUfuBMgbJ1Ut01Y/itOs+hY2nFLgqsqXd52/iSiVq5TITtUasIUgm+IIKdY2/1I7auiQOEeC9A==", + "version": "7.24.4", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.24.4.tgz", + "integrity": "sha512-Xd6+v6SnjWVx/nus+y0l1sxMOTOMBkyL4+BIdbALyatQnAe/SRVjANeDPSCYaX+i1iJmuGSKf3Z+E+V/va1Hvw==", "dependencies": { "@babel/types": "^7.24.0", "@jridgewell/gen-mapping": "^0.3.5", @@ -203,9 +204,9 @@ } }, "node_modules/@babel/helper-create-class-features-plugin": { - "version": "7.24.1", - "resolved": "https://registry.npmjs.org/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.24.1.tgz", - "integrity": "sha512-1yJa9dX9g//V6fDebXoEfEsxkZHk3Hcbm+zLhyu6qVgYFLvmTALTeV+jNU9e5RnYtioBrGEOdoI2joMSNQ/+aA==", + "version": "7.24.4", + "resolved": "https://registry.npmjs.org/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.24.4.tgz", + "integrity": "sha512-lG75yeuUSVu0pIcbhiYMXBXANHrpUPaOfu7ryAzskCgKUHuAxRQI5ssrtmF0X9UXldPlvT0XM/A4F44OXRt6iQ==", "dev": true, "dependencies": { "@babel/helper-annotate-as-pure": "^7.22.5", @@ -458,9 +459,9 @@ } }, "node_modules/@babel/helpers": { - "version": "7.24.1", - "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.24.1.tgz", - "integrity": "sha512-BpU09QqEe6ZCHuIHFphEFgvNSrubve1FtyMton26ekZ85gRGi6LrTF7zArARp2YvyFxloeiRmtSCq5sjh1WqIg==", + "version": "7.24.4", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.24.4.tgz", + "integrity": "sha512-FewdlZbSiwaVGlgT1DPANDuCHaDMiOo+D/IDYRFYjHOuv66xMSJ7fQwwODwRNAPkADIO/z1EoF/l2BCWlWABDw==", "dependencies": { "@babel/template": "^7.24.0", "@babel/traverse": "^7.24.1", @@ -485,9 +486,9 @@ } }, "node_modules/@babel/parser": { - "version": "7.24.1", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.24.1.tgz", - "integrity": "sha512-Zo9c7N3xdOIQrNip7Lc9wvRPzlRtovHVE4lkz8WEDr7uYh/GMQhSiIgFxGIArRHYdJE5kxtZjAf8rT0xhdLCzg==", + "version": "7.24.4", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.24.4.tgz", + "integrity": "sha512-zTvEBcghmeBma9QIGunWevvBAp4/Qu9Bdq+2k0Ot4fVMD6v3dsC9WOcRSKk7tRRyBM/53yKMJko9xOatGQAwSg==", "bin": { "parser": "bin/babel-parser.js" }, @@ -495,6 +496,22 @@ "node": ">=6.0.0" } }, + "node_modules/@babel/plugin-bugfix-firefox-class-in-computed-class-key": { + "version": "7.24.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-bugfix-firefox-class-in-computed-class-key/-/plugin-bugfix-firefox-class-in-computed-class-key-7.24.4.tgz", + "integrity": "sha512-qpl6vOOEEzTLLcsuqYYo8yDtrTocmu2xkGvgNebvPjT9DTtfFYGmgDqY+rBYXNlqL4s9qLDn6xkrJv4RxAPiTA==", + "dev": true, + "dependencies": { + "@babel/helper-environment-visitor": "^7.22.20", + "@babel/helper-plugin-utils": "^7.24.0" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, "node_modules/@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression": { "version": "7.24.1", "resolved": "https://registry.npmjs.org/@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression/-/plugin-bugfix-safari-id-destructuring-collision-in-function-expression-7.24.1.tgz", @@ -873,9 +890,9 @@ } }, "node_modules/@babel/plugin-transform-block-scoping": { - "version": "7.24.1", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.24.1.tgz", - "integrity": "sha512-h71T2QQvDgM2SmT29UYU6ozjMlAt7s7CSs5Hvy8f8cf/GM/Z4a2zMfN+fjVGaieeCrXR3EdQl6C4gQG+OgmbKw==", + "version": "7.24.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.24.4.tgz", + "integrity": "sha512-nIFUZIpGKDf9O9ttyRXpHFpKC+X3Y5mtshZONuEUYBomAKoM4y029Jr+uB1bHGPhNmK8YXHevDtKDOLmtRrp6g==", "dev": true, "dependencies": { "@babel/helper-plugin-utils": "^7.24.0" @@ -904,12 +921,12 @@ } }, "node_modules/@babel/plugin-transform-class-static-block": { - "version": "7.24.1", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-class-static-block/-/plugin-transform-class-static-block-7.24.1.tgz", - "integrity": "sha512-FUHlKCn6J3ERiu8Dv+4eoz7w8+kFLSyeVG4vDAikwADGjUCoHw/JHokyGtr8OR4UjpwPVivyF+h8Q5iv/JmrtA==", + "version": "7.24.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-class-static-block/-/plugin-transform-class-static-block-7.24.4.tgz", + "integrity": "sha512-B8q7Pz870Hz/q9UgP8InNpY01CSLDSCyqX7zcRuv3FcPl87A2G17lASroHWaCtbdIcbYzOZ7kWmXFKbijMSmFg==", "dev": true, "dependencies": { - "@babel/helper-create-class-features-plugin": "^7.24.1", + "@babel/helper-create-class-features-plugin": "^7.24.4", "@babel/helper-plugin-utils": "^7.24.0", "@babel/plugin-syntax-class-static-block": "^7.14.5" }, @@ -1579,15 +1596,16 @@ } }, "node_modules/@babel/preset-env": { - "version": "7.24.3", - "resolved": "https://registry.npmjs.org/@babel/preset-env/-/preset-env-7.24.3.tgz", - "integrity": "sha512-fSk430k5c2ff8536JcPvPWK4tZDwehWLGlBp0wrsBUjZVdeQV6lePbwKWZaZfK2vnh/1kQX1PzAJWsnBmVgGJA==", + "version": "7.24.4", + "resolved": "https://registry.npmjs.org/@babel/preset-env/-/preset-env-7.24.4.tgz", + "integrity": "sha512-7Kl6cSmYkak0FK/FXjSEnLJ1N9T/WA2RkMhu17gZ/dsxKJUuTYNIylahPTzqpLyJN4WhDif8X0XK1R8Wsguo/A==", "dev": true, "dependencies": { - "@babel/compat-data": "^7.24.1", + "@babel/compat-data": "^7.24.4", "@babel/helper-compilation-targets": "^7.23.6", "@babel/helper-plugin-utils": "^7.24.0", "@babel/helper-validator-option": "^7.23.5", + "@babel/plugin-bugfix-firefox-class-in-computed-class-key": "^7.24.4", "@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression": "^7.24.1", "@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining": "^7.24.1", "@babel/plugin-bugfix-v8-static-class-fields-redefine-readonly": "^7.24.1", @@ -1614,9 +1632,9 @@ "@babel/plugin-transform-async-generator-functions": "^7.24.3", "@babel/plugin-transform-async-to-generator": "^7.24.1", "@babel/plugin-transform-block-scoped-functions": "^7.24.1", - "@babel/plugin-transform-block-scoping": "^7.24.1", + "@babel/plugin-transform-block-scoping": "^7.24.4", "@babel/plugin-transform-class-properties": "^7.24.1", - "@babel/plugin-transform-class-static-block": "^7.24.1", + "@babel/plugin-transform-class-static-block": "^7.24.4", "@babel/plugin-transform-classes": "^7.24.1", "@babel/plugin-transform-computed-properties": "^7.24.1", "@babel/plugin-transform-destructuring": "^7.24.1", diff --git a/package.json b/package.json index 58ea5b2..55c8bf1 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "test:node": "cd tests/node; eslint --max-warnings 0 .", "test:typescript": "cd tests/typescript; eslint --max-warnings 0 .", "test:react": "cd tests/react; eslint --max-warnings 0 .", + "test:prettier": "prettier --check .", "prepare": "husky", "release": "semantic-release" }, @@ -43,7 +44,7 @@ "eslint": "^8.1.0" }, "dependencies": { - "@babel/core": "^7.24.3", + "@babel/core": "^7.24.4", "@babel/eslint-parser": "^7.24.1", "@babel/eslint-plugin": "^7.23.5", "@trivago/prettier-plugin-sort-imports": "^4.3.0", @@ -58,7 +59,8 @@ }, "devDependencies": { "@babel/plugin-proposal-class-properties": "^7.18.6", - "@babel/preset-env": "^7.24.3", + "@babel/plugin-syntax-import-attributes": "^7.24.1", + "@babel/preset-env": "^7.24.4", "@semantic-release/changelog": "^6.0.3", "@semantic-release/git": "^10.0.1", "@types/react": "^18.2.69", diff --git a/prettier.config.js b/prettier.config.js index 6c6e70f..db89ece 100644 --- a/prettier.config.js +++ b/prettier.config.js @@ -1,6 +1,9 @@ "use strict"; module.exports = { - plugins: ["@trivago/prettier-plugin-sort-imports"], - importOrder: ["^node:", "", "^[./]"], + // 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:", "", "^[./]"], }; diff --git a/tests/javascript/babel.config.json b/tests/javascript/babel.config.json index 3aacfb2..958a5fa 100644 --- a/tests/javascript/babel.config.json +++ b/tests/javascript/babel.config.json @@ -1,4 +1,7 @@ { "presets": ["@babel/preset-env"], - "plugins": ["@babel/plugin-proposal-class-properties"] + "plugins": [ + "@babel/plugin-proposal-class-properties", + "@babel/plugin-syntax-import-attributes" + ] } diff --git a/tests/javascript/main.js b/tests/javascript/main.js index ad61201..0b4b8f4 100644 --- a/tests/javascript/main.js +++ b/tests/javascript/main.js @@ -1,4 +1,6 @@ import { getMessage } from "./message.js"; +// Check if import attributes are detected and formatted correctly +import test from "./test.json" with { type: "json" }; class SomeClass { #someProp = true; @@ -8,4 +10,4 @@ class SomeClass { } } -console.log(getMessage(), SomeClass); +console.log(getMessage(), SomeClass, test); diff --git a/tests/javascript/test.json b/tests/javascript/test.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/tests/javascript/test.json @@ -0,0 +1 @@ +{} diff --git a/tests/typescript/main.ts b/tests/typescript/main.ts index 5feec90..b465c89 100644 --- a/tests/typescript/main.ts +++ b/tests/typescript/main.ts @@ -1,4 +1,6 @@ import { getMessage } from "./message.js"; +// Check if import attributes are detected and formatted correctly +import test from "./test.json" with { type: "json" }; // Should be an error // eslint-disable-next-line @typescript-eslint/naming-convention @@ -22,4 +24,4 @@ class SomeClass { snake_case() {} } -console.log(getMessage(), SomeClass, snake_case); +console.log(getMessage(), SomeClass, snake_case, test); diff --git a/tests/typescript/test.json b/tests/typescript/test.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/tests/typescript/test.json @@ -0,0 +1 @@ +{} diff --git a/tests/typescript/tsconfig.json b/tests/typescript/tsconfig.json index ca0ce5e..328600f 100644 --- a/tests/typescript/tsconfig.json +++ b/tests/typescript/tsconfig.json @@ -5,6 +5,7 @@ "lib": ["dom", "esnext"], "strict": true, "moduleResolution": "node", - "esModuleInterop": true + "esModuleInterop": true, + "resolveJsonModule": true } }