Skip to content

Commit

Permalink
upgrade tslint codelyzer, fix test
Browse files Browse the repository at this point in the history
* Fixes existing lint errors.

* mport FormsModule for required test modules

* Fix failing unit test message  on travis
Reference: angular/angular-cli#7296

* Removes yarn due to failing tests on travis only.
  • Loading branch information
harunurhan committed Oct 24, 2017
1 parent 37866b4 commit 34dc67d
Show file tree
Hide file tree
Showing 13 changed files with 50 additions and 6,313 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ addons:
- google-chrome
packages:
- google-chrome-stable
cache: yarn
env:
global:
- GH_REF: 'github.com/inveniosoftware-contrib/ng2-json-editor.git'
Expand All @@ -22,6 +21,7 @@ before_install:
- export CHROME_BIN=chromium-browser
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
after_install: npm ls
before_deploy:
- npm run build
- npm run copy
Expand Down
6 changes: 4 additions & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,17 @@ var extReplace = require('gulp-ext-replace');
var ngc = require('gulp-ngc');
var del = require('del');
var tsLint = require('gulp-tslint');
var Linter = require('tslint').Linter;
var tsLintProgram = Linter.createProgram('./src/tsconfig.json');
var inlineResources = require('inline-ng2-resources');
var KarmaServer = require('karma').Server;
var runSequence = require('run-sequence');

// run tslint
gulp.task('tslint', () => {
return gulp.src('./src/**/*.ts')
return gulp.src('./src/**/*.ts', { base: '.' })
.pipe(tsLint({
configuration: 'tslint.json',
program: tsLintProgram,
formatter: 'prose'
}))
.pipe(tsLint.report({
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
"build": "gulp build",
"start": "npm run build && npm run serve",
"serve": "ng serve",
"lint": "tslint \"src/**/*.ts\"",
"test:unit": "ng test --code-coverage --watch=false",
"lint": "tslint --project ./src/tsconfig.json \"src/**/*.ts\"",
"test:unit": "ng test --code-coverage --sourcemaps=false --watch=false",
"test": "npm-run-all build test:unit e2e:travis",
"pree2e": "webdriver-manager update",
"e2e": "protractor",
Expand Down Expand Up @@ -71,7 +71,7 @@
"@types/mousetrap": "^1.5.32",
"@types/node": "~6.0.60",
"bootstrap-sass": "^3.3.7",
"codelyzer": "~2.0.0-beta.1",
"codelyzer": "~3.2.0",
"copyfiles": "^1.2.0",
"core-js": "^2.4.1",
"coveralls": "^2.11.12",
Expand All @@ -81,7 +81,7 @@
"gulp-ext-replace": "^0.3.0",
"gulp-ngc": "^0.1.2",
"gulp-sass": "^2.3.2",
"gulp-tslint": "^7.0.1",
"gulp-tslint": "^8.1.2",
"inline-ng2-resources": "1.1.0",
"jasmine-core": "~2.5.2",
"jasmine-spec-reporter": "~3.2.0",
Expand All @@ -98,7 +98,7 @@
"rxjs": "^5.0.1",
"ts-helpers": "^1.1.1",
"ts-node": "1.2.1",
"tslint": "^4.3.0",
"tslint": "^5.0.0",
"typedoc": "^0.5.5",
"typescript": "~2.3.0",
"util-deprecate": "^1.0.2",
Expand Down
4 changes: 3 additions & 1 deletion src/autocomplete-input/autocomplete-input.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
*/

import { HttpModule } from '@angular/http';
import { FormsModule } from '@angular/forms';
import {
async,
ComponentFixture,
Expand Down Expand Up @@ -71,7 +72,8 @@ describe('AutocompleteInputComponent', () => {
],
imports: [
Ng2BootstrapModule.forRoot(),
HttpModule
HttpModule,
FormsModule
],
providers: [
{ provide: RemoteAutocompletionService, useClass: MockRemoteAutocompletionService },
Expand Down
2 changes: 1 addition & 1 deletion src/json-editor.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,4 @@ export {
PatchesConsoleTabComponent,
ErrorsConsoleTabComponent,
AddPatchViewComponent
}
};
4 changes: 3 additions & 1 deletion src/primitive-field/primitive-field.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
ComponentFixture,
TestBed
} from '@angular/core/testing';
import { FormsModule } from '@angular/forms';
import { Ng2BootstrapModule } from 'ngx-bootstrap';
import { Observable } from 'rxjs/Observable';
import { ReplaySubject } from 'rxjs/ReplaySubject';
Expand Down Expand Up @@ -96,7 +97,8 @@ describe('PrimitiveFieldComponent', () => {
PatchActionsComponent
],
imports: [
Ng2BootstrapModule.forRoot()
Ng2BootstrapModule.forRoot(),
FormsModule
],
providers: [
AppGlobalsService,
Expand Down
2 changes: 1 addition & 1 deletion src/searchable-dropdown/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { SearchableDropdownComponent } from './searchable-dropdown.component'
export { SearchableDropdownComponent } from './searchable-dropdown.component';
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
ComponentFixture,
TestBed,
} from '@angular/core/testing';
import { FormsModule } from '@angular/forms';
import { Ng2BootstrapModule } from 'ngx-bootstrap';

import { SearchableDropdownComponent } from './searchable-dropdown.component';
Expand Down Expand Up @@ -52,7 +53,8 @@ describe('SearchableDropdownComponent', () => {
SearchableDropdownComponent,
],
imports: [
Ng2BootstrapModule.forRoot()
Ng2BootstrapModule.forRoot(),
FormsModule
]
}).compileComponents();
}));
Expand Down
2 changes: 1 addition & 1 deletion src/shared/interfaces/view-template-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ export interface ViewTemplateConfig {
* - false if the fields to edit should be hidden by default
*/
showEditForm: (item: Map<string, any>) => boolean;
};
}
2 changes: 1 addition & 1 deletion src/shared/services/katex.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export class KatexService {
}

return -1;
};
}

