Skip to content

Commit

Permalink
Add eslint plugin to detect / fix missing copyright headers
Browse files Browse the repository at this point in the history
Template defined in config_frontend/copyright.txt

`npm run lint` will detect any files missing a header matching the template
`npm run lint:fix` will add the header to any files missing it

Set `nonMatchingTolerance: 0.95` to allow minor variations
from the template, e.g. date ranges instead of single year
  • Loading branch information
AlanGreene authored and tekton-robot committed Sep 3, 2019
1 parent fe6c4d4 commit c82a077
Show file tree
Hide file tree
Showing 16 changed files with 184 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ module.exports = {
"sourceType": "module"
},
"plugins": [
"notice",
"react"
],
"rules": {
Expand All @@ -32,6 +33,9 @@ module.exports = {
"jsx-a11y/anchor-is-valid": "off",
"no-case-declarations": "off",
"no-template-curly-in-string": "off",
"notice/notice": [
"error", { "templateFile": "config_frontend/copyright.txt", nonMatchingTolerance: 0.95 }
],
"react/jsx-filename-extension": "off",
"react/destructuring-assignment": "off",
"react/prop-types": "off",
Expand Down
13 changes: 13 additions & 0 deletions config_frontend/__mocks__/fileMock.js
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@
/*
Copyright 2019 The Tekton Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

module.exports = 'test-file-stub';
13 changes: 13 additions & 0 deletions config_frontend/__mocks__/styleMock.js
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@
/*
Copyright 2019 The Tekton Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

module.exports = {};
12 changes: 12 additions & 0 deletions config_frontend/copyright.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
Copyright <%= YEAR %> The Tekton Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
13 changes: 13 additions & 0 deletions config_frontend/setupTests.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
/*
Copyright 2019 The Tekton Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

import 'react-testing-library/cleanup-after-each';
import fetchMock from 'fetch-mock';

Expand Down
13 changes: 13 additions & 0 deletions docs/samples/extension/server.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
/*
Copyright 2019 The Tekton Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

const express = require('express');

// Constants
Expand Down
17 changes: 17 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"eslint-loader": "^2.1.2",
"eslint-plugin-import": "^2.16.0",
"eslint-plugin-jsx-a11y": "^6.2.1",
"eslint-plugin-notice": "^0.8.9",
"eslint-plugin-prettier": "^3.0.1",
"eslint-plugin-react": "^7.12.4",
"fetch-mock": "^7.3.1",
Expand Down
13 changes: 13 additions & 0 deletions packages/components/src/components/LogoutButton/LogoutButton.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
/*
Copyright 2019 The Tekton Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

import LogoutIcon from '@carbon/icons-react/lib/logout/20';
import { Button } from 'carbon-components-react';
import { injectIntl } from 'react-intl';
Expand Down
13 changes: 13 additions & 0 deletions packages/components/src/components/Rebuild/Rebuild.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
/*
Copyright 2019 The Tekton Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

import React from 'react';
import { fireEvent, waitForElement } from 'react-testing-library';
import { renderWithRouter } from '../../utils/test';
Expand Down
12 changes: 12 additions & 0 deletions src/constants/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
/*
Copyright 2019 The Tekton Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
export const messages = {
en: {
'dashboard.pipelineRuns.transitionTime': 'Last Transition Time',
Expand Down
12 changes: 12 additions & 0 deletions src/containers/Extension/actions.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
/*
Copyright 2019 The Tekton Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
export { fetchNamespaces } from '../../actions/namespaces';
export { fetchPipeline, fetchPipelines } from '../../actions/pipelines';
export { fetchSecrets } from '../../actions/secrets';
Expand Down
12 changes: 12 additions & 0 deletions src/containers/SideNav/index.js
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
/*
Copyright 2019 The Tekton Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
export { default } from './SideNav';
12 changes: 12 additions & 0 deletions webpack.common.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
/*
Copyright 2019 The Tekton Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');

Expand Down
12 changes: 12 additions & 0 deletions webpack.dev.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
/*
Copyright 2019 The Tekton Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
const merge = require('webpack-merge');

const common = require('./webpack.common.js');
Expand Down
12 changes: 12 additions & 0 deletions webpack.prod.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
/*
Copyright 2019 The Tekton Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
const merge = require('webpack-merge');
const path = require('path');
const webpack = require('webpack');
Expand Down

0 comments on commit c82a077

Please sign in to comment.