From b58d891581508252479243bc3b9fad75325b540a Mon Sep 17 00:00:00 2001 From: konstantinabl Date: Wed, 11 Dec 2024 11:11:59 +0200 Subject: [PATCH] chore: Adds check for license header (#3203) * Adds check for license header Signed-off-by: Konstantina Blazhukova * adds new header rule and removes conflict leftover Signed-off-by: Konstantina Blazhukova * Adds regex for license header Signed-off-by: Konstantina Blazhukova * finalizes regex for header Signed-off-by: Konstantina Blazhukova * improves template Signed-off-by: Konstantina Blazhukova --------- Signed-off-by: Konstantina Blazhukova --- .eslintrc.js | 28 ++++++++++++++++++++++++++-- package-lock.json | 18 ++++++++++++++++++ package.json | 1 + 3 files changed, 45 insertions(+), 2 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index ef9f67a7a..9b3a9f92b 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,4 +1,4 @@ -/* +/*- * * Hedera JSON RPC Relay * @@ -28,7 +28,10 @@ module.exports = { "plugin:@typescript-eslint/recommended", "prettier", ], - "plugins": ["simple-import-sort"], + "plugins": [ + "simple-import-sort", + "header", + ], "overrides": [ { "env": { @@ -64,5 +67,26 @@ module.exports = { }], "simple-import-sort/imports": "error", "simple-import-sort/exports": "off", + "header/header": [2, "block", [ + "-", + " *", + " * Hedera JSON RPC Relay", + " *", + {"pattern": "^\\s\\*\\sCopyright \\(C\\) 20(1[8-9]|[2-9]\\d)(?:-20(1[8-9]|[2-9]\\d))? Hedera Hashgraph, LLC$", "template": ` * Copyright (C) ${new Date().getFullYear()} Hedera Hashgraph, LLC`}, + " *", + " * Licensed under the Apache License, Version 2.0 (the \"License\");", + " * you may not use this file except in compliance with the License.", + " * You may obtain a copy of the License at", + " *", + " * http://www.apache.org/licenses/LICENSE-2.0", + " *", + " * Unless required by applicable law or agreed to in writing, software", + " * distributed under the License is distributed on an \"AS IS\" BASIS,", + " * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + " * See the License for the specific language governing permissions and", + " * limitations under the License.", + " *", + " ", + ]], }, }; diff --git a/package-lock.json b/package-lock.json index 243b615bb..dbeb9fe28 100644 --- a/package-lock.json +++ b/package-lock.json @@ -41,6 +41,7 @@ "eslint-config-airbnb-base": "^15.0.0", "eslint-config-prettier": "^8.3.0", "eslint-config-standard-with-typescript": "^43.0.1", + "eslint-plugin-header": "^3.1.1", "eslint-plugin-import": "^2.28.1", "eslint-plugin-n": "^15.7.0", "eslint-plugin-simple-import-sort": "^12.1.1", @@ -8728,6 +8729,16 @@ "node": ">=4" } }, + "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.28.1", "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.28.1.tgz", @@ -29907,6 +29918,13 @@ } } }, + "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, + "requires": {} + }, "eslint-plugin-import": { "version": "2.28.1", "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.28.1.tgz", diff --git a/package.json b/package.json index 264ca37aa..9f2e20b82 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "eslint-config-airbnb-base": "^15.0.0", "eslint-config-prettier": "^8.3.0", "eslint-config-standard-with-typescript": "^43.0.1", + "eslint-plugin-header": "^3.1.1", "eslint-plugin-import": "^2.28.1", "eslint-plugin-n": "^15.7.0", "eslint-plugin-simple-import-sort": "^12.1.1",