From 73ae3cc71add8da9e581dfc70cdf79c143aaf171 Mon Sep 17 00:00:00 2001 From: John Kenny Date: Sat, 16 Nov 2024 15:12:24 -0800 Subject: [PATCH] chore: update eslint config --- eslint.config.mjs => eslint.config.js | 22 +++---------------- lib/stop-offset.js | 2 +- package.json | 2 +- plugins/mergeGradients.js | 4 ++-- .../config-loader/cjs/svgo.config.cjs | 2 ++ test/svgo.cjs | 2 ++ yarn.lock | 4 ++-- 7 files changed, 13 insertions(+), 25 deletions(-) rename eslint.config.mjs => eslint.config.js (56%) diff --git a/eslint.config.mjs b/eslint.config.js similarity index 56% rename from eslint.config.mjs rename to eslint.config.js index bad280f..c86f4bb 100644 --- a/eslint.config.mjs +++ b/eslint.config.js @@ -1,23 +1,10 @@ import js from '@eslint/js'; import globals from 'globals'; -/** - * @typedef {import('eslint').Linter.FlatConfig} FlatConfig - */ - -/** @type {FlatConfig[]} */ export default [ + js.configs.recommended, { - ignores: [ - '.yarn/**', - '.yarnrc.yml', - 'node_modules/**', - 'dist/**', - 'test/regression-fixtures/**', - 'test/regression-diffs/**', - 'test/cli/output/**', - 'coverage/**', - ], + ignores: ['dist/**'], }, { languageOptions: { @@ -29,10 +16,7 @@ export default [ linterOptions: { reportUnusedDisableDirectives: 'error', }, - }, - js.configs.recommended, - { - files: ['**/*.js', '**/*.mjs'], + files: ['**/*.js', '**/*.cjs', '**/*.mjs'], rules: { strict: 'error', }, diff --git a/lib/stop-offset.js b/lib/stop-offset.js index 2274e8c..d441fd2 100644 --- a/lib/stop-offset.js +++ b/lib/stop-offset.js @@ -31,7 +31,7 @@ export class StopOffsetValue extends AttValue { } /** - * @param {string|AttValue} value + * @param {string|import('./types.js').AttValue} value * @returns {StopOffsetValue} */ static getStopOffsetObj(value) { diff --git a/package.json b/package.json index 3cef03e..81093b2 100644 --- a/package.json +++ b/package.json @@ -75,7 +75,7 @@ "sax": "^1.4.1" }, "devDependencies": { - "@eslint/js": "^9.14.0", + "@eslint/js": "^9.15.0", "@rollup/plugin-commonjs": "^28.0.1", "@rollup/plugin-node-resolve": "^15.3.0", "@rollup/plugin-terser": "^0.4.4", diff --git a/plugins/mergeGradients.js b/plugins/mergeGradients.js index 2f2d0ec..88d807b 100644 --- a/plugins/mergeGradients.js +++ b/plugins/mergeGradients.js @@ -45,7 +45,7 @@ export const fn = (root, params, info) => { return; } - const gradientId = element.attributes.id; + const gradientId = element.attributes.id.toString(); if (!gradientId) { return; } @@ -78,7 +78,7 @@ export const fn = (root, params, info) => { // Update all references. addChildToDelete(childrenToDelete, duplicate); - const dupId = duplicate.attributes.id; + const dupId = duplicate.attributes.id.toString(); const dupReferencingEls = referencedIds.get(dupId); if (!dupReferencingEls) { continue; diff --git a/test/fixtures/config-loader/cjs/svgo.config.cjs b/test/fixtures/config-loader/cjs/svgo.config.cjs index 7823743..f796f58 100644 --- a/test/fixtures/config-loader/cjs/svgo.config.cjs +++ b/test/fixtures/config-loader/cjs/svgo.config.cjs @@ -1,3 +1,5 @@ +'use strict'; + module.exports = { plugins: ['cjs'], }; diff --git a/test/svgo.cjs b/test/svgo.cjs index 3e85430..a851964 100644 --- a/test/svgo.cjs +++ b/test/svgo.cjs @@ -1,3 +1,5 @@ +'use strict'; + const assert = require('assert'); const { VERSION, diff --git a/yarn.lock b/yarn.lock index 6a15588..2ec164d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -437,7 +437,7 @@ __metadata: languageName: node linkType: hard -"@eslint/js@npm:9.15.0, @eslint/js@npm:^9.14.0": +"@eslint/js@npm:9.15.0, @eslint/js@npm:^9.15.0": version: 9.15.0 resolution: "@eslint/js@npm:9.15.0" checksum: 8b2aa35b62c1969c5e3aa5e33b4e072cc450b95ee9bc08b5a84aa5cbed10a01a9a8f0463b8bb3768ceeb5abfaa82abfb95650061338c3b467835757b62ffc4ba @@ -4484,7 +4484,7 @@ __metadata: version: 0.0.0-use.local resolution: "svgo-ll@workspace:." dependencies: - "@eslint/js": ^9.14.0 + "@eslint/js": ^9.15.0 "@rollup/plugin-commonjs": ^28.0.1 "@rollup/plugin-node-resolve": ^15.3.0 "@rollup/plugin-terser": ^0.4.4