Skip to content

Commit

Permalink
Add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nzakas committed Nov 12, 2021
1 parent a20e642 commit cee5632
Show file tree
Hide file tree
Showing 2 changed files with 1,214 additions and 133 deletions.
46 changes: 25 additions & 21 deletions lib/linter/linter.js
Original file line number Diff line number Diff line change
Expand Up @@ -757,27 +757,6 @@ function parse(text, languageOptions, filePath) {
filePath
});

// Espree expects this information to be passed in
if (isEspree(parser)) {
if (languageOptions.ecmaVersion) {
parserOptions.ecmaVersion = languageOptions.ecmaVersion;
}

if (languageOptions.sourceType) {

// normalize for CommonJS
if (languageOptions.sourceType === "commonjs") {
parserOptions.sourceType = "script";
parserOptions.ecmaFeatures = {
globalReturn: true,
...parserOptions.ecmaFeatures
};
} else {
parserOptions.sourceType = languageOptions.sourceType;
}
}
}

/*
* Check for parsing errors first. If there's a parsing error, nothing
* else can happen. However, a parsing error does not throw an error
Expand Down Expand Up @@ -1555,6 +1534,31 @@ class Linter {
...(languageOptions.sourceType === "commonjs" ? globals.commonjs : void 0),
...languageOptions.globals
};

// Espree expects this information to be passed in
if (isEspree(languageOptions.parser)) {

const parserOptions = languageOptions.parserOptions;

if (languageOptions.ecmaVersion) {
parserOptions.ecmaVersion = languageOptions.ecmaVersion;
}

if (languageOptions.sourceType) {

// normalize for CommonJS
if (languageOptions.sourceType === "commonjs") {
parserOptions.sourceType = "script";
parserOptions.ecmaFeatures = {
globalReturn: true,
...parserOptions.ecmaFeatures
};
} else {
parserOptions.sourceType = languageOptions.sourceType;
}
}
}

const settings = config.settings || {};

if (!slots.lastSourceCode) {
Expand Down

0 comments on commit cee5632

Please sign in to comment.