Skip to content

Commit 2ca71cc

Browse files
committed
Fixed issue with eslint-standalone rollup not removing all process.env checks.
1 parent 9e0d8ee commit 2ca71cc

File tree

2 files changed

+32
-20
lines changed

2 files changed

+32
-20
lines changed

standalone/rollup.config.js

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ module.exports = {
1717
external: ["vs/language/typescript/tsWorker", "typescript"],
1818
plugins: [
1919
replace({
20-
// verbose: true,
20+
verbose: true,
2121
alias: [
2222
// import eslint from eslint-plugin-solid deps for consistency with ../dist
2323
{
@@ -85,40 +85,44 @@ module.exports = {
8585
{
8686
// we do not want dynamic imports
8787
match: /eslint\/lib\/linter\/rules\.js$/u,
88-
test: /require\(this\._rules\[ruleId\]\)/u,
88+
test: /require\(this\._rules\[ruleId\]\)/g,
8989
replace: "null",
9090
},
9191
{
9292
// esquery has both browser and node versions, we are bundling browser version that has different export
93-
test: /esquery\.parse\(/u,
93+
test: /esquery\.parse\(/g,
9494
replace: "esquery.default.parse(",
9595
},
9696
{
9797
// esquery has both browser and node versions, we are bundling browser version that has different export
98-
test: /esquery\.matches\(/u,
98+
test: /esquery\.matches\(/g,
9999
replace: "esquery.default.matches(",
100100
},
101101
{
102-
// replace all process.env.NODE_DEBUG with false
103-
test: /process\.env\.NODE_DEBUG/u,
104-
replace: "false",
105-
},
106-
{
107-
// replace all process.env.TIMING with false
108-
test: /process\.env\.TIMING/u,
102+
// replace these env vars with false
103+
test: /process\.env\.(?:DEBUG|NODE_DEBUG|TIMING)/g,
109104
replace: "false",
110105
},
111106
{
112107
// replace all process.env.IGNORE_TEST_WIN32 with true
113-
test: /process\.env\.IGNORE_TEST_WIN32/u,
108+
test: /process\.env\.IGNORE_TEST_WIN32/g,
114109
replace: "true",
115110
},
116111
{
117-
test: /process.cwd\(\)/u,
112+
// mock all other env vars as unset
113+
test: /process\.env\.\w+/gu,
114+
replace: "undefined",
115+
},
116+
{
117+
test: /process.cwd\(\)/g,
118118
replace: "'~'",
119119
},
120120
{
121-
test: /__filename/u,
121+
test: /process\.emitWarning/g,
122+
replace: "console.log",
123+
},
124+
{
125+
test: /__filename/g,
122126
replace: "''",
123127
},
124128
],

standalone/smoke-test.mjs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
1+
/* eslint-env node */
12
import { verifyAndFix } from "./dist.mjs";
23
import assert from "assert";
34

4-
// ensure that dist.mjs runs without crashing and returns results
5-
assert.deepStrictEqual(verifyAndFix('let el = <div className="red" />'), {
6-
fixed: true,
7-
messages: [],
8-
output: 'let el = <div class="red" />',
9-
});
5+
const p = global.process;
6+
global.process = {};
7+
8+
try {
9+
// ensure that dist.mjs runs without crashing and returns results
10+
assert.deepStrictEqual(verifyAndFix('let el = <div className="red" />'), {
11+
fixed: true,
12+
messages: [],
13+
output: 'let el = <div class="red" />',
14+
});
15+
} finally {
16+
global.process = p;
17+
}

0 commit comments

Comments
 (0)