Skip to content

Commit

Permalink
feat: Deprecate from chectl tslint and eslint and check license headers
Browse files Browse the repository at this point in the history
Signed-off-by: Flavius Lacatusu <[email protected]>
  • Loading branch information
flacatus committed Jun 7, 2021
1 parent e8ca8a8 commit 8f38ff2
Show file tree
Hide file tree
Showing 73 changed files with 952 additions and 412 deletions.
29 changes: 29 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
*
* Copyright (c) 2019-2021 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/

/** @type {import('eslint').Linter.Config} */
module.exports = {
root: true,
extends: [
'./configs/eslint.json'
],
ignorePatterns: [
'**/{node_modules,lib}'
],
parserOptions: {
tsconfigRootDir: __dirname,
project: 'tsconfig.json',
sourceType: "module",
ecmaVersion: 2015,
}
};
9 changes: 9 additions & 0 deletions .github/workflows/automation-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,12 @@ jobs:
echo "[ERROR] README.md it is not up to date. Please run 'yarn oclif-dev readme' to update and commit the changes."
exit 1
fi
- name: Check license header year eslint template
run: |
TEMPLATE=$(jq '.rules."header/header"[2][1].pattern' configs/eslint.license.json)
CURRENT_YEAR=$(date +'%Y')
if [[ ${TEMPLATE} != *"$CURRENT_YEAR"* ]];then
echo -e "[ERROR] Your license header template doesn't contain the current year. Please change the year in configs/eslint.license.json and run yarn lint:fix"
exit 1
fi
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ tsconfig.tsbuildinfo
oclif.manifest.json
# templates are added at post-install step
templates
.eslintcache
23 changes: 23 additions & 0 deletions configs/base.eslint.chectl.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"sourceType": "module",
"ecmaVersion": 6,
"ecmaFeatures": {
"jsx": false
}
},
"plugins": [
"@typescript-eslint",
"no-null"
],
"env": {
"browser": true,
"mocha": true,
"node": true
},
"ignorePatterns": [
"node_modules",
"lib"
]
}
6 changes: 6 additions & 0 deletions configs/eslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": [
"./eslint.license.json",
"./base.eslint.chectl.json"
]
}
25 changes: 25 additions & 0 deletions configs/eslint.license.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"plugins": ["@typescript-eslint", "header"],
"rules": {
"header/header": [
2,
"block",
[
"*",
{
"pattern": "^ \\* Copyright \\(c\\) 2021 Red Hat, Inc\\.$",
"template": " * Copyright (c) 2021 Red Hat, Inc."
},
" * This program and the accompanying materials are made",
" * available under the terms of the Eclipse Public License 2.0",
" * which is available at https://www.eclipse.org/legal/epl-2.0/",
" *",
" * SPDX-License-Identifier: EPL-2.0",
" *",
" * Contributors:",
" * Red Hat, Inc. - initial API and implementation",
" "
]
]
}
}
13 changes: 8 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
"@eclipse-che/api": "latest",
"@oclif/dev-cli": "^1",
"@oclif/test": "^1",
"@oclif/tslint": "^3",
"@types/chai": "^4",
"@types/command-exists": "^1.2.0",
"@types/countries-and-timezones": "^2.0.3",
Expand All @@ -73,14 +72,18 @@
"@types/uuid": "^8.3.0",
"@types/websocket": "^1.0.1",
"@types/ws": "^7.4.0",
"@typescript-eslint/eslint-plugin": "^4.26.0",
"@typescript-eslint/parser": "^4.26.0",
"chai": "^4.2.0",
"cpx": "^1.5.0",
"eslint": "^7.28.0",
"eslint-plugin-header": "^3.1.1",
"eslint-plugin-no-null": "^1.0.2",
"globby": "^11",
"jest": "^26.6.3",
"nock": "^11.7.0",
"ts-jest": "^26.5.1",
"ts-node": "^9",
"tslint": "^6",
"typescript": "^4.1",
"typescript-formatter": "7.2.2"
},
Expand Down Expand Up @@ -154,18 +157,18 @@
"postinstall-repositories": "yarn upgrade eclipse-che-server eclipse-che-operator eclipse-che-devfile-workspace-operator",
"postinstall-cleanup": "rimraf node_modules/eclipse-che-server && rimraf node_modules/eclipse-che-operator",
"test": "jest --collect-coverage",
"posttest": "tslint -p test -t stylish",
"test-watch": "jest --watchAll",
"e2e-minikube-helm": "export PLATFORM=minikube && export INSTALLER=helm && yarn jest ./test/e2e/e2e.test.ts --testRegex='/test/(e2e)/.*.test.ts'",
"e2e-minikube-operator": "export PLATFORM=minikube && export INSTALLER=operator && yarn jest ./test/e2e/e2e.test.ts --testRegex='/test/(e2e)/.*.test.ts'",
"e2e-minishift": "export PLATFORM=minishift && export INSTALLER=operator && yarn jest ./test/e2e/e2e.test.ts --testRegex='/test/(e2e)/.*.test.ts'",
"e2e-openshift": "export PLATFORM=openshift && export INSTALLER=operator && yarn jest ./test/e2e/e2e.test.ts --testRegex='/test/(e2e)/.*.test.ts'",
"gnirts-ci": "node .ci/obfuscate/gnirts.js",
"prepack": "rm -rf lib && rm -rf tsconfig.tsbuildinfo && tsc -b && oclif-dev manifest && oclif-dev readme && yarn gnirts-ci",
"prepack": "yarn lint && rm -rf lib && rm -rf tsconfig.tsbuildinfo && tsc -b && oclif-dev manifest && oclif-dev readme && yarn gnirts-ci",
"pack-binaries": "oclif-dev pack",
"postpack": "rm -f oclif.manifest.json",
"format": "tsfmt -r --useTsfmt tsfmt.json",
"tslint-fix": "tslint --fix -p test -t stylish",
"lint": "eslint --cache=true --no-error-on-unmatched-pattern=true '{src,tests}/**/*.ts'",
"lint:fix": "eslint --fix --cache=true --no-error-on-unmatched-pattern=true \"{src,tests}/**/*.{ts,tsx}\"",
"version": "oclif-dev readme && git add README.md",
"watch": "tsc --watch"
},
Expand Down
6 changes: 6 additions & 0 deletions run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
TEMPLATE=$(jq '.rules."header/header"[2][1].pattern' configs/eslint.license.json)
CURRENT_YEAR=$(date +'%Y')

