Skip to content

Commit

Permalink
Patch ESLint in standalone build to make tree shaking easier, update …
Browse files Browse the repository at this point in the history
…build config and tests.
  • Loading branch information
joshwilsonvu committed Jun 19, 2024
1 parent 9074613 commit d75a579
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 15 deletions.
2 changes: 1 addition & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export default tseslint.config(
globals: globals.browser,
},
rules: {
...solid.configs['flat/recommended'].rules,
...solid.configs["flat/recommended"].rules,
"@typescript-eslint/ban-ts-comment": 0,
"@typescript-eslint/no-unused-vars": 0,
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
},
"lint-staged": {
"*!(test).{js,jsx,ts,tsx}": [
"eslint --ignore-pattern test/fixture/invalid --fix",
"pnpm lint --fix",
"prettier --write"
]
},
Expand Down
8 changes: 4 additions & 4 deletions standalone/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Linter } from "eslint";
import parser from "@typescript-eslint/parser";
import plugin from "../dist";
import { Linter } from "eslint/linter";
import * as parser from "@typescript-eslint/parser";
import plugin from "../dist/index.js";
import { version as pluginVersion } from "../package.json";
import memoizeOne from "memoize-one";

// Create linter instance
const linter = new Linter();
const linter = new Linter({ configType: "flat" });

const getConfig = memoizeOne((ruleSeverityOverrides) => {
const config = [
Expand Down
5 changes: 5 additions & 0 deletions standalone/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,10 @@
},
"dependencies": {
"@types/eslint": "^8.56.7"
},
"pnpm": {
"patchedDependencies": {
"eslint@8.57.0": "patches/eslint@8.57.0.patch"
}
}
}
22 changes: 22 additions & 0 deletions standalone/patches/eslint@8.57.0.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
diff --git a/package.json b/package.json
index a51b58b2444f41ead8b445f27003245b451f5728..48820932d33a3671c07e0f909017a2894d3ace06 100644
--- a/package.json
+++ b/package.json
@@ -10,7 +10,8 @@
"exports": {
"./package.json": "./package.json",
".": "./lib/api.js",
- "./use-at-your-own-risk": "./lib/unsupported-api.js"
+ "./use-at-your-own-risk": "./lib/unsupported-api.js",
+ "./linter": "./lib/linter/index.js"
},
"scripts": {
"build:docs:update-links": "node tools/fetch-docs-links.js",
@@ -175,5 +176,6 @@
"license": "MIT",
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
- }
+ },
+ "sideEffects": false
}
16 changes: 11 additions & 5 deletions standalone/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions standalone/rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,17 @@ export default {
},
{
// assert for web
match: /^assert$/u,
match: /^(node:)?assert$/u,
target: "./mock/assert.js",
},
{
// path for web
match: /^path$|^path\/posix$/u,
match: /^(node:)?path$|^path\/posix$/u,
target: "./mock/path.js",
},
{
// util for web
match: /^util$/u,
match: /^(node:)?util$/u,
target: "./mock/util.js",
},
{
Expand Down
3 changes: 2 additions & 1 deletion standalone/test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ assert.equal(typeof __dirname, 'undefined');
assert.equal(typeof plugin, "object");
assert.equal(typeof pluginVersion, "string");
assert.equal(typeof eslintVersion, "string");
assert.equal(eslintVersion[0], '8')
assert.equal(typeof verify, "function");
assert.equal(typeof verifyAndFix, "function");
Expand Down Expand Up @@ -77,7 +78,7 @@ const linker = (specifier) => {
"dist.js": dist,
}[specifier];
if (!mod) {
throw new Error("can't import other modules");
throw new Error(`can't import other modules: ${specifier}`);
}
return mod;
};
Expand Down

0 comments on commit d75a579

Please sign in to comment.