add workaround for broken eslint-scope package regarding class field support

This commit is contained in:
Tobias Koppers 2021-05-19 12:55:00 +02:00
parent 1d2253fdab
commit 4cf272b824
6 changed files with 58 additions and 2 deletions

View File

@ -6,6 +6,7 @@
"use strict"; "use strict";
const eslintScope = require("eslint-scope"); const eslintScope = require("eslint-scope");
const Referencer = require("eslint-scope/lib/referencer");
const { const {
CachedSource, CachedSource,
ConcatSource, ConcatSource,
@ -58,6 +59,14 @@ const {
/** @typedef {import("../util/fs").InputFileSystem} InputFileSystem */ /** @typedef {import("../util/fs").InputFileSystem} InputFileSystem */
/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */ /** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
// fix eslint-scope to support class properties correctly
// cspell:word Referencer
const ReferencerClass = Referencer;
if (!ReferencerClass.prototype.PropertyDefinition) {
ReferencerClass.prototype.PropertyDefinition =
ReferencerClass.prototype.Property;
}
/** /**
* @typedef {Object} ReexportInfo * @typedef {Object} ReexportInfo
* @property {Module} module * @property {Module} module

View File

@ -15,7 +15,7 @@
"chrome-trace-event": "^1.0.2", "chrome-trace-event": "^1.0.2",
"enhanced-resolve": "^5.8.0", "enhanced-resolve": "^5.8.0",
"es-module-lexer": "^0.4.0", "es-module-lexer": "^0.4.0",
"eslint-scope": "^5.1.1", "eslint-scope": "5.1.1",
"events": "^3.2.0", "events": "^3.2.0",
"glob-to-regexp": "^0.4.1", "glob-to-regexp": "^0.4.1",
"graceful-fs": "^4.2.4", "graceful-fs": "^4.2.4",

View File

@ -0,0 +1,21 @@
import { A, B } from "./module";
import { A as A1, B as B1 } from "./module?1";
it("should not rename class properties", function () {
expect(A.staticProp).toBe("value");
expect(B.staticProp).toBe("value");
expect(A1.staticProp).toBe("value");
expect(B1.staticProp).toBe("value");
expect(A.value).toBe("value");
expect(B.value).toBe("value");
expect(A1.value).toBe("value");
expect(B1.value).toBe("value");
expect(new A().prop).toBe("value");
expect(new B().prop).toBe("value");
expect(new A1().prop).toBe("value");
expect(new B1().prop).toBe("value");
expect(new A().value).toBe("value");
expect(new B().value).toBe("value");
expect(new A1().value).toBe("value");
expect(new B1().value).toBe("value");
});

View File

@ -0,0 +1,21 @@
import {
staticProp as importedStaticProp,
prop as importedProp
} from "./module";
export const staticProp = "value";
export const prop = "value";
export class A {
static staticProp = staticProp;
static [staticProp] = staticProp;
prop = prop;
[prop] = prop;
}
export class B {
static staticProp = importedStaticProp;
static [importedStaticProp] = importedStaticProp;
prop = importedProp;
[importedProp] = importedProp;
}

View File

@ -0,0 +1,5 @@
var supportsClassFields = require("../../../helpers/supportsClassFields");
module.exports = function (config) {
return supportsClassFields();
};

View File

@ -2563,7 +2563,7 @@ eslint-plugin-prettier@^3.1.4:
dependencies: dependencies:
prettier-linter-helpers "^1.0.0" prettier-linter-helpers "^1.0.0"
eslint-scope@^5.0.0, eslint-scope@^5.1.1: eslint-scope@5.1.1, eslint-scope@^5.0.0, eslint-scope@^5.1.1:
version "5.1.1" version "5.1.1"
resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.1.1.tgz#e786e59a66cb92b3f6c1fb0d508aab174848f48c" resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.1.1.tgz#e786e59a66cb92b3f6c1fb0d508aab174848f48c"
integrity sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw== integrity sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==