From bcd16333936afdc6931f19c84e2a635e32c22419 Mon Sep 17 00:00:00 2001 From: dblock Date: Tue, 4 Jun 2024 07:18:20 -0400 Subject: [PATCH] Added license headers jest linter. Signed-off-by: dblock --- eslint.config.mjs | 19 ++++++++++++++++++- package-lock.json | 19 +++++++++++++++++++ package.json | 1 + 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/eslint.config.mjs b/eslint.config.mjs index 9e13e3c1a..53e6a18c3 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -2,6 +2,7 @@ import path from 'path' import { fileURLToPath } from 'url' import { FlatCompat } from '@eslint/eslintrc' import pluginJs from '@eslint/js' +import licenseHeader from 'eslint-plugin-license-header' // mimic CommonJS variables -- not needed if using CommonJS const _filename = fileURLToPath(import.meta.url) @@ -13,6 +14,9 @@ export default [ ...compat.extends('standard-with-typescript'), { files: ['**/*.{js,ts}'], + plugins: { + 'license-header': licenseHeader + }, rules: { '@typescript-eslint/consistent-indexed-object-style': 'error', '@typescript-eslint/consistent-type-assertions': 'error', @@ -51,7 +55,20 @@ export default [ 'array-callback-return': 'off', 'new-cap': 'off', 'no-return-assign': 'error', - 'object-shorthand': 'error' + 'object-shorthand': 'error', + 'license-header/header': [ + 'error', + [ + '/*', + '* Copyright OpenSearch Contributors', + '* SPDX-License-Identifier: Apache-2.0', + '*', + '* The OpenSearch Contributors require contributions made to', + '* this file be licensed under the Apache-2.0 license or a', + '* compatible open source license.', + '*/' + ] + ] } } ] diff --git a/package-lock.json b/package-lock.json index f4b1b6149..d404636d8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -30,6 +30,7 @@ "eslint": "^8.57.0", "eslint-config-standard-with-typescript": "^43.0.1", "eslint-plugin-import": "^2.29.1", + "eslint-plugin-license-header": "^0.6.1", "eslint-plugin-n": "^16.6.2", "eslint-plugin-promise": "^6.1.1", "globals": "^15.0.0", @@ -3403,6 +3404,15 @@ "node": ">=0.10.0" } }, + "node_modules/eslint-plugin-license-header": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-license-header/-/eslint-plugin-license-header-0.6.1.tgz", + "integrity": "sha512-9aIz8q3OaMr1/uQmCGCWySjTs5nEXUJexNegz/8lluNcZbEl82Ag1Vyr1Hu3oIveRW1NbXDPs6nu4zu9mbrmWA==", + "dev": true, + "dependencies": { + "requireindex": "^1.2.0" + } + }, "node_modules/eslint-plugin-n": { "version": "16.6.2", "resolved": "https://registry.npmjs.org/eslint-plugin-n/-/eslint-plugin-n-16.6.2.tgz", @@ -6591,6 +6601,15 @@ "node": ">=0.10.0" } }, + "node_modules/requireindex": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/requireindex/-/requireindex-1.2.0.tgz", + "integrity": "sha512-L9jEkOi3ASd9PYit2cwRfyppc9NoABujTP8/5gFcbERmo5jUoAKovIC3fsF17pkTnGsrByysqX+Kxd2OTNI1ww==", + "dev": true, + "engines": { + "node": ">=0.10.5" + } + }, "node_modules/resolve": { "version": "1.22.8", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.8.tgz", diff --git a/package.json b/package.json index 0c14289ab..6e953726a 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,7 @@ "eslint": "^8.57.0", "eslint-config-standard-with-typescript": "^43.0.1", "eslint-plugin-import": "^2.29.1", + "eslint-plugin-license-header": "^0.6.1", "eslint-plugin-n": "^16.6.2", "eslint-plugin-promise": "^6.1.1", "globals": "^15.0.0",