Skip to content

Commit

Permalink
Revert "perf: fix lazy loading of core rules (eslint#15606)"
Browse files Browse the repository at this point in the history
This reverts commit c40184d.
  • Loading branch information
srijan-deepsource committed May 30, 2022
1 parent 8700cc9 commit 5592ba4
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 123 deletions.
9 changes: 2 additions & 7 deletions lib/config/flat-config-array.js
Expand Up @@ -14,6 +14,7 @@ const { flatConfigSchema } = require("./flat-config-schema");
const { RuleValidator } = require("./rule-validator");
const { defaultConfig } = require("./default-config");
const recommendedConfig = require("../../conf/eslint-recommended");
const allConfig = require("../../conf/eslint-all");

//-----------------------------------------------------------------------------
// Helpers
Expand Down Expand Up @@ -78,13 +79,7 @@ class FlatConfigArray extends ConfigArray {
}

if (config === "eslint:all") {

/*
* Load `eslint-all.js` here instead of at the top level to avoid loading all rule modules
* when it isn't necessary. `eslint-all.js` reads `meta` of rule objects to filter out deprecated ones,
* so requiring `eslint-all.js` module loads all rule modules as a consequence.
*/
return require("../../conf/eslint-all");
return allConfig;
}

return config;
Expand Down
1 change: 0 additions & 1 deletion package.json
Expand Up @@ -122,7 +122,6 @@
"node-polyfill-webpack-plugin": "^1.0.3",
"npm-license": "^0.3.3",
"nyc": "^15.0.1",
"pirates": "^4.0.5",
"progress": "^2.0.3",
"proxyquire": "^2.0.1",
"puppeteer": "^9.1.1",
Expand Down
66 changes: 0 additions & 66 deletions tests/_utils/test-lazy-loading-rules.js

This file was deleted.

6 changes: 0 additions & 6 deletions tests/fixtures/lazy-loading-rules/.eslintrc.js

This file was deleted.

1 change: 0 additions & 1 deletion tests/fixtures/lazy-loading-rules/foo.js

This file was deleted.

42 changes: 0 additions & 42 deletions tests/lib/eslint/eslint.js
Expand Up @@ -27,7 +27,6 @@ const {
const hash = require("../../../lib/cli-engine/hash");
const { unIndent, createCustomTeardown } = require("../../_utils");
const coreRules = require("../../../lib/rules");
const childProcess = require("child_process");

//------------------------------------------------------------------------------
// Tests
Expand Down Expand Up @@ -6695,45 +6694,4 @@ describe("ESLint", () => {
});
});
});

describe("loading rules", () => {
it("should not load unused core rules", done => {
let calledDone = false;

const cwd = getFixturePath("lazy-loading-rules");
const pattern = "foo.js";
const usedRules = ["semi"];

const forkedProcess = childProcess.fork(
path.join(__dirname, "../../_utils/test-lazy-loading-rules.js"),
[cwd, pattern, String(usedRules)]
);

// this is an error message
forkedProcess.on("message", ({ message, stack }) => {
if (calledDone) {
return;
}
calledDone = true;

const error = new Error(message);

error.stack = stack;
done(error);
});

forkedProcess.on("exit", exitCode => {
if (calledDone) {
return;
}
calledDone = true;

if (exitCode === 0) {
done();
} else {
done(new Error("Forked process exited with a non-zero exit code"));
}
});
});
});
});

0 comments on commit 5592ba4

Please sign in to comment.