Skip to content

chore: cleanup package and dependencies - change compile target to es6 #182

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

Merged
merged 11 commits into from
Nov 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions .npmignore

This file was deleted.

3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
language: node_js
node_js:
- '6'
- '8'
install:
- yarn install
- yarn build
- yarn add $WEBPACK $TSLOADER $VUELOADER -D
- yarn lint
env:
- WEBPACK=webpack@^4.0.0 TSLOADER=ts-loader@^4.3.0 VUELOADER=vue-loader@^15.2.4
- WEBPACK=webpack@^4.0.0 TSLOADER=ts-loader@^5.0.0 VUELOADER=vue-loader@^15.2.4
- WEBPACK=webpack@^3.10.0 TSLOADER=ts-loader@^3.4.0 VUELOADER=vue-loader@^13.5.0
- WEBPACK=webpack@^2.7.0 TSLOADER=ts-loader@^3.4.0 VUELOADER=vue-loader@^13.5.0
deploy:
Expand Down
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
## 0.5.0
* Removed unused dependency `resolve`.
* Replace `lodash` usage with native calls.
* ** Breaking Changes**:
* Removed all getters from `NormalizedMessage`, use direct property access instead.
* **Internal**:
* Test against ts-loader v5
* Enable all strict type checks
* Update dev dependencies


## v0.4.15