private splitAtDelimiters(startData: Array<KatexData>, leftDelim: string, rightDelim: string, display: boolean): Array<KatexData> {
const finalData = [];
Expand Down
2 changes: 1 addition & 1 deletion src/tree-menu/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ import { TreeMenuItemComponent } from './tree-menu-item.component';
export {
TreeMenuComponent,
TreeMenuItemComponent
}
};
33 changes: 26 additions & 7 deletions tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
"curly": true,
"eofline": true,
"forin": true,
"import-blacklist": [true, "rxjs"],
"import-blacklist": [
true,
"rxjs"
],
"import-spacing": true,
"indent": [
true,
Expand All @@ -27,8 +30,14 @@
"member-access": false,
"member-ordering": [
true,
"static-before-instance",
"variables-before-functions"
{
"order": [
"static-field",
"instance-field",
"static-method",
"instance-method"
]
}
],
"no-arg": true,
"no-bitwise": true,
Expand Down Expand Up @@ -70,6 +79,7 @@
],
"radix": true,
"semicolon": [
true,
"always"
],
"triple-equals": [
Expand Down Expand Up @@ -97,9 +107,18 @@
"check-separator",
"check-type"
],

"directive-selector": [true, "attribute", "", "camelCase"],
"component-selector": [true, "element", "", "kebab-case"],
"directive-selector": [
true,
"attribute",
"",
"camelCase"
],
"component-selector": [
true,
"element",
"",
"kebab-case"
],
"use-input-property-decorator": true,
"use-output-property-decorator": true,
"use-host-property-decorator": true,
Expand All @@ -113,4 +132,4 @@
"templates-use-public": false,
"invoke-injectable": true
}
}
}
Loading

0 comments on commit 34dc67d

Please sign in to comment.