Skip to content

Commit 3c64544

Browse files
committedMay 1, 2024·
chore: update to eslint v9
1 parent d880b1e commit 3c64544

14 files changed

+394
-1133
lines changed
 

‎.eslintignore

-4
This file was deleted.

‎.eslintrc

-6
This file was deleted.

‎eslint.config.mjs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import unjs from "eslint-config-unjs";
2+
3+
export default unjs({
4+
ignores: [
5+
// ignore paths
6+
],
7+
rules: {
8+
// rule overrides
9+
},
10+
markdown: {
11+
rules: {
12+
// markdown rule overrides
13+
},
14+
},
15+
});

‎package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
"scripts": {
2121
"build": "unbuild",
2222
"dev": "vitest",
23-
"lint": "eslint --ext .ts,.js src test && prettier -c src test",
24-
"lint:fix": "eslint --ext .ts,.js src test --fix && prettier -w src test",
23+
"lint": "eslint src test && prettier -c src test",
24+
"lint:fix": "eslint src test --fix && prettier -w src test",
2525
"release": "pnpm test && pnpm build && changelogen --release && npm publish && git push --follow-tags",
2626
"test": "pnpm lint && pnpm test:types && vitest run",
2727
"test:types": "tsc --noEmit"
@@ -36,8 +36,8 @@
3636
"@types/node": "^20.12.7",
3737
"@vitest/coverage-v8": "^1.5.3",
3838
"changelogen": "^0.5.5",
39-
"eslint": "^8.57.0",
40-
"eslint-config-unjs": "^0.2.1",
39+
"eslint": "^9.1.1",
40+
"eslint-config-unjs": "0.3.0-rc.7",
4141
"import-meta-resolve": "^4.1.0",
4242
"jiti": "^1.21.0",
4343
"prettier": "^3.2.5",

‎pnpm-lock.yaml

+358-1,105
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/analyze.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { tokenizer } from "acorn";
22
import { matchAll, clearImports, getImportNames } from "./_utils";
3-
import { resolvePath, ResolveOptions } from "./resolve";
3+
import { resolvePath, type ResolveOptions } from "./resolve";
44
import { loadURL } from "./utils";
55

66
/**
@@ -453,7 +453,7 @@ export function findExports(code: string): ESMExport[] {
453453
});
454454

455455
// Merge and normalize exports
456-
// eslint-disable-next-line unicorn/no-array-push-push
456+
457457
const exports: ESMExport[] = normalizeExports([
458458
...declaredExports,
459459
...namedExports,
@@ -652,7 +652,9 @@ function _filterStatement<T extends TokenLocation>(
652652
function _tryGetLocations(code: string, label: string) {
653653
try {
654654
return _getLocations(code, label);
655-
} catch {}
655+
} catch {
656+
// Ignore error
657+
}
656658
}
657659

658660
function _getLocations(code: string, label: string) {

‎src/cjs.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export interface CommonjsContext {
1717
*/
1818
__dirname: string;
1919
// TODO!
20-
// eslint-disable-next-line no-undef
20+
2121
/**
2222
* A function to require modules as in CommonJS.
2323
*/
@@ -81,7 +81,9 @@ export function interopDefault(
8181
},
8282
});
8383
}
84-
} catch {}
84+
} catch {
85+
// Ignore error
86+
}
8587
}
8688
return defaultValue;
8789
}

‎test/exports.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ describe("findExports", () => {
7070
specifier: "./other",
7171
name: "foo",
7272
},
73-
// eslint-disable-next-line no-template-curly-in-string
73+
7474
"const a = `<div${JSON.stringify({ class: 42 })}>`;\nexport default true;":
7575
{ type: "default", name: "default", names: ["default"] },
7676
"export const enum foo { a = 'xx' }": {

‎test/fixture/eval-err.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// @ts-nocheck
2-
// eslint-disable-next-line require-await
2+
33
async function test() {
44
throw new Error("Something went wrong in eval-err module!");
55
}

‎test/fixture/eval.mjs

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ console.log(
2020
),
2121
);
2222

23-
await loadModule("./eval-err.mjs", { url: import.meta.url }).catch((e) =>
24-
console.error(e),
23+
await loadModule("./eval-err.mjs", { url: import.meta.url }).catch((error) =>
24+
console.error(error),
2525
);

‎test/fixture/imports/js-cjs/index.js

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// eslint-disable-next-line unicorn/prefer-module
21
module.exports = "js-cjs";
32

43
console.log(import("node:fs"));

‎test/fixture/imports/mixed/index.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable unicorn/prefer-module */
21
export const isCrtAvailable = () => {
32
try {
43
if (
@@ -8,5 +7,7 @@ export const isCrtAvailable = () => {
87
) {
98
return ["md/crt-avail"];
109
}
11-
} catch {}
10+
} catch {
11+
// Ignore error
12+
}
1213
};

‎test/fixture/utils.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export function reverse(str) {
2-
return str.split("").reverse().join("");
2+
return [...str].reverse().join("");
33
}

‎test/utils.test.ts

-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ describe("parseNodeModulePath", () => {
106106
});
107107

108108
describe("lookupNodeModuleSubpath", () => {
109-
// eslint-disable-next-line unicorn/consistent-function-scoping
110109
const r = (p: string) => new URL(p, import.meta.url).toString();
111110

112111
const tests = [

0 commit comments

Comments
 (0)
Please sign in to comment.