Skip to content

Commit

Permalink
chore: improve license header checks @W-14846456 (#3951)
Browse files Browse the repository at this point in the history
* chore(scripts): run header check on commit

Fail faster than waiting for CI!

* fix(scripts): update copyright header check to permit new company name

In 2022, Salesforce changed from "salesforce.com, inc." to "Salesforce, Inc."

https://investor.salesforce.com/press-releases/press-release-details/2022/Salesforce-Changes-Legal-Name-to-Salesforce-Inc/default.aspx

* chore: remove file that doesn't exist from ignore patterns

* chore(lint): add copyright header enforcement to eslint

This enables auto-fixes, which is an improvment over the check-license-headers.js script.

* chore(scripts): add check-license-headers to package.json scripts

* fix: check license headers for all files, not just js/ts

* chore: remove check-license-headers script

Headers are enforced for JS/TS files using eslint.

Other file types don't need enforcement.

* chore(lint): remove overrides covered by .eslintignore

* chore(lint): remove unnecessary rule exception

* style: revert to 2-space indent

* style: revert to original formatting

* chore(scripts): remove package.json script for removed script file
  • Loading branch information
wjhsf authored Jan 22, 2024
1 parent e9305a2 commit ebc8c32
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 162 deletions.
32 changes: 29 additions & 3 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"jest",
"@lwc/lwc-internal",
"@typescript-eslint",
"import"
"import",
"header"
],
"extends": [
"eslint:recommended",
Expand Down Expand Up @@ -104,7 +105,22 @@
"name": "@lwc/features",
"importNames": ["lwcRuntimeFlags", "runtimeFlags", "default"],
"message": "Do not directly import runtime flags from @lwc/features. Use the global lwcRuntimeFlags variable instead."
}]
}],
"header/header": [
2,
"block",
[
"",
{
"pattern": "^ \\* Copyright \\(c\\) \\d{4}, ([sS]alesforce.com, inc|Salesforce, Inc)\\.$",
"template": " * Copyright (c) 2024, Salesforce, Inc."
},
" * All rights reserved.",
" * SPDX-License-Identifier: MIT",
" * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT",
" "
]
]
},

"overrides": [
Expand Down Expand Up @@ -185,6 +201,16 @@
"benchmark": true,
"run": true
}
}
},
{
"files": [
"packages/@lwc/integration-tests/src/**/!(*.spec.js)",
"packages/@lwc/integration-karma/test/**",
"packages/@lwc/integration-karma/test-hydration/**"
],
"rules": {
"header/header": "off"
}
}
]
}
2 changes: 0 additions & 2 deletions .github/workflows/unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ jobs:
- name: Install chromedriver v119
run: yarn add -W chromedriver@^119

- name: Check missing file headers
run: node ./scripts/tasks/check-license-headers.js
- name: Check package.json integrity
run: node ./scripts/tasks/check-and-rewrite-package-json.js --test
- name: Verify @lwc/shared is tree-shakable
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"bytes": "^3.1.2",
"es-module-lexer": "^1.4.1",
"eslint": "^8.56.0",
"eslint-plugin-header": "^3.1.1",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jest": "^27.6.0",
"glob": "^10.3.10",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
* Copyright (c) 2024, Salesforce, Inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
import { LightningElement } from 'lwc';

export default class extends LightningElement {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
* Copyright (c) 2024, Salesforce, Inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
import { LightningElement } from 'lwc';

export default class extends LightningElement {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
* Copyright (c) 2024, Salesforce, Inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
import { LightningElement } from 'lwc';

export default class extends LightningElement {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
* Copyright (c) 2024, Salesforce, Inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
import { LightningElement } from 'lwc';

export default class extends LightningElement {
Expand Down
4 changes: 2 additions & 2 deletions packages/@lwc/template-compiler/src/shared/utils.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { DASHED_TAGNAME_ELEMENT_SET } from './constants';

/*
* Copyright (c) 2018, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
import { DASHED_TAGNAME_ELEMENT_SET } from './constants';

export function toPropertyName(attr: string) {
let prop = '';
let shouldUpperCaseNext = false;
Expand Down
1 change: 0 additions & 1 deletion scripts/release/version.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env node

/*
* Copyright (c) 2018, salesforce.com, inc.
* All rights reserved.
Expand Down
154 changes: 0 additions & 154 deletions scripts/tasks/check-license-headers.js

This file was deleted.

7 changes: 7 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1265,9 +1265,11 @@

"@lwc/eslint-plugin-lwc-internal@link:./scripts/eslint-plugin":
version "0.0.0"
uid ""

"@lwc/jest-utils-lwc-internals@link:./scripts/jest/utils":
version "0.0.0"
uid ""

"@mapbox/node-pre-gyp@^1.0.0":
version "1.0.11"
Expand Down Expand Up @@ -4935,6 +4937,11 @@ eslint-module-utils@^2.8.0:
dependencies:
debug "^3.2.7"

eslint-plugin-header@^3.1.1:
version "3.1.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-header/-/eslint-plugin-header-3.1.1.tgz#6ce512432d57675265fac47292b50d1eff11acd6"
integrity sha512-9vlKxuJ4qf793CmeeSrZUvVClw6amtpghq3CuWcB5cUNnWHQhgcqy5eF8oVKFk1G3Y/CbchGfEaw3wiIJaNmVg==

eslint-plugin-import@^2.29.1:
version "2.29.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.29.1.tgz#d45b37b5ef5901d639c15270d74d46d161150643"
Expand Down

0 comments on commit ebc8c32

Please sign in to comment.