From b759304bf1bc4e8b3baa3277c37f8c9a5ef999ae Mon Sep 17 00:00:00 2001 From: Tony Ganchev Date: Mon, 16 Mar 2026 13:24:53 +0200 Subject: [PATCH] chore: switch to @tony.ganchev/eslint-plugin-header Hi, team, I noticed you are using _eslint-plugin-header_ on ESLint 8. I forked _@tony.ganchev/eslint-plugin-header_ mid-2024 to add support for ESLint 9 and hoped it would be a temporary measure but since the original has not been updated for five years I decided to continue improving the new plugin and have been doing so for the last two years. Specific improvements include: - full JSON schema for validating the configuration. - fixed multiple bugs with the behavior of the plugin on Windows. - many other bug-fixes. - improved autofixing and error-reporting behavior. - added support for leading pragma comments before the header such as `@jest-environment` or `eslint-env`. In the case of the current review, this allowed me to remove the `eslint-disable` directive from one file and reintroduce validation. I switched the configuration to use the new config format for v3.2.x as the leading comments feature is not supported by the array-based format inherited from _eslint-plugin-header_. I've sent PR proposals to other projects in the _cloudscape-design_ space: - https://github.com/cloudscape-design/board-components/pull/401 - https://github.com/cloudscape-design/browser-test-tools/pull/188 - https://github.com/cloudscape-design/chart-components/pull/185 - https://github.com/cloudscape-design/code-view/pull/122 - https://github.com/cloudscape-design/collection-hooks/pull/136 - https://github.com/cloudscape-design/component-toolkit/pull/200 - https://github.com/cloudscape-design/components/pull/4308 - https://github.com/cloudscape-design/demos/pull/243 - https://github.com/cloudscape-design/documenter/pull/112 - https://github.com/cloudscape-design/global-styles/pull/73 - https://github.com/cloudscape-design/jest-preset/pull/58 - https://github.com/cloudscape-design/test-utils/pull/114 - https://github.com/cloudscape-design/theming-core/pull/148 Looking forward to your feedback. --- .eslintrc | 20 ++++++++++++++++---- package-lock.json | 22 +++++++++++----------- package.json | 2 +- src/__tests__/utils.ts | 1 - 4 files changed, 28 insertions(+), 17 deletions(-) diff --git a/.eslintrc b/.eslintrc index 036ba08..05fd975 100644 --- a/.eslintrc +++ b/.eslintrc @@ -16,7 +16,7 @@ "jsx": true } }, - "plugins": ["unicorn", "react-hooks", "no-unsanitized", "header", "import", "simple-import-sort", "@vitest"], + "plugins": ["unicorn", "react-hooks", "no-unsanitized", "@tony.ganchev/header", "import", "simple-import-sort", "@vitest"], "rules": { "@typescript-eslint/no-unused-vars": "error", "@typescript-eslint/consistent-type-definitions": ["error", "interface"], @@ -54,10 +54,22 @@ "eqeqeq": "error", "no-return-await": "error", "require-await": "error", - "header/header": [ + "@tony.ganchev/header/header": [ "error", - "line", - [" Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.", " SPDX-License-Identifier: Apache-2.0"] + { + "header": { + "commentType": "line", + "lines": [" Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.", " SPDX-License-Identifier: Apache-2.0"] + }, + "leadingComments": { + "comments": [ + { + "commentType": "block", + "lines": [" eslint-env node "] + } + ] + } + } ], "no-restricted-imports": [ "error", diff --git a/package-lock.json b/package-lock.json index ab07008..fa8f8a0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -25,6 +25,7 @@ "@cloudscape-design/theming-build": "^1", "@testing-library/jest-dom": "^5.16.5", "@testing-library/react": "^13.4.0", + "@tony.ganchev/eslint-plugin-header": "^3.3.1", "@types/jest-image-snapshot": "^6.1.0", "@types/lodash": "^4.14.191", "@types/node": "^18.19.4", @@ -41,7 +42,6 @@ "delay-cli": "^2.0.0", "eslint": "^8.57.0", "eslint-config-prettier": "^9.1.0", - "eslint-plugin-header": "^3.1.1", "eslint-plugin-import": "^2.26.0", "eslint-plugin-no-unsanitized": "^4.0.2", "eslint-plugin-prettier": "^5.1.3", @@ -4010,6 +4010,16 @@ "react-dom": "^18.0.0" } }, + "node_modules/@tony.ganchev/eslint-plugin-header": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/@tony.ganchev/eslint-plugin-header/-/eslint-plugin-header-3.3.1.tgz", + "integrity": "sha512-/Fj0+DaXbBfrlXmd3wBZkB8TIwGT3N++y/oTYxRABK/gzNxjgcBjt63xBpuHCYIXmH1EwuALd6XS1fzNG4S0zg==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "eslint": ">=7.7.0" + } + }, "node_modules/@tootallnate/quickjs-emscripten": { "version": "0.23.0", "resolved": "https://registry.npmjs.org/@tootallnate/quickjs-emscripten/-/quickjs-emscripten-0.23.0.tgz", @@ -7788,16 +7798,6 @@ "ms": "^2.1.1" } }, - "node_modules/eslint-plugin-header": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-header/-/eslint-plugin-header-3.1.1.tgz", - "integrity": "sha512-9vlKxuJ4qf793CmeeSrZUvVClw6amtpghq3CuWcB5cUNnWHQhgcqy5eF8oVKFk1G3Y/CbchGfEaw3wiIJaNmVg==", - "dev": true, - "license": "MIT", - "peerDependencies": { - "eslint": ">=7.7.0" - } - }, "node_modules/eslint-plugin-import": { "version": "2.31.0", "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.31.0.tgz", diff --git a/package.json b/package.json index 78af33e..8b92d3f 100644 --- a/package.json +++ b/package.json @@ -71,6 +71,7 @@ "@cloudscape-design/theming-build": "^1", "@testing-library/jest-dom": "^5.16.5", "@testing-library/react": "^13.4.0", + "@tony.ganchev/eslint-plugin-header": "^3.3.1", "@types/jest-image-snapshot": "^6.1.0", "@types/lodash": "^4.14.191", "@types/node": "^18.19.4", @@ -87,7 +88,6 @@ "delay-cli": "^2.0.0", "eslint": "^8.57.0", "eslint-config-prettier": "^9.1.0", - "eslint-plugin-header": "^3.1.1", "eslint-plugin-import": "^2.26.0", "eslint-plugin-no-unsanitized": "^4.0.2", "eslint-plugin-prettier": "^5.1.3", diff --git a/src/__tests__/utils.ts b/src/__tests__/utils.ts index 0c1b6af..dfb805e 100644 --- a/src/__tests__/utils.ts +++ b/src/__tests__/utils.ts @@ -1,5 +1,4 @@ /* eslint-env node */ -/* eslint-disable header/header */ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 import * as fs from "node:fs";