зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1878009
- Remove Babel integration from ESLint. r=mossop,devtools-reviewers,nchevobbe
Differential Revision: https://phabricator.services.mozilla.com/D200365
This commit is contained in:
Родитель
fa2a8be440
Коммит
56cc7346e1
19
.eslintrc.js
19
.eslintrc.js
|
@ -55,13 +55,6 @@ const httpTestingPaths = [
|
|||
];
|
||||
|
||||
module.exports = {
|
||||
parser: "@babel/eslint-parser",
|
||||
parserOptions: {
|
||||
sourceType: "script",
|
||||
babelOptions: {
|
||||
configFile: path.join(__dirname, ".babel-eslint.rc.js"),
|
||||
},
|
||||
},
|
||||
settings: {
|
||||
"import/extensions": [".mjs"],
|
||||
},
|
||||
|
@ -84,6 +77,18 @@ module.exports = {
|
|||
browser: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
files: [
|
||||
"**/*.jsx",
|
||||
"browser/components/pocket/content/**/*.js",
|
||||
"browser/components/storybook/.storybook/**/*.mjs",
|
||||
],
|
||||
parserOptions: {
|
||||
ecmaFeatures: {
|
||||
jsx: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ["browser/components/storybook/**"],
|
||||
env: {
|
||||
|
|
|
@ -155,6 +155,16 @@ module.exports = {
|
|||
"mozilla/specific": false,
|
||||
},
|
||||
},
|
||||
{
|
||||
files: [
|
||||
"client/inspector/markup/test/doc_markup_events_react_*_jsx.html",
|
||||
],
|
||||
parserOptions: {
|
||||
ecmaFeatures: {
|
||||
jsx: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
rules: {
|
||||
// These are the rules that have been configured so far to match the
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
|
||||
|
||||
module.exports = {
|
||||
plugins: ["react", "mozilla", "@babel", "import", "file-header"],
|
||||
plugins: ["react", "mozilla", "import", "file-header"],
|
||||
globals: {
|
||||
atob: true,
|
||||
btoa: true,
|
||||
|
@ -32,13 +32,6 @@ module.exports = {
|
|||
ecmaVersion: "latest",
|
||||
sourceType: "module",
|
||||
ecmaFeatures: { jsx: true },
|
||||
|
||||
// When the linter runs from the MC root, it won't pick up this project's
|
||||
// babel.config.js, so we explicitly set Babel's root location so that
|
||||
// it knows where to look.
|
||||
babelOptions: {
|
||||
root: __dirname,
|
||||
},
|
||||
},
|
||||
env: {
|
||||
es6: true,
|
||||
|
|
|
@ -5,10 +5,15 @@
|
|||
"use strict";
|
||||
|
||||
module.exports = {
|
||||
env: {
|
||||
"mozilla/browser-window": true,
|
||||
},
|
||||
|
||||
overrides: [
|
||||
{
|
||||
files: "./**/*.?(m)js",
|
||||
excludedFiles: "aboutwebrtc/**",
|
||||
env: {
|
||||
"mozilla/browser-window": true,
|
||||
},
|
||||
},
|
||||
],
|
||||
plugins: ["mozilla"],
|
||||
|
||||
rules: {
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
module.exports = {
|
||||
env: {
|
||||
browser: true,
|
||||
es2021: true,
|
||||
es2022: true,
|
||||
"mozilla/privileged": true,
|
||||
"mozilla/specific": true,
|
||||
},
|
||||
|
@ -83,6 +83,9 @@ module.exports = {
|
|||
},
|
||||
{
|
||||
files: ["**/*.mjs"],
|
||||
parserOptions: {
|
||||
sourceType: "module",
|
||||
},
|
||||
rules: {
|
||||
"mozilla/use-static-import": "error",
|
||||
// This rule defaults to not allowing "use strict" in module files since
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
"use strict";
|
||||
|
||||
const parser = require("@babel/eslint-parser");
|
||||
const parser = require("espree");
|
||||
const { analyze } = require("eslint-scope");
|
||||
const { KEYS: defaultVisitorKeys } = require("eslint-visitor-keys");
|
||||
const estraverse = require("estraverse");
|
||||
|
@ -96,18 +96,19 @@ module.exports = {
|
|||
// can parse.
|
||||
let config = { ...this.getPermissiveConfig(configOptions), ...astOptions };
|
||||
|
||||
let parseResult =
|
||||
"parseForESLint" in parser
|
||||
? parser.parseForESLint(sourceText, config)
|
||||
: { ast: parser.parse(sourceText, config) };
|
||||
let parseResult = parser.parse(sourceText, config);
|
||||
|
||||
let visitorKeys = parseResult.visitorKeys || defaultVisitorKeys;
|
||||
visitorKeys.ExperimentalRestProperty = visitorKeys.RestElement;
|
||||
visitorKeys.ExperimentalSpreadProperty = visitorKeys.SpreadElement;
|
||||
|
||||
// eslint-scope doesn't support "latest" as a version, so we pass a really
|
||||
// big number to ensure this always reads as the latest.
|
||||
// xref https://github.com/eslint/eslint-scope/issues/74
|
||||
config.ecmaVersion =
|
||||
config.ecmaVersion == "latest" ? 1e8 : config.ecmaVersion;
|
||||
|
||||
return {
|
||||
ast: parseResult.ast,
|
||||
scopeManager: parseResult.scopeManager || analyze(parseResult.ast),
|
||||
ast: parseResult,
|
||||
scopeManager: parseResult.scopeManager || analyze(parseResult, config),
|
||||
visitorKeys,
|
||||
};
|
||||
},
|
||||
|
@ -285,33 +286,14 @@ module.exports = {
|
|||
* Espree compatible permissive config.
|
||||
*/
|
||||
getPermissiveConfig({ useBabel = true } = {}) {
|
||||
const config = {
|
||||
return {
|
||||
range: true,
|
||||
requireConfigFile: false,
|
||||
babelOptions: {
|
||||
// configFile: path.join(gRootDir, ".babel-eslint.rc.js"),
|
||||
// parserOpts: {
|
||||
// plugins: [
|
||||
// "@babel/plugin-proposal-class-static-block",
|
||||
// "@babel/plugin-syntax-class-properties",
|
||||
// "@babel/plugin-syntax-jsx",
|
||||
// ],
|
||||
// },
|
||||
},
|
||||
loc: true,
|
||||
comment: true,
|
||||
attachComment: true,
|
||||
ecmaVersion: this.getECMAVersion(),
|
||||
sourceType: "script",
|
||||
};
|
||||
|
||||
if (useBabel && this.isMozillaCentralBased()) {
|
||||
config.babelOptions.configFile = path.join(
|
||||
gRootDir,
|
||||
".babel-eslint.rc.js"
|
||||
);
|
||||
}
|
||||
return config;
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -214,10 +214,6 @@ def expected_eslint_modules():
|
|||
)
|
||||
with open(mozilla_json_path, encoding="utf-8") as f:
|
||||
dependencies = json.load(f).get("dependencies", {})
|
||||
# Bug 1860508: We skip checking eslint-visitor-keys because the Babel
|
||||
# dependencies currently require an older version to that which
|
||||
# eslint-plugin-mozilla requires.
|
||||
dependencies.pop("eslint-visitor-keys")
|
||||
expected_modules.update(dependencies)
|
||||
|
||||
# Also read the in-tree ESLint plugin spidermonkey information, to ensure the
|
||||
|
|
Загрузка…
Ссылка в новой задаче