diff --git a/packages/eslint-plugin/package.json b/packages/eslint-plugin/package.json index f7b70c8..f0c90e9 100644 --- a/packages/eslint-plugin/package.json +++ b/packages/eslint-plugin/package.json @@ -24,9 +24,9 @@ "LICENSE" ], "exports": { + "types": "./dist/index.d.ts", "import": "./dist/index.js", - "require": "./dist/index.cjs", - "types": "./dist/index.d.ts" + "require": "./dist/index.cjs" }, "scripts": { "dev": "tsup --watch", diff --git a/packages/eslint-plugin/src/constants/copyright.ts b/packages/eslint-plugin/src/constants/copyright.ts index 32fac67..4d07de2 100644 --- a/packages/eslint-plugin/src/constants/copyright.ts +++ b/packages/eslint-plugin/src/constants/copyright.ts @@ -1,12 +1,10 @@ export const DEFAULT_START_YEAR = 2017; export const COPYRIGHT_TEXT = ` -/* * Copyright {startYear}-{currentYear} Commencis. All Rights Reserved. * * Save to the extent permitted by law, you may not use, copy, modify, * distribute or create derivative works of this material or any part * of it without the prior written consent of Commencis. * Any reproduction of this material must contain this notice. - */ `.trim(); diff --git a/packages/eslint-plugin/src/rules/copyright-text.ts b/packages/eslint-plugin/src/rules/copyright-text.ts index 727cf87..23e4697 100644 --- a/packages/eslint-plugin/src/rules/copyright-text.ts +++ b/packages/eslint-plugin/src/rules/copyright-text.ts @@ -40,7 +40,9 @@ export default createRule<[RuleOptions], MessageIds>({ create(context, [options]) { const startYear = options.startYear ?? DEFAULT_START_YEAR; - const expectedCopyrightText = getCopyrightText(startYear); + const isHtml = context.filename.endsWith('.vue'); + + const expectedCopyrightText = getCopyrightText(startYear, isHtml); return { Program(node: TSESTree.Program) { diff --git a/packages/eslint-plugin/src/utils/getCopyrightText.ts b/packages/eslint-plugin/src/utils/getCopyrightText.ts index d0852bc..1c528f4 100644 --- a/packages/eslint-plugin/src/utils/getCopyrightText.ts +++ b/packages/eslint-plugin/src/utils/getCopyrightText.ts @@ -1,9 +1,15 @@ import { COPYRIGHT_TEXT } from '@/constants/copyright'; -export function getCopyrightText(startYear: number): string { +export function getCopyrightText(startYear: number, isHtml: boolean): string { const currentYear = new Date().getFullYear(); - return COPYRIGHT_TEXT.replace(/{startYear}/g, startYear.toString()).replace( - /{currentYear}/g, - currentYear.toString() - ); + + const formattedText = COPYRIGHT_TEXT.replace( + /{startYear}/g, + startYear.toString() + ).replace(/{currentYear}/g, currentYear.toString()); + + if (isHtml) { + return ``; + } + return `/*\n ${formattedText}\n */`; }