Skip to content

Commit 27deab1

Browse files
committed
chore(copyright): add sync-header-years script and tests
chore(copyright): wire sync script into lefthook and add package scripts feat(eslint): add inline ping-copyright rule to eslint.config.mjs
1 parent 9f93d5e commit 27deab1

6 files changed

Lines changed: 449 additions & 41 deletions

File tree

eslint.config.mjs

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2025 Ping Identity Corporation. All rights reserved.
2+
* Copyright (c) 2025 - 2026 Ping Identity Corporation. All rights reserved.
33
*
44
* This software may be modified and distributed under the terms
55
* of the MIT license. See the LICENSE file for details.
@@ -33,6 +33,48 @@ export default [
3333
'**/test-output',
3434
],
3535
},
36+
{
37+
files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx', '**/*.mjs', '**/*.cjs'],
38+
ignores: [
39+
'**/*.test.*',
40+
'**/*.spec.*',
41+
'**/vite.config.*',
42+
'**/vitest.config.*',
43+
'**/vitest.setup.*',
44+
'**/eslint.config.*',
45+
],
46+
plugins: {
47+
'local-rules': {
48+
rules: {
49+
'ping-copyright': {
50+
meta: {
51+
type: 'suggestion',
52+
messages: { missing: 'Missing Ping Identity copyright header.' },
53+
},
54+
create(context) {
55+
return {
56+
Program(node) {
57+
const src = context.getSourceCode();
58+
const comments = src.getAllComments();
59+
const first = comments[0];
60+
if (
61+
!first ||
62+
first.range[0] > 0 ||
63+
!/Copyright[\s\S]*Ping Identity/i.test(first.value)
64+
) {
65+
context.report({ node, messageId: 'missing' });
66+
}
67+
},
68+
};
69+
},
70+
},
71+
},
72+
},
73+
},
74+
rules: {
75+
'local-rules/ping-copyright': 'warn',
76+
},
77+
},
3678
...compat.extends('plugin:@typescript-eslint/recommended', 'plugin:prettier/recommended'),
3779
{
3880
plugins: {

lefthook.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ pre-commit:
22
commands:
33
nx-sync:
44
run: pnpm nx sync
5+
copyright-sync:
6+
run: node tools/copyright/sync-header-years.mjs --fix
7+
stage_fixed: true
58
nx-check:
69
run: pnpm nx affected -t typecheck lint build api-report --tui=false
710
stage_fixed: true

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
"circular-dep-check": "madge --circular .",
2323
"clean": "shx rm -rf ./{coverage,dist,docs,node_modules,tmp}/ ./{packages,e2e}/*/{dist,node_modules}/ ./e2e/node_modules/ && git clean -fX -e \"!.env*,nx-cloud.env\" -e \"!**/GEMINI.md\"",
2424
"commit": "git cz",
25+
"copyright:check": "node tools/copyright/sync-header-years.mjs --check",
26+
"copyright:sync": "node tools/copyright/sync-header-years.mjs --fix",
2527
"commitlint": "commitlint --edit",
2628
"create-package": "nx g @nx/js:library",
2729
"format": "pnpm nx format:write",
@@ -45,7 +47,6 @@
4547
"path": "./node_modules/cz-conventional-changelog"
4648
}
4749
},
48-
"dependencies": {},
4950
"devDependencies": {
5051
"@changesets/changelog-github": "^0.6.0",
5152
"@changesets/cli": "^2.27.9",

pnpm-lock.yaml

Lines changed: 52 additions & 39 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)