if [[ ${TEMPLATE} != *"$CURRENT_YEAR"* ]];then
echo -e "[INFO] Your license header template doesn't contain the current year. Please change config/eslint.license.json year and run yarn lint:fix"
fi
10 changes: 6 additions & 4 deletions src/api/che-api-client.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
/*********************************************************************
* Copyright (c) 2019-2020 Red Hat, Inc.
*
/**
* Copyright (c) 2021 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/

import { che as chetypes } from '@eclipse-che/api'
import axios, { AxiosInstance } from 'axios'
Expand Down
10 changes: 6 additions & 4 deletions src/api/che-login-manager.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
/*********************************************************************
* Copyright (c) 2020 Red Hat, Inc.
*
/**
* Copyright (c) 2021 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/

import axios, { AxiosInstance } from 'axios'
import * as fs from 'fs-extra'
Expand Down
10 changes: 6 additions & 4 deletions src/api/che.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
/*********************************************************************
* Copyright (c) 2019-2020 Red Hat, Inc.
*
/**
* Copyright (c) 2021 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/

import { che as chetypes } from '@eclipse-che/api'
import { CoreV1Api, V1Pod, Watch } from '@kubernetes/client-node'
Expand Down
10 changes: 6 additions & 4 deletions src/api/config-manager.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
/*********************************************************************
* Copyright (c) 2020 Red Hat, Inc.
*
/**
* Copyright (c) 2021 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/

import * as fs from 'fs-extra'
import { merge } from 'lodash'
Expand Down
10 changes: 6 additions & 4 deletions src/api/context.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
/*********************************************************************
* Copyright (c) 2020 Red Hat, Inc.
*
/**
* Copyright (c) 2021 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/

import Command from '@oclif/command'
import Listr = require('listr')
Expand Down
11 changes: 9 additions & 2 deletions src/api/devfile.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
// Generated automatically via quicktype.io
/**
* This schema describes the structure of the devfile object
* Copyright (c) 2021 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
export interface Devfile {
attributes?: { [key: string]: string }
Expand Down
10 changes: 6 additions & 4 deletions src/api/github-client.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
/*********************************************************************
* Copyright (c) 2020-2021 Red Hat, Inc.
*
/**
* Copyright (c) 2021 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/

import { Octokit } from '@octokit/rest'

Expand Down
10 changes: 6 additions & 4 deletions src/api/kube.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
/*********************************************************************
* Copyright (c) 2019-2020 Red Hat, Inc.
*
/**
* Copyright (c) 2021 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/

import { AdmissionregistrationV1Api, ApiextensionsV1Api, ApiextensionsV1beta1Api, ApisApi, AppsV1Api, AuthorizationV1Api, BatchV1Api, CoreV1Api, CustomObjectsApi, ExtensionsV1beta1Api, ExtensionsV1beta1IngressList, KubeConfig, Log, PortForward, RbacAuthorizationV1Api, V1ClusterRole, V1ClusterRoleBinding, V1ClusterRoleBindingList, V1ConfigMap, V1ConfigMapEnvSource, V1Container, V1ContainerStateTerminated, V1ContainerStateWaiting, V1Deployment, V1DeploymentList, V1DeploymentSpec, V1EnvFromSource, V1Job, V1JobSpec, V1LabelSelector, V1MutatingWebhookConfiguration, V1Namespace, V1NamespaceList, V1ObjectMeta, V1PersistentVolumeClaimList, V1Pod, V1PodCondition, V1PodList, V1PodSpec, V1PodTemplateSpec, V1PolicyRule, V1Role, V1RoleBinding, V1RoleBindingList, V1RoleList, V1RoleRef, V1Secret, V1SelfSubjectAccessReview, V1SelfSubjectAccessReviewSpec, V1Service, V1ServiceAccount, V1ServiceList, V1Subject, Watch } from '@kubernetes/client-node'
import { Cluster, Context } from '@kubernetes/client-node/dist/config_types'
Expand Down
10 changes: 6 additions & 4 deletions src/api/openshift.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
/*********************************************************************
* Copyright (c) 2019 Red Hat, Inc.
*
/**
* Copyright (c) 2021 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/

import execa = require('execa')

Expand Down
10 changes: 6 additions & 4 deletions src/api/typings/cert-manager.d.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
/*********************************************************************
* Copyright (c) 2020 Red Hat, Inc.
*
/**
* Copyright (c) 2021 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/

export interface V1Certificate {
apiVersion: string
Expand Down
10 changes: 6 additions & 4 deletions src/api/typings/olm.d.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
/*********************************************************************
* Copyright (c) 2020 Red Hat, Inc.
*
/**
* Copyright (c) 2021 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/

import { V1Deployment, V1ObjectMeta } from '@kubernetes/client-node'

Expand Down
10 changes: 6 additions & 4 deletions src/api/typings/openshift.d.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
/*********************************************************************
* Copyright (c) 2020 Red Hat, Inc.
*
/**
* Copyright (c) 2021 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/

export interface OAuth {
apiVersion: string;
Expand Down
Loading

0 comments on commit 8f38ff2

Please sign in to comment.