Skip to content

Commit 22dc29e

Browse files
committed
vue parser
1 parent 47ba3f8 commit 22dc29e

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

scripts/parsers.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Workaround for https://github.com/typescript-eslint/typescript-eslint/issues/117
66
import {Variable} from 'eslint-scope';
77
import typescriptEslintParserOriginal from '@typescript-eslint/parser';
88
import babelEslintParserOriginal from '@babel/eslint-parser';
9+
import vueEslintParserOriginal from 'vue-eslint-parser';
910

1011
function addGlobals(names) {
1112
const globalScope = this.scopes[0];
@@ -72,7 +73,9 @@ function fixParse(parse) {
7273
return function parseForESLint(...arguments_) {
7374
const result = parse(...arguments_);
7475

75-
result.scopeManager.addGlobals = addGlobals;
76+
if (result.scopeManager) {
77+
result.scopeManager.addGlobals ??= addGlobals;
78+
}
7679

7780
return result;
7881
};
@@ -87,3 +90,8 @@ export const babelEslintParser = {
8790
...babelEslintParserOriginal,
8891
parseForESLint: fixParse(babelEslintParserOriginal.parseForESLint),
8992
};
93+
94+
export const vueEslintParser = {
95+
...vueEslintParserOriginal,
96+
parseForESLint: fixParse(vueEslintParserOriginal.parseForESLint),
97+
};

test/utils/parsers.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
import {typescriptEslintParser, babelEslintParser} from '../../scripts/parsers.js';
2-
import vueEslintParser from 'vue-eslint-parser';
1+
import {
2+
typescriptEslintParser,
3+
babelEslintParser,
4+
vueEslintParser,
5+
} from '../../scripts/parsers.js';
36

47
const babelParser = {
58
name: 'babel',

0 commit comments

Comments
 (0)