* [Add `tslintAutoFix` option to be passed on to tslint to auto format typescript files](https://github.com/Realytics/fork-ts-checker-webpack-plugin/pull/174) (#174)
Expand Down
Binary file removed fork-ts-checker-webpack-plugin-v0.4.11.tgz
Binary file not shown.
28 changes: 12 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "fork-ts-checker-webpack-plugin",
"version": "0.4.15",
"version": "0.5.0",
"description": "Runs typescript type checker and linter on separate process.",
"main": "lib/index.js",
"types": "lib/types/index.d.ts",
"types": "lib/index.d.ts",
"files": [
"lib"
],
Expand Down Expand Up @@ -51,27 +51,25 @@
"devDependencies": {
"@types/babel-code-frame": "^6.20.1",
"@types/chokidar": "^1.7.5",
"@types/lodash": "^4.14.117",
"@types/micromatch": "^3.1.0",
"@types/minimatch": "^3.0.1",
"@types/node": "^8.0.26",
"@types/resolve": "0.0.4",
"@types/webpack": "^4.4.9",
"chai": "^3.5.0",
"css-loader": "^0.28.7",
"@types/node": "^8.10.38",
"@types/webpack": "^4.4.19",
"chai": "^4.2.0",
"css-loader": "0.28.11",
"eslint": "^5.7.0",
"husky": "^1.1.2",
"husky": "^1.1.4",
"istanbul": "^0.4.5",
"lint-staged": "^7.3.0",
"lint-staged": "^8.0.5",
"mocha": "^5.2.0",
"mock-fs": "^4.3.0",
"mock-require": "^2.0.2",
"mock-require": "^3.0.2",
"prettier": "^1.14.3",
"rimraf": "^2.5.4",
"sinon": "^2.3.1",
"ts-loader": "4.3.0",
"sinon": "^7.1.1",
"ts-loader": "^5.3.0",
"tslint": "^5.11.0",
"tslint-config-prettier": "^1.15.0",
"tslint-config-prettier": "^1.16.0",
"typescript": "^3.0.1",
"vue": "^2.5.16",
"vue-class-component": "^6.1.1",
Expand All @@ -88,10 +86,8 @@
"babel-code-frame": "^6.22.0",
"chalk": "^2.4.1",
"chokidar": "^2.0.4",
"lodash": "^4.17.11",
"micromatch": "^3.1.10",
"minimatch": "^3.0.4",
"resolve": "^1.5.0",
"tapable": "^1.0.0"
},
"husky": {
Expand Down
22 changes: 11 additions & 11 deletions src/CancellationToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,32 @@ interface CancellationTokenData {
}

export class CancellationToken {
isCancelled: boolean;
cancellationFileName: string;
lastCancellationCheckTime: number;
constructor(cancellationFileName: string, isCancelled: boolean) {
private isCancelled: boolean;
private cancellationFileName: string;
private lastCancellationCheckTime: number;
constructor(cancellationFileName?: string, isCancelled?: boolean) {
this.isCancelled = !!isCancelled;
this.cancellationFileName =
cancellationFileName || crypto.randomBytes(64).toString('hex');
this.lastCancellationCheckTime = 0;
}

static createFromJSON(json: CancellationTokenData) {
public static createFromJSON(json: CancellationTokenData) {
return new CancellationToken(json.cancellationFileName, json.isCancelled);
}

toJSON() {
public toJSON() {
return {
cancellationFileName: this.cancellationFileName,
isCancelled: this.isCancelled
};
}

getCancellationFilePath() {
public getCancellationFilePath() {
return path.join(os.tmpdir(), this.cancellationFileName);
}

isCancellationRequested() {
public isCancellationRequested() {
if (this.isCancelled) {
return true;
}
Expand All @@ -52,18 +52,18 @@ export class CancellationToken {
return this.isCancelled;
}

throwIfCancellationRequested() {
public throwIfCancellationRequested() {
if (this.isCancellationRequested()) {
throw new ts.OperationCanceledException();
}
}

requestCancellation() {
public requestCancellation() {
fs.writeFileSync(this.getCancellationFilePath(), '');
this.isCancelled = true;
}

cleanupCancellation() {
public cleanupCancellation() {
if (this.isCancelled && fs.existsSync(this.getCancellationFilePath())) {
fs.unlinkSync(this.getCancellationFilePath());
this.isCancelled = false;
Expand Down
32 changes: 16 additions & 16 deletions src/FilesRegister.ts
Original file line number Diff line number Diff line change
@@ -1,70 +1,70 @@
import * as ts from 'typescript';
import { RuleFailure } from 'tslint';

interface DataShape {
source: ts.SourceFile;
export interface DataShape {
source?: ts.SourceFile;
linted: boolean;
lints: any[];
lints: RuleFailure[];
}

export class FilesRegister {
files: { [filePath: string]: { mtime: number; data: DataShape } };
dataFactory: (_data?: any) => DataShape; // It doesn't seem that the _data parameter is ever used?
private files: { [filePath: string]: { mtime?: number; data: DataShape } };

constructor(dataFactory: (_data?: any) => DataShape) {
constructor(private dataFactory: (_data?: DataShape) => DataShape) {
this.files = {};
this.dataFactory = dataFactory;
}

keys() {
public keys() {
return Object.keys(this.files);
}

add(filePath: string) {
public add(filePath: string) {
this.files[filePath] = {
mtime: undefined,
data: this.dataFactory(undefined)
};
}

remove(filePath: string) {
public remove(filePath: string) {
if (this.has(filePath)) {
delete this.files[filePath];
}
}

has(filePath: string) {
public has(filePath: string) {
return this.files.hasOwnProperty(filePath);
}

get(filePath: string) {
public get(filePath: string) {
if (!this.has(filePath)) {
throw new Error('File "' + filePath + '" not found in register.');
}

return this.files[filePath];
}

ensure(filePath: string) {
public ensure(filePath: string) {
if (!this.has(filePath)) {
this.add(filePath);
}
}

getData(filePath: string) {
public getData(filePath: string) {
return this.get(filePath).data;
}

mutateData(filePath: string, mutator: (data: DataShape) => void) {
public mutateData(filePath: string, mutator: (data: DataShape) => void) {
this.ensure(filePath);

mutator(this.files[filePath].data);
}

getMtime(filePath: string) {
public getMtime(filePath: string) {
return this.get(filePath).mtime;
}

setMtime(filePath: string, mtime: number) {
public setMtime(filePath: string, mtime: number) {
this.ensure(filePath);

if (this.files[filePath].mtime !== mtime) {
Expand Down
24 changes: 10 additions & 14 deletions src/FilesWatcher.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
import * as chokidar from 'chokidar';
import * as path from 'path';
import startsWith = require('lodash/startsWith');

export class FilesWatcher {
watchPaths: string[];
watchExtensions: string[];
watchers: chokidar.FSWatcher[];
listeners: { [eventName: string]: Function[] };
constructor(watchPaths: string[], watchExtensions: string[]) {
this.watchPaths = watchPaths;
private watchers: chokidar.FSWatcher[];
private listeners: { [eventName: string]: Function[] };
constructor(private watchPaths: string[], private watchExtensions: string[]) {
this.watchExtensions = watchExtensions;
this.watchers = [];
this.listeners = {};
}

isFileSupported(filePath: string) {
public isFileSupported(filePath: string) {
return this.watchExtensions.indexOf(path.extname(filePath)) !== -1;
}

watch() {
public watch() {
if (this.isWatching()) {
throw new Error('Cannot watch again - already watching.');
}
Expand All @@ -43,27 +39,27 @@ export class FilesWatcher {
});
}

isWatchingFile(filePath: string) {
public isWatchingFile(filePath: string) {
return (
this.isWatching() &&
this.isFileSupported(filePath) &&
this.watchPaths.some(watchPath => startsWith(filePath, watchPath))
this.watchPaths.some(watchPath => filePath.startsWith(watchPath))
);
}

isWatching() {
public isWatching() {
return this.watchers.length > 0;
}

on(event: string, listener: Function) {
public on(event: string, listener: Function) {
if (!this.listeners[event]) {
this.listeners[event] = [];
}

this.listeners[event].push(listener);
}

off(event: string, listener: Function) {
public off(event: string, listener: Function) {
if (this.listeners[event]) {
this.listeners[event] = this.listeners[event].filter(
oldListener => oldListener !== listener
Expand Down
Loading