From bc883c9135b29215f5b06825c560ee089cb2d4fa Mon Sep 17 00:00:00 2001 From: yassinedorbozgithub Date: Thu, 2 Jan 2025 11:44:55 +0100 Subject: [PATCH] fix(widget): restrict dynamic header to the updates files --- widget/.eslintrc-staged.json | 19 +++++++++++++++++++ widget/.eslintrc.json | 19 ++++++++++++------- widget/package.json | 5 +++++ 3 files changed, 36 insertions(+), 7 deletions(-) create mode 100644 widget/.eslintrc-staged.json diff --git a/widget/.eslintrc-staged.json b/widget/.eslintrc-staged.json new file mode 100644 index 00000000..b5949ee8 --- /dev/null +++ b/widget/.eslintrc-staged.json @@ -0,0 +1,19 @@ +{ + "extends": "./.eslintrc.json", + "rules": { + "header/header": [ + 2, + "block", + [ + "", + " * Copyright © 2025 Hexastack. All rights reserved.", + " *", + " * Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:", + " * 1. The name \"Hexabot\" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.", + " * 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's \"About\" section, documentation, and README file).", + " " + ], + 2 + ] + } +} diff --git a/widget/.eslintrc.json b/widget/.eslintrc.json index 334447df..1f2632d5 100644 --- a/widget/.eslintrc.json +++ b/widget/.eslintrc.json @@ -1,6 +1,6 @@ { "root": true, - "plugins": ["@typescript-eslint", "import", "license-header", "react"], + "plugins": ["@typescript-eslint", "import", "header", "react"], "extends": [ "eslint:recommended", "plugin:@typescript-eslint/recommended", @@ -49,17 +49,22 @@ ], "react/jsx-curly-brace-presence": ["warn"], "react/self-closing-comp": ["error"], - "license-header/header": [ - "error", + "header/header": [ + 2, + "block", [ - "/*", - " * Copyright © 2024 Hexastack. All rights reserved.", + "", + { + "pattern": "^ \\* Copyright © 20\\d{2} Hexastack. All rights reserved.$", + "template": " * Copyright © 2025 Hexastack. All rights reserved." + }, " *", " * Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:", " * 1. The name \"Hexabot\" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.", " * 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's \"About\" section, documentation, and README file).", - " */" - ] + " " + ], + 2 ] }, "settings": { diff --git a/widget/package.json b/widget/package.json index cc3d425d..bedf97bb 100644 --- a/widget/package.json +++ b/widget/package.json @@ -16,6 +16,9 @@ "serve": "npx http-server ./dist/", "typecheck": "tsc --noEmit" }, + "lint-staged": { + "*.{ts,tsx}": "eslint --fix -c \".eslintrc-staged.json\"" + }, "dependencies": { "@types/emoji-js": "^3.5.2", "autolinker": "^4.0.0", @@ -33,9 +36,11 @@ "@typescript-eslint/parser": "^7.15.0", "@vitejs/plugin-react": "^4.3.1", "eslint": "^8.57.0", + "eslint-plugin-header": "^3.1.1", "eslint-plugin-react": "^7.37.2", "eslint-plugin-react-hooks": "^4.6.2", "eslint-plugin-react-refresh": "^0.4.7", + "lint-staged": "^15.3.0", "sass": "^1.77.8", "typescript": "^5.2.2", "vite": "^5.3.4",