Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/license checker #220

Merged
merged 45 commits into from
Dec 1, 2020
Merged

Feature/license checker #220

merged 45 commits into from
Dec 1, 2020

Conversation

just-at-uber
Copy link
Contributor

@just-at-uber just-at-uber commented Nov 20, 2020

This change introduces a new lint plugin which checks if a source file does not have a license in the header of the file.
It will fail CI build pipeline if it detects that a file has a missing license.
It is a quick fix to fix this issue by running command npm run lint which will auto-fix this by injecting a license into the files with a missing license (see .eslintrc.js for configuration).
This PR contains the lint plugin change + LICENSE + all changes to source files which are violating a missing license in the header of the file. I have added LICENSE to linting rules so it automatically gets updated when year ends also.

Examples

These examples are committed into the repository and has the linter passed over it. It ensures that these rules are covered and passes lint. If these start to fail, it will also mean that there could be other files that are failing also which need updating (for example year ends and will mark all files as failed if not containing the next year).

License for file not existing in uber/cadence-web which is copied from another company (temporal for example)

<script>
// Modifications Copyright (c) 2020 Uber Technologies Inc.
// Copyright (c) 2020 Temporal Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

export default {
  name: 'test-file-does-not-exist',
};
</script>

License for file existing in uber/cadence-web but modified by another company (temporal for example) and merged changes back

<script>
// Copyright (c) 2017-2020 Uber Technologies Inc.
// Portions of the Software are attributed to Copyright (c) 2020 Temporal Technologies Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

export default {
  name: 'test-file-modified',
};
</script>

License for file existing in uber/cadence-web with no modifications by another company

<script>
// Copyright (c) 2017-2020 Uber Technologies Inc.
//
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

export default {
  name: 'test-file-unmodified',
};
</script>

License for new file created in uber/cadence-web with no modifications by another company

<script>
// Copyright (c) 2020 Uber Technologies Inc.
//
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

export default {
  name: 'test-file-new',
};
</script>

… to get unmodified license generation working.
@just-at-uber just-at-uber mentioned this pull request Nov 24, 2020
@just-at-uber just-at-uber changed the base branch from master to fix/script-ordering November 24, 2020 21:47
…lint rule to run over LICENSE file and report any violations. Updated eslintrc comments with some links to open issue with header plugin requesting for named capture group to be supported in template.
Base automatically changed from fix/script-ordering to master November 25, 2020 19:38
//
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is now auto-generated from lint plugin.

' THE SOFTWARE.'
],
2
],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

configuration rules for injecting license into headers.

@@ -8,7 +8,7 @@
"clean": "rm -rf dist",
"dev": "NODE_ENV=development node server.js",
"lint": "npm run lint:check -- --fix",
"lint:check": "eslint --ext .js,.vue client server",
"lint:check": "eslint --ext .js,.vue client server LICENSE",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adds linter for LICENSE file at root. This will allow auto-generation for LICENSE. Will also fail lint if changed and not passing linting rules.

@@ -101,6 +101,7 @@
"eslint-plugin-chai-friendly": "^0.5.0",
"eslint-plugin-cup": "^2.0.2",
"eslint-plugin-flowtype": "^4.6.0",
"eslint-plugin-header": "just-at-uber/eslint-plugin-header#ef55ce547ecb6801da326c75374711f0865a57a6",
Copy link
Contributor Author

@just-at-uber just-at-uber Nov 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pinned to fork of eslint-plugin-header repo. Waiting for maintainer to merge PR. Can see open PR here:
Stuk/eslint-plugin-header#32
Will create new PR once fork changes are merged back.

@just-at-uber just-at-uber marked this pull request as ready for review November 30, 2020 23:59
@just-at-uber just-at-uber requested a review from a team December 1, 2020 00:44
@just-at-uber just-at-uber merged commit ab824d6 into master Dec 1, 2020
@just-at-uber just-at-uber deleted the feature/license-checker branch December 1, 2020 22:20
@just-at-uber just-at-uber mentioned this pull request Dec 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants