提交 4a5a511a 编写于 作者: M Marcin Maciaszczyk

Use gts for checking code

上级 e8e4fd43
......@@ -25,7 +25,7 @@ before_script:
jobs:
include:
- stage: test
script: npm run check:static
script: npm run check
- script: npm run test:coverage
after_success:
- bash <(curl -s https://codecov.io/bash)
......
此差异已折叠。
......@@ -32,29 +32,27 @@
"test:coverage": "npm run test:frontend:coverage && npm run test:backend:coverage",
"test:e2e": "ng e2e",
"cluster": "./aio/scripts/start-cluster.sh",
"check": "npm run check:static && npm run test && npm run test:e2e",
"check:static": "npm run check:license && npm run lint && npm run check:format",
"check": "concurrently \"npm run check:backend\" \"npm run check:frontend\" \"npm run check:license\"",
"check:backend": "./aio/scripts/lint-backend.sh",
"check:frontend": "concurrently \"npm run check:frontend:ts\" \"npm run check:frontend:scss\" \"npm run check:frontend:html\"",
"check:frontend:ts": "gts check",
"check:frontend:scss": "./aio/scripts/format.sh --styles --check && ./node_modules/sass-lint/bin/sass-lint.js -c .sass-lint.yml 'src/app/frontend/**/*.scss' -v -q",
"check:frontend:html": "./aio/scripts/format.sh --html --check",
"check:license": "gulp check-license-headers",
"check:format": "concurrently \"npm run check:format:code\" \"npm run check:format:styles\" \"npm run check:format:html\"",
"check:format:code": "./aio/scripts/format.sh --code --check",
"check:format:styles": "./aio/scripts/format.sh --styles --check",
"check:format:html": "./aio/scripts/format.sh --html --check",
"lint": "npm run lint:frontend && npm run lint:backend",
"lint:frontend": "npm run lint:frontend:code && npm run lint:frontend:styles",
"lint:frontend:code": "tslint -c tslint.json --project . -t codeFrame --fix",
"lint:frontend:styles": "./node_modules/sass-lint/bin/sass-lint.js -c .sass-lint.yml 'src/app/frontend/**/*.scss' -v -q",
"lint:backend": "./aio/scripts/lint-backend.sh",
"format": "npm run format:headers && concurrently \"npm run format:frontend\" \"npm run format:backend\"",
"format:headers": "gulp update-license-headers",
"format:frontend": "./aio/scripts/format.sh --code --styles --html",
"format:backend": "goimports -w src/app/backend",
"fix": "concurrently \"npm run fix:backend\" \"npm run fix:frontend\" \"npm run fix:license\"",
"fix:backend": "goimports -w src/app/backend",
"fix:frontend": "concurrently \"npm run fix:frontend:ts\" \"npm run fix:frontend:scss\" \"npm run fix:frontend:html\"",
"fix:frontend:ts": "gts fix",
"fix:frontend:scss": "./aio/scripts/format.sh --styles",
"fix:frontend:html": "./aio/scripts/format.sh --html",
"fix:license": "gulp update-license-headers",
"clean": "rm -rf .go_workspace .tmp coverage dist npm-debug.log",
"postversion": "node aio/scripts/version.js",
"postinstall": "node aio/scripts/version.js && webdriver-manager update && go get golang.org/x/tools/cmd/goimports",
"clean": "rm -rf .go_workspace .tmp coverage dist npm-debug.log"
"postinstall": "node aio/scripts/version.js && webdriver-manager update && go get golang.org/x/tools/cmd/goimports"
},
"husky": {
"hooks": {
"pre-commit": "npm run check:static"
"pre-commit": "npm run check"
}
},
"dependencies": {
......@@ -145,7 +143,8 @@
"through2": "^3.0.0",
"ts-node": "~5.0.1",
"tslint": "~5.11.0",
"typescript": "3.1.6"
"typescript": "3.1.6",
"gts": "^0.9.0"
},
"engines": {
"node": ">=8.0.0",
......
......@@ -18,7 +18,6 @@ import {StateDeclaration, StateObject, StateService} from '@uirouter/core';
import {searchState} from '../../../search/state';
import {SEARCH_QUERY_STATE_PARAM} from '../../params/params';
/** Breadcrumbs config string used on state config. **/
const breadcrumbsConfig = 'kdBreadcrumbs';
@Injectable()
......
......@@ -14,7 +14,7 @@
import {HttpClient} from '@angular/common/http';
import {Component, EventEmitter, forwardRef, Input, OnInit, Output} from '@angular/core';
import {AbstractControl, ControlValueAccessor, FormArray, FormBuilder, FormControl, FormGroup, NG_ASYNC_VALIDATORS, NG_VALIDATORS, NG_VALUE_ACCESSOR, Validators} from '@angular/forms';
import {AbstractControl, ControlValueAccessor, FormArray, FormBuilder, FormControl, FormGroup, NG_ASYNC_VALIDATORS, NG_VALUE_ACCESSOR, Validators} from '@angular/forms';
import {PortMapping} from '@api/backendapi';
import {Observable} from 'rxjs';
import {first, map, startWith} from 'rxjs/operators';
......@@ -22,20 +22,8 @@ import {FormValidators} from '../validator/validators';
import {validateProtocol} from '../validator/validprotocol.validator';
const i18n = {
/**
@export {string} @desc Label 'None', which appears as an option in the service type
selection box on the deploy page.
*/
MSG_PORT_MAPPINGS_SERVICE_TYPE_NONE_LABEL: 'None',
/**
@export {string} @desc Label 'Internal', which appears as an option in the service type
selection box on the deploy page.
*/
MSG_PORT_MAPPINGS_SERVICE_TYPE_INTERNAL_LABEL: 'Internal',
/**
@export {string} @desc Label 'External', which appears as an option in the service type
selection box on the deploy page.
*/
MSG_PORT_MAPPINGS_SERVICE_TYPE_EXTERNAL_LABEL: 'External',
};
......@@ -77,28 +65,11 @@ const EXT_SERVICE: ServiceType = {
],
})
export class PortMappingsComponent implements OnInit, ControlValueAccessor {
/**
* Initialized from the scope.
*/
@Input() protocols: string[];
/**
* Available service types
*/
serviceTypes: ServiceType[];
/**
* Selected service type. Binding to outer scope.
*/
// serviceType: ServiceType;
/**
* Binding to outer scope.
*/
@Input() isExternal: boolean;
@Output() changeExternal: EventEmitter<boolean> = new EventEmitter<boolean>();
serviceTypes: ServiceType[];
portMappingForm: FormGroup;
constructor(private readonly fb_: FormBuilder, private readonly http_: HttpClient) {}
......@@ -158,10 +129,12 @@ export class PortMappingsComponent implements OnInit, ControlValueAccessor {
private newEmptyPortMapping(defaultProtocol: string): FormGroup {
return this.fb_.group({
port: [
'', Validators.compose([FormValidators.isInteger, Validators.min(1), Validators.max(65535)])
'',
Validators.compose([FormValidators.isInteger, Validators.min(1), Validators.max(65535)])
],
targetPort: [
'', Validators.compose([FormValidators.isInteger, Validators.min(1), Validators.max(65535)])
'',
Validators.compose([FormValidators.isInteger, Validators.min(1), Validators.max(65535)])
],
protocol: [defaultProtocol]
});
......
......@@ -26,9 +26,11 @@ export const uniqueNameValidationKey = 'uniqueName';
*/
@Directive({
selector: '[kdUniqueName]',
providers: [
{provide: NG_ASYNC_VALIDATORS, useExisting: forwardRef(() => UniqueNameValidator), multi: true}
]
providers: [{
provide: NG_ASYNC_VALIDATORS,
useExisting: forwardRef(() => UniqueNameValidator),
multi: true
}]
})
export class UniqueNameValidator implements AsyncValidator {
@Input() namespace: string;
......
......@@ -36,8 +36,9 @@ import {AbstractControl, NG_VALIDATORS, Validator} from '@angular/forms';
*/
@Directive({
selector: '[kdWarnThreshold]',
providers:
[{provide: NG_VALIDATORS, useExisting: forwardRef(() => WarnThresholdValidator), multi: true}]
providers: [
{provide: NG_VALIDATORS, useExisting: forwardRef(() => WarnThresholdValidator), multi: true}
]
})
export class WarnThresholdValidator implements Validator {
@Input() kdWarnThreshold: number;
......
......@@ -15,65 +15,21 @@
/**
* This file includes polyfills needed by Angular and is loaded before the app.
* You can add your own extra polyfills to this file.
*
* This file is divided into 2 sections:
* 1. Browser polyfills. These are applied before loading ZoneJS and are
* sorted by browsers.
* 2. Application imports. Files imported after ZoneJS that should be loaded
* before your main file.
*
* The current setup is for so-called "evergreen" browsers; the last versions of
* browsers that automatically update themselves. This includes Safari >= 10,
* Chrome >= 55 (including Opera), Edge >= 13 on the desktop, and iOS 10 and
* Chrome on mobile.
*
* Learn more in https://angular.io/docs/ts/latest/guide/browser-support.html
*/
/***************************************************************************************************
* BROWSER POLYFILLS
*/
/** IE9, IE10 and IE11 requires all of the following polyfills. **/
// import 'core-js/es6/symbol';
// import 'core-js/es6/object';
// import 'core-js/es6/function';
// import 'core-js/es6/parse-int';
// import 'core-js/es6/parse-float';
// import 'core-js/es6/number';
// import 'core-js/es6/math';
// import 'core-js/es6/string';
// import 'core-js/es6/date';
// import 'core-js/es6/array';
// import 'core-js/es6/regexp';
// import 'core-js/es6/map';
// import 'core-js/es6/weak-map';
// import 'core-js/es6/set';
/** IE10 and IE11 requires the following for NgClass support on SVG elements */
// import 'classlist.js'; // Run `npm install --save classlist.js`.
/** IE10 and IE11 requires the following for the Reflect API. */
// IE10 and IE11 requires the following for the Reflect API.
import 'core-js/es7/reflect';
import 'hammerjs';
/**
* Required to support Web Animations `@angular/platform-browser/animations`.
* Needed for: All but Chrome, Firefox and Opera.
*
* http://caniuse.com/#feat=web-animation
**/
// Required to support Web Animations `@angular/platform-browser/animations`:
import 'web-animations-js';
/**
* Zone JS is required by default for Angular itself.
*/
// Zone JS is required by default for Angular itself.
import 'zone.js/dist/zone';
/**
* RxJS is required to support additional Observable methods such as map or switchMap.
*/
// RxJS is required to support additional Observable methods such as map or switchMap.
import 'rxjs/Rx';
import 'core-js/es7/reflect'; // needed for unit testing
// Needed for unit testing.
import 'core-js/es7/reflect';
......@@ -103,8 +103,9 @@ class MaxiTestComponent {
status: {failed: 2, pending: 1, running: 3, succeeded: 5},
cumulativeMetrics: [],
listMeta: {totalItems: 1},
errors:
[{ErrStatus: {message: 'error message', code: 10, status: 'Ready', reason: 'the reason'}}]
errors: [{
ErrStatus: {message: 'error message', code: 10, status: 'Ready', reason: 'the reason'}
}]
},
sessionAffinity: 'affinity1',
errors: []
......
{
"extends": "./node_modules/gts/tsconfig-google.json",
"angularCompilerOptions": {
"annotationsAs": "static fields",
"annotateForClosureCompiler": true
......
{
"rules": {
"array-type": [true, "array-simple"],
"arrow-return-shorthand": true,
"ban": [true,
{"name": "parseInt", "message": "tsstyle#type-coercion"},
{"name": "parseFloat", "message": "tsstyle#type-coercion"},
{"name": "Array", "message": "tsstyle#array-constructor"}
],
"ban-types": [true,
["Object", "Use {} instead."],
["String", "Use 'string' instead."],
["Number", "Use 'number' instead."],
["Boolean", "Use 'boolean' instead."]
],
"class-name": true,
"comment-format": [true, "check-space"],
"curly": [true, "ignore-same-line"],
"eofline": true,
"forin": true,
"interface-name": [true, "never-prefix"],
"jsdoc-format": false,
"label-position": true,
"member-access": [true, "no-public"],
"new-parens": true,
"no-angle-bracket-type-assertion": true,
"no-any": true,
"no-arg": true,
"no-conditional-assignment": true,
"no-consecutive-blank-lines": true,
"no-console": true,
"no-construct": true,
"no-debugger": true,
"no-default-export": true,
"no-duplicate-variable": true,
"no-inferrable-types": true,
"no-namespace": [true, "allow-declarations"],
"no-reference": true,
"no-string-throw": true,
"no-trailing-whitespace": true,
"no-unused-expression": true,
"no-unsafe-finally": true,
"no-var-keyword": true,
"object-literal-shorthand": true,
"ordered-imports": true,
"only-arrow-functions": [true, "allow-declarations", "allow-named-functions"],
"prefer-const": true,
"prefer-readonly": true,
"radix": true,
"semicolon": [true, "always"],
"switch-default": true,
"triple-equals": [true, "allow-null-check"],
"use-isnan": true,
"variable-name": [
true,
"check-format",
"ban-keywords",
"allow-leading-underscore",
"allow-trailing-underscore"
],
"typedef": [
true,
"call-signature",
"property-declaration"
]
}
"extends": "gts/tslint.json"
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册