From ab616aa93b18964761d0c5e85c88a29601264d67 Mon Sep 17 00:00:00 2001 From: Ian VanSchooten Date: Tue, 19 Mar 2024 09:27:56 -0400 Subject: [PATCH 1/2] Update ESLint --- package.json | 4 ++-- pnpm-lock.yaml | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 1b0cec0..f625264 100644 --- a/package.json +++ b/package.json @@ -31,8 +31,8 @@ "devDependencies": { "c8": "^7.11.3", "clean-publish": "^3.4.2", - "eslint": "^8.0.1", - "eslint-plugin-no-only-tests": "^2.6.0", + "eslint": "^8.57.0", + "eslint-plugin-no-only-tests": "^3.1.0", "postcss": "^8.3.11", "prettier": "^2.6.2", "vite": "^2.9.9", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 65481dc..fe497dc 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -17,11 +17,11 @@ devDependencies: specifier: ^3.4.2 version: 3.4.5 eslint: - specifier: ^8.0.1 + specifier: ^8.57.0 version: 8.57.0 eslint-plugin-no-only-tests: - specifier: ^2.6.0 - version: 2.6.0 + specifier: ^3.1.0 + version: 3.1.0 postcss: specifier: ^8.3.11 version: 8.4.36 @@ -593,9 +593,9 @@ packages: engines: {node: '>=10'} dev: true - /eslint-plugin-no-only-tests@2.6.0: - resolution: {integrity: sha512-T9SmE/g6UV1uZo1oHAqOvL86XWl7Pl2EpRpnLI8g/bkJu+h7XBCB+1LnubRZ2CUQXj805vh4/CYZdnqtVaEo2Q==} - engines: {node: '>=4.0.0'} + /eslint-plugin-no-only-tests@3.1.0: + resolution: {integrity: sha512-Lf4YW/bL6Un1R6A76pRZyE1dl1vr31G/ev8UzIc/geCgFWyrKil8hVjYqWVKGB/UIGmb6Slzs9T0wNezdSVegw==} + engines: {node: '>=5.0.0'} dev: true /eslint-scope@7.2.2: From 332d1a89f6224937043751d0ad6c7a90174ff9a8 Mon Sep 17 00:00:00 2001 From: Ian VanSchooten Date: Tue, 19 Mar 2024 09:52:58 -0400 Subject: [PATCH 2/2] Convert eslint to flat config --- .eslintrc.js | 24 ------------------------ .vscode/settings.json | 3 +++ eslint.config.mjs | 28 ++++++++++++++++++++++++++++ index.test.mjs | 2 +- package.json | 1 + pnpm-lock.yaml | 3 +++ 6 files changed, 36 insertions(+), 25 deletions(-) delete mode 100644 .eslintrc.js create mode 100644 .vscode/settings.json create mode 100644 eslint.config.mjs diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 1e4629f..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1,24 +0,0 @@ -module.exports = { - parserOptions: { - ecmaVersion: 2022, - }, - env: { - node: true, - es6: true, - }, - plugins: ["no-only-tests"], - extends: ["eslint:recommended"], - overrides: [ - { - files: "*.mjs", - parserOptions: { - sourceType: "module", - }, - }, - // Prevent .only in tests - { - files: ["src/**/*.test.{ts,tsx}"], - rules: { "no-only-tests/no-only-tests": "error" }, - }, - ], -}; diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..eb8204b --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "eslint.experimental.useFlatConfig": true +} diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 0000000..79c79ba --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,28 @@ +import noOnlyPlugin from "eslint-plugin-no-only-tests"; +import eslint from "@eslint/js"; + +export default [ + eslint.configs.recommended, + { + rules: { + semi: "error", + "prefer-const": "error", + }, + }, + { + files: ["**/*.js"], + languageOptions: { + globals: { + require: "readonly", + module: "readonly", + }, + }, + }, + // Prevent .only in tests + { + plugins: { + "no-only-tests": noOnlyPlugin, + }, + rules: { "no-only-tests/no-only-tests": "error" }, + }, +]; diff --git a/index.test.mjs b/index.test.mjs index 679915b..437517e 100644 --- a/index.test.mjs +++ b/index.test.mjs @@ -12,7 +12,7 @@ function format(css) { } async function run(input, output, opts, postcssOpts = {}) { - let result = await postcss([plugin(opts)]).process(input, postcssOpts); + const result = await postcss([plugin(opts)]).process(input, postcssOpts); expect(format(result.css)).toEqual(format(output)); expect(result.warnings()).toHaveLength(0); } diff --git a/package.json b/package.json index f625264..a2c4a3f 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,7 @@ "postcss": "^8.3.0" }, "devDependencies": { + "@eslint/js": "^8.57.0", "c8": "^7.11.3", "clean-publish": "^3.4.2", "eslint": "^8.57.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index fe497dc..69f1bd6 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -10,6 +10,9 @@ dependencies: version: 4.2.1 devDependencies: + '@eslint/js': + specifier: ^8.57.0 + version: 8.57.0 c8: specifier: ^7.11.3 version: 7.14.0