Skip to content

Commit

Permalink
Fix crash of eslint cannot find eslint-plugin-vue
Browse files Browse the repository at this point in the history
  • Loading branch information
octref committed Mar 4, 2020
1 parent 62ffca7 commit 40571f9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"buefy-helper-json": "^1.0.2",
"element-helper-json": "^2.0.6",
"eslint": "^6.8.0",
"eslint-plugin-vue": "^6.0.1",
"eslint-plugin-vue": "^6.2.1",
"gridsome-helper-json": "^1.0.3",
"js-beautify": "^1.10.0",
"lodash": "^4.17.4",
Expand Down
4 changes: 4 additions & 0 deletions server/src/modes/template/services/htmlValidation.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { CLIEngine, Linter } from 'eslint';
import { configs } from 'eslint-plugin-vue';
import { TextDocument, Diagnostic, Range, DiagnosticSeverity } from 'vscode-languageserver-types';
import { resolve } from 'path';

function toDiagnostic(error: Linter.LintMessage): Diagnostic {
const line = error.line - 1;
Expand Down Expand Up @@ -28,8 +29,11 @@ export function doESLintValidation(document: TextDocument, engine: CLIEngine): D
}

export function createLintEngine() {
const SERVER_ROOT = resolve(__dirname, '../../../../');
return new CLIEngine({
useEslintrc: false,
// So ESLint can find the bundled eslint-plugin-vue
cwd: SERVER_ROOT,
...configs.base,
...configs.essential
});
Expand Down
9 changes: 5 additions & 4 deletions server/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1439,11 +1439,12 @@ escape-string-regexp@1.0.5, escape-string-regexp@^1.0.2, escape-string-regexp@^1
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4"
integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=

eslint-plugin-vue@^6.0.1:
version "6.1.2"
resolved "https://registry.yarnpkg.com/eslint-plugin-vue/-/eslint-plugin-vue-6.1.2.tgz#4b05c28c83c0ec912669b64dbd998bb8bf692ef6"
integrity sha512-M75oAB+2a/LNkLKRbeEaS07EjzjIUaV7/hYoHAfRFeeF8ZMmCbahUn8nQLsLP85mkar24+zDU3QW2iT1JRsACw==
eslint-plugin-vue@^6.2.1:
version "6.2.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-vue/-/eslint-plugin-vue-6.2.1.tgz#ca802df5c33146aed1e56bb21d250c1abb6120a3"
integrity sha512-MiIDOotoWseIfLIfGeDzF6sDvHkVvGd2JgkvjyHtN3q4RoxdAXrAMuI3SXTOKatljgacKwpNAYShmcKZa4yZzw==
dependencies:
natural-compare "^1.4.0"
semver "^5.6.0"
vue-eslint-parser "^7.0.0"

Expand Down

0 comments on commit 40571f9

Please sign in to comment.