Skip to content

Commit 504a138

Browse files
committedJul 11, 2024
migrate to ESLint flat config
1 parent dbe081f commit 504a138

7 files changed

+90
-36
lines changed
 

‎.eslintignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
lib
22
esm
33
umd
4-
.eslintrc.js
4+
eslint.config.js

‎.eslintrc.js

-20
This file was deleted.

‎eslint.config.js

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import globals from "globals";
2+
import eslint from "@eslint/js";
3+
import tsEslint from "typescript-eslint";
4+
import eslintConfigPrettier from "eslint-config-prettier";
5+
import eslintPluginJest from "eslint-plugin-jest";
6+
7+
/** @type {import("eslint").Linter.FlatConfig[]} */
8+
export default tsEslint.config(
9+
{
10+
ignores: ["lib/**", "esm/**", "umd/**"],
11+
extends: [
12+
eslint.configs.recommended,
13+
...tsEslint.configs.recommended,
14+
eslintConfigPrettier,
15+
],
16+
languageOptions: {
17+
globals: {
18+
...globals.jest,
19+
},
20+
parser: tsEslint.parser,
21+
parserOptions: {
22+
sourceType: "module",
23+
project: "./tsconfig.eslint.json",
24+
},
25+
},
26+
plugins: {
27+
"@typescript-eslint": tsEslint.plugin,
28+
},
29+
},
30+
{
31+
files: ["**/tests/**/*.test.ts"],
32+
...eslintPluginJest.configs["flat/recommended"],
33+
},
34+
);

‎jest.config.js renamed to ‎jest.config.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module.exports = {
1+
export default {
22
moduleFileExtensions: ["ts", "js"],
33
transform: {
44
"^.+\\.(ts|tsx)$": "ts-jest",

‎package-lock.json

+45-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "@progfay/scrapbox-parser",
33
"version": "9.0.0",
4+
"type": "module",
45
"description": "parse Scrapbox notation to JavaScript Object",
56
"files": [
67
"lib",
@@ -28,12 +29,12 @@
2829
"test:update": "jest --updateSnapshot --no-cache",
2930
"lint": "run-p lint:*",
3031
"lint:prettier": "prettier --check .",
31-
"lint:eslint": "eslint -c ./.eslintrc.js .",
32+
"lint:eslint": "eslint .",
3233
"lint:cspell": "cspell --no-summary '**/*'",
3334
"lint:typescript": "tsc -p ./tsconfig.eslint.json",
3435
"format": "run-s format:prettier format:eslint",
3536
"format:prettier": "prettier --write .",
36-
"format:eslint": "eslint --fix -c ./.eslintrc.js ."
37+
"format:eslint": "eslint --fix ."
3738
},
3839
"repository": {
3940
"type": "git",
@@ -53,10 +54,9 @@
5354
"@babel/core": "7.24.7",
5455
"@babel/preset-env": "7.24.7",
5556
"@types/core-js": "2.5.8",
57+
"@types/eslint": "8.56.10",
5658
"@types/jest": "29.5.12",
5759
"@types/node": "20.14.10",
58-
"@typescript-eslint/eslint-plugin": "7.16.0",
59-
"@typescript-eslint/parser": "7.16.0",
6060
"babel-loader": "9.1.3",
6161
"cspell": "8.10.4",
6262
"eslint": "8.57.0",
@@ -69,6 +69,7 @@
6969
"ts-jest": "29.2.2",
7070
"ts-loader": "9.5.1",
7171
"typescript": "5.5.3",
72+
"typescript-eslint": "7.16.0",
7273
"webpack": "5.92.1",
7374
"webpack-cli": "5.1.4"
7475
},

‎webpack.config.js renamed to ‎webpack.config.mjs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
module.exports = {
1+
import path from "node:path";
2+
3+
export default {
24
mode: "production",
35
entry: "./src/index.ts",
46
output: {
57
// eslint-disable-next-line @typescript-eslint/no-var-requires
6-
path: require("path").resolve(__dirname, "umd"),
8+
path: path.resolve(import.meta.dirname, "umd"),
79
filename: "scrapbox-parser.js",
810
library: "ScrapboxParser",
911
libraryTarget: "umd",

0 commit comments

Comments
 (0)
Please sign in to comment.