chore: update eslint-plugin-format, remove patch

This commit is contained in:
Stephen Zhou
2024-06-15 16:59:45 +08:00
parent a353988633
commit 1cbc030e09
3 changed files with 21 additions and 89 deletions

View File

@@ -72,7 +72,7 @@
"cross-env": "^7.0.3",
"crx": "^5.0.1",
"eslint": "^9.2.0",
"eslint-plugin-format": "^0.1.1",
"eslint-plugin-format": "^0.1.2",
"eslint-plugin-simple-import-sort": "^12.1.0",
"esno": "^4.7.0",
"fs-extra": "^11.2.0",
@@ -100,11 +100,6 @@
"webextension-polyfill": "^0.11.0",
"wxt": "^0.18.2"
},
"pnpm": {
"patchedDependencies": {
"eslint-plugin-format@0.1.1": "patches/eslint-plugin-format@0.1.1.patch"
}
},
"simple-git-hooks": {
"pre-commit": "pnpm lint-staged"
},

View File

@@ -1,58 +0,0 @@
diff --git a/dist/index.mjs b/dist/index.mjs
index 12b3a7684cf7c12692c6e3980d05315f0522d9a3..4cd39ecbe6f345d72182af6b61bb24652b7f0751 100644
--- a/dist/index.mjs
+++ b/dist/index.mjs
@@ -35,11 +35,34 @@ const prettier = {
return {
Program() {
const sourceCode = context.sourceCode.text;
+ try {
const formatted = format$1(sourceCode, {
filepath: context.filename,
...context.options[0] || {}
});
reportDifferences(context, sourceCode, formatted);
+ } catch (error) {
+ let loc = {
+ start: { line: 1, column: 0 },
+ end: { line: 1, column: 0 },
+ }
+
+ if (error instanceof Error) {
+ const locationMatch = error.message.match(/\((?<line>\d):(?<column>\d)\)/)
+ if (locationMatch?.groups) {
+ const { line, column } = locationMatch.groups
+ loc = {
+ start: { line: +line, column: +column },
+ end: { line: +line, column: +column },
+ }
+ }
+ }
+
+ context.report({
+ loc,
+ message: 'Failed to format the code',
+ })
+ }
}
};
}
@@ -77,8 +100,18 @@ const dprint = {
return {
Program() {
const sourceCode = context.sourceCode.text;
+ try {
const formatted = format(sourceCode, context.filename, context.options[0] || {});
reportDifferences(context, sourceCode, formatted);
+ } catch (error) {
+ context.report({
+ loc: {
+ start: { line: 1, column: 0 },
+ end: { line: 1, column: 0 },
+ },
+ message: 'Failed to format the code',
+ })
+ }
}
};
}

45
pnpm-lock.yaml generated
View File

