From 56f4ffbeed19e84b3a9461e3c4e760652069aa90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?lvjiaxuan=20=E5=90=95=E5=98=89=E8=BD=A9?= <11309921+lvjiaxuan@users.noreply.github.com> Date: Thu, 16 Feb 2023 16:07:37 +0800 Subject: [PATCH] feat: remove snippets and optimize pre-linting --- README.md | 8 +- package-lock.json | 381 +++-------------------------------------- package.json | 21 +-- snippets/snippets.json | 15 -- src/extension.ts | 50 ++---- 5 files changed, 42 insertions(+), 433 deletions(-) delete mode 100644 snippets/snippets.json diff --git a/README.md b/README.md index 5b331a7..a58a70e 100644 --- a/README.md +++ b/README.md @@ -16,12 +16,7 @@ ](https://marketplace.visualstudio.com/items?itemName=lvjiaxuan.eslint-disable) ## Features - -- Simple snippets with typing `eslint-disable`. -- Select one or **multiple lines** which has rule problems from extension of ESLint IntelliSense, and we could disable rules with: - - The editor context menu. - - Command: `eslint-disable.disable`. - - Keyboard shortcuts: `ctrl + alt + d`. +Select one or **multiple lines** which has rule problems from extension of ESLint IntelliSense, and we could disable rules by `ctrl + alt + d`. > **Note** > @@ -36,4 +31,3 @@ ## TODO - [ ] Support multi-selections disable at the same action. -- [ ] Snippets support present problem rules. diff --git a/package-lock.json b/package-lock.json index 135776f..20ebb01 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,25 +21,12 @@ "@vscode/test-electron": "^2.2.3", "eslint": "^8.34.0", "tsup": "^6.6.3", - "typescript": "^4.9.5", - "vue": "^3.2.47" + "typescript": "^4.9.5" }, "engines": { "vscode": "^1.60.0" } }, - "node_modules/@babel/parser": { - "version": "7.20.15", - "resolved": "https://registry.npmmirror.com/@babel/parser/-/parser-7.20.15.tgz", - "integrity": "sha512-DI4a1oZuf8wC+oAJA9RW6ga3Zbe8RZFt7kD9i4qAspz3I/yHet1VvC3DiSy/fsUvv5pvJuNPh0LPOdCcqinDPg==", - "dev": true, - "bin": { - "parser": "bin/babel-parser.js" - }, - "engines": { - "node": ">=6.0.0" - } - }, "node_modules/@esbuild/android-arm": { "version": "0.17.7", "resolved": "https://registry.npmmirror.com/@esbuild/android-arm/-/android-arm-0.17.7.tgz", @@ -784,136 +771,6 @@ "node": ">=16" } }, - "node_modules/@vue/compiler-core": { - "version": "3.2.47", - "resolved": "https://registry.npmmirror.com/@vue/compiler-core/-/compiler-core-3.2.47.tgz", - "integrity": "sha512-p4D7FDnQb7+YJmO2iPEv0SQNeNzcbHdGByJDsT4lynf63AFkOTFN07HsiRSvjGo0QrxR/o3d0hUyNCUnBU2Tig==", - "dev": true, - "dependencies": { - "@babel/parser": "^7.16.4", - "@vue/shared": "3.2.47", - "estree-walker": "^2.0.2", - "source-map": "^0.6.1" - } - }, - "node_modules/@vue/compiler-core/node_modules/source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmmirror.com/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/@vue/compiler-dom": { - "version": "3.2.47", - "resolved": "https://registry.npmmirror.com/@vue/compiler-dom/-/compiler-dom-3.2.47.tgz", - "integrity": "sha512-dBBnEHEPoftUiS03a4ggEig74J2YBZ2UIeyfpcRM2tavgMWo4bsEfgCGsu+uJIL/vax9S+JztH8NmQerUo7shQ==", - "dev": true, - "dependencies": { - "@vue/compiler-core": "3.2.47", - "@vue/shared": "3.2.47" - } - }, - "node_modules/@vue/compiler-sfc": { - "version": "3.2.47", - "resolved": "https://registry.npmmirror.com/@vue/compiler-sfc/-/compiler-sfc-3.2.47.tgz", - "integrity": "sha512-rog05W+2IFfxjMcFw10tM9+f7i/+FFpZJJ5XHX72NP9eC2uRD+42M3pYcQqDXVYoj74kHMSEdQ/WmCjt8JFksQ==", - "dev": true, - "dependencies": { - "@babel/parser": "^7.16.4", - "@vue/compiler-core": "3.2.47", - "@vue/compiler-dom": "3.2.47", - "@vue/compiler-ssr": "3.2.47", - "@vue/reactivity-transform": "3.2.47", - "@vue/shared": "3.2.47", - "estree-walker": "^2.0.2", - "magic-string": "^0.25.7", - "postcss": "^8.1.10", - "source-map": "^0.6.1" - } - }, - "node_modules/@vue/compiler-sfc/node_modules/source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmmirror.com/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/@vue/compiler-ssr": { - "version": "3.2.47", - "resolved": "https://registry.npmmirror.com/@vue/compiler-ssr/-/compiler-ssr-3.2.47.tgz", - "integrity": "sha512-wVXC+gszhulcMD8wpxMsqSOpvDZ6xKXSVWkf50Guf/S+28hTAXPDYRTbLQ3EDkOP5Xz/+SY37YiwDquKbJOgZw==", - "dev": true, - "dependencies": { - "@vue/compiler-dom": "3.2.47", - "@vue/shared": "3.2.47" - } - }, - "node_modules/@vue/reactivity": { - "version": "3.2.47", - "resolved": "https://registry.npmmirror.com/@vue/reactivity/-/reactivity-3.2.47.tgz", - "integrity": "sha512-7khqQ/75oyyg+N/e+iwV6lpy1f5wq759NdlS1fpAhFXa8VeAIKGgk2E/C4VF59lx5b+Ezs5fpp/5WsRYXQiKxQ==", - "dev": true, - "dependencies": { - "@vue/shared": "3.2.47" - } - }, - "node_modules/@vue/reactivity-transform": { - "version": "3.2.47", - "resolved": "https://registry.npmmirror.com/@vue/reactivity-transform/-/reactivity-transform-3.2.47.tgz", - "integrity": "sha512-m8lGXw8rdnPVVIdIFhf0LeQ/ixyHkH5plYuS83yop5n7ggVJU+z5v0zecwEnX7fa7HNLBhh2qngJJkxpwEEmYA==", - "dev": true, - "dependencies": { - "@babel/parser": "^7.16.4", - "@vue/compiler-core": "3.2.47", - "@vue/shared": "3.2.47", - "estree-walker": "^2.0.2", - "magic-string": "^0.25.7" - } - }, - "node_modules/@vue/runtime-core": { - "version": "3.2.47", - "resolved": "https://registry.npmmirror.com/@vue/runtime-core/-/runtime-core-3.2.47.tgz", - "integrity": "sha512-RZxbLQIRB/K0ev0K9FXhNbBzT32H9iRtYbaXb0ZIz2usLms/D55dJR2t6cIEUn6vyhS3ALNvNthI+Q95C+NOpA==", - "dev": true, - "dependencies": { - "@vue/reactivity": "3.2.47", - "@vue/shared": "3.2.47" - } - }, - "node_modules/@vue/runtime-dom": { - "version": "3.2.47", - "resolved": "https://registry.npmmirror.com/@vue/runtime-dom/-/runtime-dom-3.2.47.tgz", - "integrity": "sha512-ArXrFTjS6TsDei4qwNvgrdmHtD930KgSKGhS5M+j8QxXrDJYLqYw4RRcDy1bz1m1wMmb6j+zGLifdVHtkXA7gA==", - "dev": true, - "dependencies": { - "@vue/runtime-core": "3.2.47", - "@vue/shared": "3.2.47", - "csstype": "^2.6.8" - } - }, - "node_modules/@vue/server-renderer": { - "version": "3.2.47", - "resolved": "https://registry.npmmirror.com/@vue/server-renderer/-/server-renderer-3.2.47.tgz", - "integrity": "sha512-dN9gc1i8EvmP9RCzvneONXsKfBRgqFeFZLurmHOveL7oH6HiFXJw5OGu294n1nHc/HMgTy6LulU/tv5/A7f/LA==", - "dev": true, - "dependencies": { - "@vue/compiler-ssr": "3.2.47", - "@vue/shared": "3.2.47" - }, - "peerDependencies": { - "vue": "3.2.47" - } - }, - "node_modules/@vue/shared": { - "version": "3.2.47", - "resolved": "https://registry.npmmirror.com/@vue/shared/-/shared-3.2.47.tgz", - "integrity": "sha512-BHGyyGN3Q97EZx0taMQ+OLNuZcW3d37ZEVmEAyeoA9ERdGvm9Irc/0Fua8SNyOtV1w6BS4q25wbMzJujO9HIfQ==", - "dev": true - }, "node_modules/acorn": { "version": "8.8.0", "resolved": "https://registry.npmmirror.com/acorn/-/acorn-8.8.0.tgz", @@ -1277,12 +1134,6 @@ "node": ">=4" } }, - "node_modules/csstype": { - "version": "2.6.21", - "resolved": "https://registry.npmmirror.com/csstype/-/csstype-2.6.21.tgz", - "integrity": "sha512-Z1PhmomIfypOpoMjRQB70jfvy/wxT50qW08YXO5lMIJkrdq4yOTR+AW7FqutScmB9NkLwxo+jU+kZLbofZZq/w==", - "dev": true - }, "node_modules/debug": { "version": "4.3.4", "resolved": "https://registry.npmmirror.com/debug/-/debug-4.3.4.tgz", @@ -1661,12 +1512,6 @@ "node": ">=4.0" } }, - "node_modules/estree-walker": { - "version": "2.0.2", - "resolved": "https://registry.npmmirror.com/estree-walker/-/estree-walker-2.0.2.tgz", - "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==", - "dev": true - }, "node_modules/esutils": { "version": "2.0.3", "resolved": "https://registry.npmmirror.com/esutils/-/esutils-2.0.3.tgz", @@ -2264,15 +2109,6 @@ "node": ">=10" } }, - "node_modules/magic-string": { - "version": "0.25.9", - "resolved": "https://registry.npmmirror.com/magic-string/-/magic-string-0.25.9.tgz", - "integrity": "sha512-RmF0AsMzgt25qzqqLc1+MbHmhdx0ojF2Fvs4XnOqz2ZOBXzzkEwc/dJQZCYHAn7v1jbVOjAZfK8msRn4BxO4VQ==", - "dev": true, - "dependencies": { - "sourcemap-codec": "^1.4.8" - } - }, "node_modules/mdast-util-from-markdown": { "version": "0.8.5", "resolved": "https://registry.npmmirror.com/mdast-util-from-markdown/-/mdast-util-from-markdown-0.8.5.tgz", @@ -2391,6 +2227,8 @@ "resolved": "https://registry.npmmirror.com/nanoid/-/nanoid-3.3.4.tgz", "integrity": "sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw==", "dev": true, + "optional": true, + "peer": true, "bin": { "nanoid": "bin/nanoid.cjs" }, @@ -2577,7 +2415,9 @@ "version": "1.0.0", "resolved": "https://registry.npmmirror.com/picocolors/-/picocolors-1.0.0.tgz", "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==", - "dev": true + "dev": true, + "optional": true, + "peer": true }, "node_modules/picomatch": { "version": "2.3.1", @@ -2602,6 +2442,8 @@ "resolved": "https://registry.npmmirror.com/postcss/-/postcss-8.4.21.tgz", "integrity": "sha512-tP7u/Sn/dVxK2NnruI4H9BG+x+Wxz6oeZ1cJ8P6G/PZY0IKk4k/63TDsQf2kQq3+qoJeLm2kIBUNlZe3zgb4Zg==", "dev": true, + "optional": true, + "peer": true, "dependencies": { "nanoid": "^3.3.4", "picocolors": "^1.0.0", @@ -2851,17 +2693,12 @@ "resolved": "https://registry.npmmirror.com/source-map-js/-/source-map-js-1.0.2.tgz", "integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==", "dev": true, + "optional": true, + "peer": true, "engines": { "node": ">=0.10.0" } }, - "node_modules/sourcemap-codec": { - "version": "1.4.8", - "resolved": "https://registry.npmmirror.com/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz", - "integrity": "sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==", - "deprecated": "Please use @jridgewell/sourcemap-codec instead", - "dev": true - }, "node_modules/string_decoder": { "version": "1.1.1", "resolved": "https://registry.npmmirror.com/string_decoder/-/string_decoder-1.1.1.tgz", @@ -3207,19 +3044,6 @@ "resolved": "https://registry.npmmirror.com/vscode-languageserver-types/-/vscode-languageserver-types-3.17.3.tgz", "integrity": "sha512-SYU4z1dL0PyIMd4Vj8YOqFvHu7Hz/enbWtpfnVbJHU4Nd1YNYx8u0ennumc6h48GQNeOLxmwySmnADouT/AuZA==" }, - "node_modules/vue": { - "version": "3.2.47", - "resolved": "https://registry.npmmirror.com/vue/-/vue-3.2.47.tgz", - "integrity": "sha512-60188y/9Dc9WVrAZeUVSDxRQOZ+z+y5nO2ts9jWXSTkMvayiWxCWOWtBQoYjLeccfXkiiPZWAHcV+WTPhkqJHQ==", - "dev": true, - "dependencies": { - "@vue/compiler-dom": "3.2.47", - "@vue/compiler-sfc": "3.2.47", - "@vue/runtime-dom": "3.2.47", - "@vue/server-renderer": "3.2.47", - "@vue/shared": "3.2.47" - } - }, "node_modules/vue-eslint-parser": { "version": "9.1.0", "resolved": "https://registry.npmmirror.com/vue-eslint-parser/-/vue-eslint-parser-9.1.0.tgz", @@ -3345,12 +3169,6 @@ } }, "dependencies": { - "@babel/parser": { - "version": "7.20.15", - "resolved": "https://registry.npmmirror.com/@babel/parser/-/parser-7.20.15.tgz", - "integrity": "sha512-DI4a1oZuf8wC+oAJA9RW6ga3Zbe8RZFt7kD9i4qAspz3I/yHet1VvC3DiSy/fsUvv5pvJuNPh0LPOdCcqinDPg==", - "dev": true - }, "@esbuild/android-arm": { "version": "0.17.7", "resolved": "https://registry.npmmirror.com/@esbuild/android-arm/-/android-arm-0.17.7.tgz", @@ -3797,131 +3615,6 @@ "unzipper": "^0.10.11" } }, - "@vue/compiler-core": { - "version": "3.2.47", - "resolved": "https://registry.npmmirror.com/@vue/compiler-core/-/compiler-core-3.2.47.tgz", - "integrity": "sha512-p4D7FDnQb7+YJmO2iPEv0SQNeNzcbHdGByJDsT4lynf63AFkOTFN07HsiRSvjGo0QrxR/o3d0hUyNCUnBU2Tig==", - "dev": true, - "requires": { - "@babel/parser": "^7.16.4", - "@vue/shared": "3.2.47", - "estree-walker": "^2.0.2", - "source-map": "^0.6.1" - }, - "dependencies": { - "source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmmirror.com/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true - } - } - }, - "@vue/compiler-dom": { - "version": "3.2.47", - "resolved": "https://registry.npmmirror.com/@vue/compiler-dom/-/compiler-dom-3.2.47.tgz", - "integrity": "sha512-dBBnEHEPoftUiS03a4ggEig74J2YBZ2UIeyfpcRM2tavgMWo4bsEfgCGsu+uJIL/vax9S+JztH8NmQerUo7shQ==", - "dev": true, - "requires": { - "@vue/compiler-core": "3.2.47", - "@vue/shared": "3.2.47" - } - }, - "@vue/compiler-sfc": { - "version": "3.2.47", - "resolved": "https://registry.npmmirror.com/@vue/compiler-sfc/-/compiler-sfc-3.2.47.tgz", - "integrity": "sha512-rog05W+2IFfxjMcFw10tM9+f7i/+FFpZJJ5XHX72NP9eC2uRD+42M3pYcQqDXVYoj74kHMSEdQ/WmCjt8JFksQ==", - "dev": true, - "requires": { - "@babel/parser": "^7.16.4", - "@vue/compiler-core": "3.2.47", - "@vue/compiler-dom": "3.2.47", - "@vue/compiler-ssr": "3.2.47", - "@vue/reactivity-transform": "3.2.47", - "@vue/shared": "3.2.47", - "estree-walker": "^2.0.2", - "magic-string": "^0.25.7", - "postcss": "^8.1.10", - "source-map": "^0.6.1" - }, - "dependencies": { - "source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmmirror.com/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true - } - } - }, - "@vue/compiler-ssr": { - "version": "3.2.47", - "resolved": "https://registry.npmmirror.com/@vue/compiler-ssr/-/compiler-ssr-3.2.47.tgz", - "integrity": "sha512-wVXC+gszhulcMD8wpxMsqSOpvDZ6xKXSVWkf50Guf/S+28hTAXPDYRTbLQ3EDkOP5Xz/+SY37YiwDquKbJOgZw==", - "dev": true, - "requires": { - "@vue/compiler-dom": "3.2.47", - "@vue/shared": "3.2.47" - } - }, - "@vue/reactivity": { - "version": "3.2.47", - "resolved": "https://registry.npmmirror.com/@vue/reactivity/-/reactivity-3.2.47.tgz", - "integrity": "sha512-7khqQ/75oyyg+N/e+iwV6lpy1f5wq759NdlS1fpAhFXa8VeAIKGgk2E/C4VF59lx5b+Ezs5fpp/5WsRYXQiKxQ==", - "dev": true, - "requires": { - "@vue/shared": "3.2.47" - } - }, - "@vue/reactivity-transform": { - "version": "3.2.47", - "resolved": "https://registry.npmmirror.com/@vue/reactivity-transform/-/reactivity-transform-3.2.47.tgz", - "integrity": "sha512-m8lGXw8rdnPVVIdIFhf0LeQ/ixyHkH5plYuS83yop5n7ggVJU+z5v0zecwEnX7fa7HNLBhh2qngJJkxpwEEmYA==", - "dev": true, - "requires": { - "@babel/parser": "^7.16.4", - "@vue/compiler-core": "3.2.47", - "@vue/shared": "3.2.47", - "estree-walker": "^2.0.2", - "magic-string": "^0.25.7" - } - }, - "@vue/runtime-core": { - "version": "3.2.47", - "resolved": "https://registry.npmmirror.com/@vue/runtime-core/-/runtime-core-3.2.47.tgz", - "integrity": "sha512-RZxbLQIRB/K0ev0K9FXhNbBzT32H9iRtYbaXb0ZIz2usLms/D55dJR2t6cIEUn6vyhS3ALNvNthI+Q95C+NOpA==", - "dev": true, - "requires": { - "@vue/reactivity": "3.2.47", - "@vue/shared": "3.2.47" - } - }, - "@vue/runtime-dom": { - "version": "3.2.47", - "resolved": "https://registry.npmmirror.com/@vue/runtime-dom/-/runtime-dom-3.2.47.tgz", - "integrity": "sha512-ArXrFTjS6TsDei4qwNvgrdmHtD930KgSKGhS5M+j8QxXrDJYLqYw4RRcDy1bz1m1wMmb6j+zGLifdVHtkXA7gA==", - "dev": true, - "requires": { - "@vue/runtime-core": "3.2.47", - "@vue/shared": "3.2.47", - "csstype": "^2.6.8" - } - }, - "@vue/server-renderer": { - "version": "3.2.47", - "resolved": "https://registry.npmmirror.com/@vue/server-renderer/-/server-renderer-3.2.47.tgz", - "integrity": "sha512-dN9gc1i8EvmP9RCzvneONXsKfBRgqFeFZLurmHOveL7oH6HiFXJw5OGu294n1nHc/HMgTy6LulU/tv5/A7f/LA==", - "dev": true, - "requires": { - "@vue/compiler-ssr": "3.2.47", - "@vue/shared": "3.2.47" - } - }, - "@vue/shared": { - "version": "3.2.47", - "resolved": "https://registry.npmmirror.com/@vue/shared/-/shared-3.2.47.tgz", - "integrity": "sha512-BHGyyGN3Q97EZx0taMQ+OLNuZcW3d37ZEVmEAyeoA9ERdGvm9Irc/0Fua8SNyOtV1w6BS4q25wbMzJujO9HIfQ==", - "dev": true - }, "acorn": { "version": "8.8.0", "resolved": "https://registry.npmmirror.com/acorn/-/acorn-8.8.0.tgz", @@ -4205,12 +3898,6 @@ "integrity": "sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg==", "dev": true }, - "csstype": { - "version": "2.6.21", - "resolved": "https://registry.npmmirror.com/csstype/-/csstype-2.6.21.tgz", - "integrity": "sha512-Z1PhmomIfypOpoMjRQB70jfvy/wxT50qW08YXO5lMIJkrdq4yOTR+AW7FqutScmB9NkLwxo+jU+kZLbofZZq/w==", - "dev": true - }, "debug": { "version": "4.3.4", "resolved": "https://registry.npmmirror.com/debug/-/debug-4.3.4.tgz", @@ -4498,12 +4185,6 @@ "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", "dev": true }, - "estree-walker": { - "version": "2.0.2", - "resolved": "https://registry.npmmirror.com/estree-walker/-/estree-walker-2.0.2.tgz", - "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==", - "dev": true - }, "esutils": { "version": "2.0.3", "resolved": "https://registry.npmmirror.com/esutils/-/esutils-2.0.3.tgz", @@ -4990,15 +4671,6 @@ "yallist": "^4.0.0" } }, - "magic-string": { - "version": "0.25.9", - "resolved": "https://registry.npmmirror.com/magic-string/-/magic-string-0.25.9.tgz", - "integrity": "sha512-RmF0AsMzgt25qzqqLc1+MbHmhdx0ojF2Fvs4XnOqz2ZOBXzzkEwc/dJQZCYHAn7v1jbVOjAZfK8msRn4BxO4VQ==", - "dev": true, - "requires": { - "sourcemap-codec": "^1.4.8" - } - }, "mdast-util-from-markdown": { "version": "0.8.5", "resolved": "https://registry.npmmirror.com/mdast-util-from-markdown/-/mdast-util-from-markdown-0.8.5.tgz", @@ -5101,7 +4773,9 @@ "version": "3.3.4", "resolved": "https://registry.npmmirror.com/nanoid/-/nanoid-3.3.4.tgz", "integrity": "sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw==", - "dev": true + "dev": true, + "optional": true, + "peer": true }, "natural-compare": { "version": "1.4.0", @@ -5246,7 +4920,9 @@ "version": "1.0.0", "resolved": "https://registry.npmmirror.com/picocolors/-/picocolors-1.0.0.tgz", "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==", - "dev": true + "dev": true, + "optional": true, + "peer": true }, "picomatch": { "version": "2.3.1", @@ -5265,6 +4941,8 @@ "resolved": "https://registry.npmmirror.com/postcss/-/postcss-8.4.21.tgz", "integrity": "sha512-tP7u/Sn/dVxK2NnruI4H9BG+x+Wxz6oeZ1cJ8P6G/PZY0IKk4k/63TDsQf2kQq3+qoJeLm2kIBUNlZe3zgb4Zg==", "dev": true, + "optional": true, + "peer": true, "requires": { "nanoid": "^3.3.4", "picocolors": "^1.0.0", @@ -5445,13 +5123,9 @@ "version": "1.0.2", "resolved": "https://registry.npmmirror.com/source-map-js/-/source-map-js-1.0.2.tgz", "integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==", - "dev": true - }, - "sourcemap-codec": { - "version": "1.4.8", - "resolved": "https://registry.npmmirror.com/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz", - "integrity": "sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==", - "dev": true + "dev": true, + "optional": true, + "peer": true }, "string_decoder": { "version": "1.1.1", @@ -5717,19 +5391,6 @@ "resolved": "https://registry.npmmirror.com/vscode-languageserver-types/-/vscode-languageserver-types-3.17.3.tgz", "integrity": "sha512-SYU4z1dL0PyIMd4Vj8YOqFvHu7Hz/enbWtpfnVbJHU4Nd1YNYx8u0ennumc6h48GQNeOLxmwySmnADouT/AuZA==" }, - "vue": { - "version": "3.2.47", - "resolved": "https://registry.npmmirror.com/vue/-/vue-3.2.47.tgz", - "integrity": "sha512-60188y/9Dc9WVrAZeUVSDxRQOZ+z+y5nO2ts9jWXSTkMvayiWxCWOWtBQoYjLeccfXkiiPZWAHcV+WTPhkqJHQ==", - "dev": true, - "requires": { - "@vue/compiler-dom": "3.2.47", - "@vue/compiler-sfc": "3.2.47", - "@vue/runtime-dom": "3.2.47", - "@vue/server-renderer": "3.2.47", - "@vue/shared": "3.2.47" - } - }, "vue-eslint-parser": { "version": "9.1.0", "resolved": "https://registry.npmmirror.com/vue-eslint-parser/-/vue-eslint-parser-9.1.0.tgz", diff --git a/package.json b/package.json index 4be3012..89798e7 100644 --- a/package.json +++ b/package.json @@ -65,24 +65,6 @@ "mac": "ctrl+alt+d", "when": "editorTextFocus" } - ], - "snippets": [ - { - "language": "javascript", - "path": "./snippets/snippets.json" - }, - { - "language": "javascriptreact", - "path": "./snippets/snippets.json" - }, - { - "language": "typescript", - "path": "./snippets/snippets.json" - }, - { - "language": "typescriptreact", - "path": "./snippets/snippets.json" - } ] }, "scripts": { @@ -108,8 +90,7 @@ "@vscode/test-electron": "^2.2.3", "eslint": "^8.34.0", "tsup": "^6.6.3", - "typescript": "^4.9.5", - "vue": "^3.2.47" + "typescript": "^4.9.5" }, "eslintConfig": { "extends": "plugin:@lvjiaxuan/recommended", diff --git a/snippets/snippets.json b/snippets/snippets.json deleted file mode 100644 index b30fc8b..0000000 --- a/snippets/snippets.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "eslint-disable": { - "prefix": "eslint-disable-block", - "body": [ - "/* eslint-disable ${1:INSERT_RULES|} */", - "$0/* eslint-enable ${1} */" - ], - "description": "ESLint disable wrapper" - }, - "eslint-disable-next-line": { - "prefix": "eslint-disable-next-line", - "body": ["// eslint-disable-next-line ${1:INSERT_RULES}"], - "description": "ESLint disable next line" - } -} diff --git a/src/extension.ts b/src/extension.ts index edb75c7..8707cf2 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -1,13 +1,12 @@ import { type ExtensionContext, Position, SnippetString, commands, window, workspace } from 'vscode' import type { ESLint } from 'eslint' -import { getTextBylines } from './utils' +import { existFile, getTextBylines } from './utils' import { workspacePath } from './global' import { constructESLint } from './eslint' import statusBarItem, { showStatusBarItem } from './statusBarItem' import log from './log' import config from './configuration' import path from 'node:path' -import fs from 'node:fs' let eslint: ESLint const lintingCache = new Map>() @@ -26,7 +25,6 @@ export async function activate(context: ExtensionContext) { return } - eslint = await constructESLint({ overrideConfig: { overrides: [ @@ -38,10 +36,8 @@ export async function activate(context: ExtensionContext) { }, }) - context.subscriptions.push(...disposes, statusBarItem.value) - log(`eslint-disable is activated!(${ Date.now() - _startTime }ms)!`) showStatusBarItem(`$(check) eslint-disable is activated!(${ Date.now() - _startTime }ms)!`) @@ -49,21 +45,25 @@ export async function activate(context: ExtensionContext) { if (config.preLinting) { window.activeTextEditor && void commands.executeCommand('eslint-disable.disable', true) window.onDidChangeActiveTextEditor(() => window.activeTextEditor && commands.executeCommand('eslint-disable.disable', true)) - workspace.onDidChangeTextDocument(event => { + + let timer: NodeJS.Timeout + workspace.onDidChangeTextDocument(async event => { const fileName = event.document.fileName - if (!checkFileExist(event.document.fileName) || !event.contentChanges.length) { + if (!await existFile(event.document.fileName) || !event.contentChanges.length) { return } /** * It seems that inserting `// eslint-disable` is no need to clear cache. * But in actually, the line numbers on cache would be changed. - * Maybe I should re-compute these line numbers later. + * Maybe I should re-compute these line numbers in later. */ if (lintingCache.has(fileName)) { lintingCache.delete(fileName) - log(`${ fileName } - Clear linting cache.`) + log(`${ path.basename(fileName) } - Clear linting cache. Re-Linting after 5s.`) + clearTimeout(timer) + timer = setTimeout(() => void commands.executeCommand('eslint-disable.disable', true), 5 * 1000) } }) } @@ -82,12 +82,12 @@ const disposes = [ const activeTextEditor = window.activeTextEditor! const fileName = activeTextEditor.document.fileName + const basename = path.basename(fileName) - if (!checkFileExist(fileName)) { + if (!await existFile(fileName)) { return } - if (activeTextEditor.selections.length > 1) { log('Sorry, we can not disable multi-selections for now. It will be supported in later version.', true, 'OK') return @@ -96,13 +96,12 @@ const disposes = [ log('πŸ‘‡πŸ‘‡πŸ‘‡πŸ‘‡πŸ‘‡πŸ‘‡') log(`eslint-disable services ${ fileName }`) - log('πŸ‘†πŸ‘†πŸ‘†πŸ‘†πŸ‘†πŸ‘†') let lineRuleIdsMap = lintingCache.get(fileName) if (!lineRuleIdsMap) { - log(`${ fileName } - Start linting file text...`) + log(`${ basename } - Start linting file text...`) showStatusBarItem('$(loading~spin) Start linting file text...', 0) // FIXME: A workaround. @@ -110,7 +109,7 @@ const disposes = [ const _startTime = Date.now() const results = await eslint.lintFiles(activeTextEditor.document.uri.fsPath) // By debugging, it is a sync task,which makes `statusBarItem.show` cloud not render immediately. - log(`${ fileName } - Linting finish(${ Date.now() - _startTime }ms).`) + log(`${ basename } - Linting finish(${ Date.now() - _startTime }ms).`) showStatusBarItem(`$(check) Linting finish(${ Date.now() - _startTime }ms).`) // eslint-disable-next-line require-atomic-updates @@ -126,33 +125,33 @@ const disposes = [ if (config.preLinting) { lintingCache.set(fileName, lineRuleIdsMap) - log(`${ fileName } - Set linting cache.`) + log(`${ basename } - Set linting cache.`) } } else { const parseFileName = path.parse(fileName).base - log(`${ fileName } - Linting cache found.`) + log(`${ basename } - Linting cache found.`) showStatusBarItem(`Linting cache found at ${ parseFileName }.`) } if (lineRuleIdsMap && !Object.keys(lineRuleIdsMap).length) { - log(`${ fileName } - Everything is good.`, !silent, 'OK') + log(`${ basename } - Everything is good.`, !silent, 'OK') return } else { - log(`${ fileName } - Problems found: ${ Object.values(lineRuleIdsMap).toString() } `) + log(`${ basename } - Problems found: ${ Object.values(lineRuleIdsMap).toString() } `) } !silent && activeTextEditor.selections.forEach(selection => { const text = getTextBylines(selection.start.line, selection.end.line) if (!text?.replace(/\n|\r/g, '')) { - log(`${ fileName } - No content to disable.`, true, 'OK') + log(`${ basename } - No content to disable.`, true, 'OK') return } if (!Object.keys(lineRuleIdsMap!).some(problemLine => selection.start.line + 1 <= +problemLine && +problemLine <= selection.end.line + 1)) { - log(`${ fileName } - No problem rules found from your selection.`, true, 'OK') + log(`${ basename } - No problem rules found from your selection.`, true, 'OK') return } @@ -210,14 +209,3 @@ const disposes = [ showStatusBarItem('$(check) Reloading finished.') }), ] - - -function checkFileExist(fileName: string) { - try { - fs.statSync(fileName) - } catch { - // log(`Skip, no such file: ${ fileName }`) - return false - } - return true -}