@@ -4,11 +4,6 @@ settings:
autoInstallPeers: true
excludeLinksFromLockfile: false
patchedDependencies:
eslint-plugin-format@0.1.1:
hash: mfx7mexmog33ykld5nlb6ktu7m
path: patches/eslint-plugin-format@0.1.1.patch
importers:
.:
@@ -49,7 +44,7 @@ importers:
devDependencies:
'@antfu/eslint-config':
specifier: ^2.17.0
version: 2.17.0(@vue/compiler-sfc@3.4.27)(eslint-plugin-format@0.1.1(patch_hash=mfx7mexmog33ykld5nlb6ktu7m)(eslint@9.2.0))(eslint@9.2.0)(typescript@5.4.5)(vitest@1.6.0(@types/node@20.12.11)(jsdom@24.0.0)(sass@1.77.0)(terser@5.31.0))
version: 2.17.0(@vue/compiler-sfc@3.4.27)(eslint-plugin-format@0.1.2(eslint@9.2.0))(eslint@9.2.0)(typescript@5.4.5)(vitest@1.6.0(@types/node@20.12.11)(jsdom@24.0.0)(sass@1.77.0)(terser@5.31.0))
'@ffflorian/jszip-cli':
specifier: ^3.6.3
version: 3.6.3(typescript@5.4.5)
@@ -99,8 +94,8 @@ importers:
specifier: ^9.2.0
version: 9.2.0
eslint-plugin-format:
specifier: ^0.1.1
version: 0.1.1(patch_hash=mfx7mexmog33ykld5nlb6ktu7m)(eslint@9.2.0)
specifier: ^0.1.2
version: 0.1.2(eslint@9.2.0)
eslint-plugin-simple-import-sort:
specifier: ^12.1.0
version: 12.1.0(eslint@9.2.0)
@@ -439,11 +434,11 @@ packages:
resolution: {integrity: sha512-dBVuXR082gk3jsFp7Rd/JI4kytwGHecnCoTtXFb7DB6CNHp4rg5k1bhg0nWdLGLnOV71lmDzGQaLMy8iPLY0pw==}
engines: {node: '>=10.0.0'}
'@dprint/formatter@0.2.1':
resolution: {integrity: sha512-GCzgRt2o4mhZLy8L47k2A+q9EMG/jWhzZebE29EqKsxmjDrSfv2VisEj/Q+39OOf04jTkEfB/TRO+IZSyxHdYg==}
'@dprint/formatter@0.3.0':
resolution: {integrity: sha512-N9fxCxbaBOrDkteSOzaCqwWjso5iAe+WJPsHC021JfHNj2ThInPNEF13ORDKta3llq5D1TlclODCvOvipH7bWQ==}
'@dprint/markdown@0.16.4':
resolution: {integrity: sha512-WjsC4yLybR5/76+d/2s36nOBGjETe+jJR//ddFHohDXKdis+FTUv7dJ00kmd6g0AKQwDITayM1Nid10gFNG0Yg==}
'@dprint/markdown@0.17.1':
resolution: {integrity: sha512-Mk9C9tHHSScB3JOUd2PEP3keWnJZ8Kqcd99qaVhknzhxgZF/gGTx0CMyd+lpsIV+Moe+OtbRnqAjp+hKVtT1zQ==}
'@dprint/toml@0.6.2':
resolution: {integrity: sha512-Mk5unEANsL/L+WHYU3NpDXt1ARU5bNU5k5OZELxaJodDycKG6RoRnSlZXpW6+7UN2PSnETAFVUdKrh937ZwtHA==}
@@ -2671,8 +2666,8 @@ packages:
peerDependencies:
eslint: '>=4.19.1'
eslint-plugin-format@0.1.1:
resolution: {integrity: sha512-jzk70D3RbaseNIdMtimMqiJHDPUw9bzZjmZTT9tQ6x3HU9U9bGqnsieQK5H0FIZUpx4qC41CidLDWwVCylICRQ==}
eslint-plugin-format@0.1.2:
resolution: {integrity: sha512-ZrcO3aiumgJ6ENAv65IWkPjtW77ML/5mp0YrRK0jdvvaZJb+4kKWbaQTMr/XbJo6CtELRmCApAziEKh7L2NbdQ==}
peerDependencies:
eslint: ^8.40.0 || ^9.0.0
@@ -4736,8 +4731,8 @@ packages:
resolution: {integrity: sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==}
engines: {node: '>=6.0.0'}
prettier@3.3.0:
resolution: {integrity: sha512-J9odKxERhCQ10OC2yb93583f6UnYutOeiV5i0zEDS7UGTdUt0u+y8erxl3lBKvwo/JHyyoEdXjwp4dke9oyZ/g==}
prettier@3.3.2:
resolution: {integrity: sha512-rAVeHYMcv8ATV5d508CFdn+8/pHPpXeIid1DdrPwXnaAdH7cqjVbpJaT5eq4yRAFU/lsbwYwSF/n5iNrdJHPQA==}
engines: {node: '>=14'}
hasBin: true
@@ -6281,7 +6276,7 @@ snapshots:
'@jridgewell/gen-mapping': 0.3.5
'@jridgewell/trace-mapping': 0.3.25
'@antfu/eslint-config@2.17.0(@vue/compiler-sfc@3.4.27)(eslint-plugin-format@0.1.1(patch_hash=mfx7mexmog33ykld5nlb6ktu7m)(eslint@9.2.0))(eslint@9.2.0)(typescript@5.4.5)(vitest@1.6.0(@types/node@20.12.11)(jsdom@24.0.0)(sass@1.77.0)(terser@5.31.0))':
'@antfu/eslint-config@2.17.0(@vue/compiler-sfc@3.4.27)(eslint-plugin-format@0.1.2(eslint@9.2.0))(eslint@9.2.0)(typescript@5.4.5)(vitest@1.6.0(@types/node@20.12.11)(jsdom@24.0.0)(sass@1.77.0)(terser@5.31.0))':
dependencies:
'@antfu/install-pkg': 0.3.3
'@clack/prompts': 0.7.0
@@ -6319,7 +6314,7 @@ snapshots:
yaml-eslint-parser: 1.2.2
yargs: 17.7.2
optionalDependencies:
eslint-plugin-format: 0.1.1(patch_hash=mfx7mexmog33ykld5nlb6ktu7m)(eslint@9.2.0)
eslint-plugin-format: 0.1.2(eslint@9.2.0)
transitivePeerDependencies:
- '@vue/compiler-sfc'
- supports-color
@@ -6585,9 +6580,9 @@ snapshots:
'@discoveryjs/json-ext@0.5.7': {}
'@dprint/formatter@0.2.1': {}
'@dprint/formatter@0.3.0': {}
'@dprint/markdown@0.16.4': {}
'@dprint/markdown@0.17.1': {}
'@dprint/toml@0.6.2': {}
@@ -9117,15 +9112,15 @@ snapshots:
eslint: 9.2.0
ignore: 5.3.1
eslint-plugin-format@0.1.1(patch_hash=mfx7mexmog33ykld5nlb6ktu7m)(eslint@9.2.0):
eslint-plugin-format@0.1.2(eslint@9.2.0):
dependencies:
'@dprint/formatter': 0.2.1
'@dprint/markdown': 0.16.4
'@dprint/formatter': 0.3.0
'@dprint/markdown': 0.17.1
'@dprint/toml': 0.6.2
eslint: 9.2.0
eslint-formatting-reporter: 0.0.0(eslint@9.2.0)
eslint-parser-plain: 0.1.0
prettier: 3.3.0
prettier: 3.3.2
synckit: 0.9.0
eslint-plugin-import-x@0.5.0(eslint@9.2.0)(typescript@5.4.5):
@@ -11389,7 +11384,7 @@ snapshots:
dependencies:
fast-diff: 1.3.0
prettier@3.3.0: {}
prettier@3.3.2: {}
pretty-format@29.7.0:
dependencies: