Skip to content

Commit 81b08b2

Browse files
committed
Fix ESLint issues for gulp-core-build
1 parent 08b8a89 commit 81b08b2

23 files changed

+136
-127
lines changed

apps/rush-lib/src/logic/TaskSelector.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,6 @@ export class TaskSelector {
218218
}
219219

220220
private _getScriptCommand(rushProject: RushConfigurationProject, script: string): string | undefined {
221-
// tslint:disable-next-line:no-string-literal
222221
if (!rushProject.packageJson.scripts) {
223222
return undefined;
224223
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// This is a workaround for https://github.com/eslint/eslint/issues/3458
2+
require("@rushstack/eslint-config/patch-eslint6");
3+
4+
module.exports = {
5+
extends: [ "@rushstack/eslint-config" ],
6+
parserOptions: { tsconfigRootDir: __dirname },
7+
};

core-build/gulp-core-build/src/GulpProxy.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ export class GulpProxy extends Orchestrator {
1313
public dest: gulp.DestMethod;
1414
public watch: gulp.WatchMethod;
1515

16-
constructor(gulpInstance: gulp.Gulp) {
16+
public constructor(gulpInstance: gulp.Gulp) {
1717
super();
1818
this.src = gulpInstance.src;
1919
this.dest = gulpInstance.dest;
2020
this.watch = gulpInstance.watch;
2121
}
2222

23-
/* tslint:disable-next-line:no-any */
23+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
2424
public task(): any {
2525
throw new Error(
2626
'You should not define gulp tasks directly, but instead subclass the GulpTask or call subTask(), and register it to gulp-core-build.'

core-build/gulp-core-build/src/IBuildConfig.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ import * as gulp from 'gulp';
55
import { GulpProxy } from './GulpProxy';
66
import { IExecutable } from './IExecutable';
77

8-
/* tslint:disable:no-any */
9-
108
/**
119
* @public
1210
*/
@@ -119,6 +117,7 @@ export interface IBuildConfig {
119117
/**
120118
* Arbitrary property bag for a task to store environment values in.
121119
*/
120+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
122121
properties?: { [key: string]: any };
123122

124123
/**
@@ -129,6 +128,7 @@ export interface IBuildConfig {
129128
/**
130129
* Optional callback to be executed when a task ends.
131130
*/
131+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
132132
onTaskEnd?: (taskName: string, duration: number[], error?: any) => void;
133133

134134
/**

core-build/gulp-core-build/src/IExecutable.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,6 @@ export interface IExecutable {
4040
/**
4141
* Optional method to indicate directory matches to clean up when the clean task is run.
4242
*/
43-
getCleanMatch?: (config: IBuildConfig, taskConfig?: any) => string[]; /* tslint:disable-line:no-any */
43+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
44+
getCleanMatch?: (config: IBuildConfig, taskConfig?: any) => string[];
4445
}

core-build/gulp-core-build/src/State.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,6 @@ try {
3131
}
3232

3333
export const builtPackage: IPackageJSON = packageJson;
34+
// eslint-disable-next-line @typescript-eslint/no-var-requires
3435
export const coreBuildPackage: IPackageJSON = require('../package.json');
3536
export const nodeVersion: string = process.version;

core-build/gulp-core-build/src/config.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@ export function getFlagValue(name: string, defaultValue?: boolean): boolean {
2626
return configValue === 'true' || configValue === true;
2727
}
2828

29-
/* tslint:disable:no-any */
29+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
3030
function _firstDefinedValue(...values: (string | boolean | undefined)[]): any {
31-
/* tslint:enable:no-any */
3231
for (const value of values) {
3332
if (value !== undefined) {
3433
return value;

core-build/gulp-core-build/src/index.ts

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,8 @@ let _buildConfig: IBuildConfig = {
9191
* @public
9292
*/
9393
export function setConfig(config: Partial<IBuildConfig>): void {
94-
/* tslint:disable:typedef */
94+
// eslint-disable-next-line
9595
const objectAssign = require('object-assign');
96-
/* tslint:enable:typedef */
9796

9897
_buildConfig = objectAssign({}, _buildConfig, config);
9998
}
@@ -105,9 +104,8 @@ export function setConfig(config: Partial<IBuildConfig>): void {
105104
* @public
106105
*/
107106
export function mergeConfig(config: Partial<IBuildConfig>): void {
108-
/* tslint:disable:typedef */
107+
// eslint-disable-next-line
109108
const merge = require('lodash.merge');
110-
/* tslint:enable:typedef */
111109

112110
_buildConfig = merge({}, _buildConfig, config);
113111
}
@@ -158,20 +156,21 @@ export function task(taskName: string, taskExecutable: IExecutable): IExecutable
158156
* @public
159157
*/
160158
export interface ICustomGulpTask {
161-
(gulp: typeof Gulp | GulpProxy, buildConfig: IBuildConfig, done?: (failure?: Object) => void):
162-
Promise<Object> | NodeJS.ReadWriteStream | void;
159+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
160+
(gulp: typeof Gulp | GulpProxy, buildConfig: IBuildConfig, done?: (failure?: any) => void):
161+
Promise<object> | NodeJS.ReadWriteStream | void;
163162
}
164163

165164
/** @public */
166165
class CustomTask extends GulpTask<void> {
167166
private _fn: ICustomGulpTask;
168-
constructor(name: string, fn: ICustomGulpTask) {
167+
public constructor(name: string, fn: ICustomGulpTask) {
169168
super(name);
170169
this._fn = fn.bind(this);
171170
}
172171

173172
public executeTask(gulp: typeof Gulp | GulpProxy, completeCallback?: (error?: string | Error) => void):
174-
Promise<Object> | NodeJS.ReadWriteStream | void {
173+
Promise<object> | NodeJS.ReadWriteStream | void {
175174
return this._fn(gulp, getConfig(), completeCallback);
176175
}
177176
}
@@ -279,8 +278,8 @@ export function watch(watchMatch: string | string[], taskExecutable: IExecutable
279278
* Takes in IExecutables as arguments and returns an IExecutable that will execute them in serial.
280279
* @public
281280
*/
282-
export function serial(...tasks: Array<IExecutable[] | IExecutable>): IExecutable {
283-
const flatTasks: IExecutable[] = <IExecutable[]>_flatten(tasks).filter(taskExecutable => {
281+
export function serial(...tasks: (IExecutable[] | IExecutable)[]): IExecutable {
282+
const flatTasks: IExecutable[] = _flatten(tasks).filter(taskExecutable => {
284283
// eslint-disable-next-line no-restricted-syntax
285284
return taskExecutable !== null && taskExecutable !== undefined;
286285
});
@@ -306,7 +305,7 @@ export function serial(...tasks: Array<IExecutable[] | IExecutable>): IExecutabl
306305
* Takes in IExecutables as arguments and returns an IExecutable that will execute them in parallel.
307306
* @public
308307
*/
309-
export function parallel(...tasks: Array<IExecutable[] | IExecutable>): IExecutable {
308+
export function parallel(...tasks: (IExecutable[] | IExecutable)[]): IExecutable {
310309
const flatTasks: IExecutable[] = _flatten<IExecutable>(tasks).filter(taskExecutable => {
311310
// eslint-disable-next-line no-restricted-syntax
312311
return taskExecutable !== null && taskExecutable !== undefined;
@@ -401,11 +400,11 @@ function _registerTask(gulp: typeof Gulp, taskName: string, taskExecutable: IExe
401400
function _executeTask(taskExecutable: IExecutable, buildConfig: IBuildConfig): Promise<void> {
402401
// Try to fallback to the default task if provided.
403402
if (taskExecutable && !taskExecutable.execute) {
404-
/* tslint:disable:no-any */
403+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
405404
if ((taskExecutable as any).default) {
405+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
406406
taskExecutable = (taskExecutable as any).default;
407407
}
408-
/* tslint:enable:no-any */
409408
}
410409

411410
// If the task is missing, throw a meaningful error.
@@ -450,10 +449,10 @@ function _trackTask(taskExecutable: IExecutable): void {
450449
/**
451450
* Flattens a set of arrays into a single array.
452451
*/
453-
function _flatten<T>(oArr: Array<T | T[]>): T[] {
452+
function _flatten<T>(oArr: (T | T[])[]): T[] {
454453
const output: T[] = [];
455454

456-
function traverse(arr: Array<T | T[]>): void {
455+
function traverse(arr: (T | T[])[]): void {
457456
for (let i: number = 0; i < arr.length; ++i) {
458457
if (Array.isArray(arr[i])) {
459458
traverse(arr[i] as T[]);
@@ -473,15 +472,15 @@ function _handleCommandLineArguments(): void {
473472
}
474473

475474
function _handleTasksListArguments(): void {
476-
/* tslint:disable:no-string-literal */
475+
/* eslint-disable dot-notation */
477476
if (args['tasks'] || args['tasks-simple'] || args['T']) {
478477
global['dontWatchExit'] = true;
479478
}
480479
if (args['h']) {
481480
// we are showing a help command prompt via yargs or ts-command-line
482481
global['dontWatchExit'] = true;
483482
}
484-
/* tslint:enable:no-string-literal */
483+
/* eslint-enable dot-notation */
485484
}
486485

487486
/** @public */

core-build/gulp-core-build/src/logging.ts

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
import * as colors from 'colors';
55
import * as Gulp from 'gulp';
66
import * as path from 'path';
7-
/* tslint:disable:typedef */
7+
// eslint-disable-next-line
88
const prettyTime = require('pretty-hrtime');
9-
/* tslint:enable:typedef */
9+
1010
import { IBuildConfig } from './IBuildConfig';
1111
import * as state from './State';
1212
import { getFlagValue } from './config';
@@ -34,14 +34,16 @@ interface ILocalCache {
3434
totalTaskSrc: number;
3535
wroteSummary: boolean;
3636
writingSummary: boolean;
37-
writeSummaryCallbacks: Array<() => void>;
37+
writeSummaryCallbacks: (() => void)[];
3838
watchMode?: boolean;
3939
fromRunGulp?: boolean;
4040
exitCode: number;
4141
writeSummaryLogs: string[];
4242
gulp: typeof Gulp | undefined;
43-
gulpErrorCallback: undefined | ((err: Object) => void);
44-
gulpStopCallback: undefined | ((err: Object) => void);
43+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
44+
gulpErrorCallback: undefined | ((err: any) => void);
45+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
46+
gulpStopCallback: undefined | ((err: any) => void);
4547
errorAndWarningSuppressions: (string | RegExp)[];
4648
shouldLogWarningsDuringSummary: boolean;
4749
shouldLogErrorsDuringSummary: boolean;
@@ -50,9 +52,8 @@ interface ILocalCache {
5052
let wiredUpErrorHandling: boolean = false;
5153
let duringFastExit: boolean = false;
5254

53-
/* tslint:disable:no-any */
55+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
5456
const globalInstance: any = global as any;
55-
/* tslint:enable:no-any */
5657

5758
const localCache: ILocalCache = globalInstance.__loggingCache = globalInstance.__loggingCache || {
5859
warnings: [],
@@ -91,9 +92,8 @@ function isVerbose(): boolean {
9192
return getFlagValue('verbose');
9293
}
9394

94-
/* tslint:disable:no-any */
95+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
9596
function formatError(e: any): string | undefined {
96-
/* tslint:enable:no-any */
9797

9898
if (!e.err) {
9999
if (isVerbose()) {
@@ -260,9 +260,8 @@ function writeSummary(callback: () => void): void {
260260
}
261261
}
262262

263-
/* tslint:disable:no-any */
263+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
264264
function _writeTaskError(e: any): void {
265-
/* tslint:enable:no-any */
266265
if (!e || !(e.err && e.err[WROTE_ERROR_KEY])) {
267266
writeError(e);
268267
localCache.taskErrors++;
@@ -287,7 +286,7 @@ function wireUpProcessErrorHandling(shouldWarningsFailBuild: boolean): void {
287286
const oldStdErr: Function = process.stderr.write;
288287
// tslint:disable-next-line:no-function-expression
289288
process.stderr.write = function (text: string | Buffer): boolean {
290-
if (!!text.toString()) {
289+
if (text.toString()) {
291290
wroteToStdErr = true;
292291
return oldStdErr.apply(process.stderr, arguments);
293292
}
@@ -297,7 +296,7 @@ function wireUpProcessErrorHandling(shouldWarningsFailBuild: boolean): void {
297296

298297
process.on('exit', (code: number) => {
299298
duringFastExit = true;
300-
if (!global['dontWatchExit']) { // tslint:disable-line:no-string-literal
299+
if (!global['dontWatchExit']) { // eslint-disable-line dot-notation
301300
if (!localCache.wroteSummary) {
302301
localCache.wroteSummary = true;
303302
console.log('About to exit with code:', code);
@@ -474,6 +473,7 @@ export function coverageData(coverage: number, threshold: number, filePath: stri
474473
localCache.coverageTotal += coverage;
475474
}
476475

476+
// eslint-disable-next-line no-control-regex
477477
const colorCodeRegex: RegExp = /\x1B[[(?);]{0,2}(;?\d)*./g;
478478

479479
/**
@@ -610,13 +610,13 @@ export function verbose(...args: string[]): void {
610610
}
611611

612612
/** @public */
613-
export function generateGulpError(err: Object): Object {
613+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
614+
export function generateGulpError(err: any): any {
614615
if (isVerbose()) {
615616
return err;
616617
} else {
617-
/* tslint:disable:no-any */
618+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
618619
const output: any = {
619-
/* tslint:enable:no-any */
620620
showStack: false,
621621
toString: (): string => {
622622
return '';
@@ -629,14 +629,13 @@ export function generateGulpError(err: Object): Object {
629629
}
630630
}
631631

632-
/* tslint:disable:no-any */
633632
/**
634633
* Logs an error to standard error and causes the build to fail.
635634
* @param e - the error (can be a string or Error object)
636635
* @public
637636
*/
637+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
638638
export function writeError(e: any): void {
639-
/* tslint:enable:no-any */
640639
if (e) {
641640
if (!e[WROTE_ERROR_KEY]) {
642641
if (e.err) {
@@ -788,12 +787,14 @@ export function initialize(
788787
// Do Nothing
789788
});
790789

791-
gulp.on('start', (err: Object) => {
790+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
791+
gulp.on('start', (err: any) => {
792792

793793
log('Starting gulp');
794794
});
795795

796-
gulp.on('stop', (err: Object) => {
796+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
797+
gulp.on('stop', (err: any) => {
797798

798799
writeSummary(() => {
799800
// error if we have any errors
@@ -811,7 +812,8 @@ export function initialize(
811812
});
812813
});
813814

814-
gulp.on('err', (err: Object) => {
815+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
816+
gulp.on('err', (err: any) => {
815817

816818
_writeTaskError(err);
817819
writeSummary(() => {
@@ -822,9 +824,8 @@ export function initialize(
822824
});
823825
});
824826

825-
/* tslint:disable:no-any */
827+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
826828
gulp.on('task_start', (e: any) => {
827-
/* tslint:enable:no-any */
828829

829830
if (localCache.fromRunGulp) {
830831
log('Starting', '\'' + colors.cyan(e.task) + '\'...');
@@ -833,9 +834,8 @@ export function initialize(
833834
localCache.taskRun++;
834835
});
835836

836-
/* tslint:disable:no-any */
837+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
837838
gulp.on('task_stop', (e: any) => {
838-
/* tslint:enable:no-any */
839839

840840
const time: string = prettyTime(e.hrDuration);
841841

@@ -847,19 +847,17 @@ export function initialize(
847847
}
848848
});
849849

850-
/* tslint:disable:no-any */
850+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
851851
gulp.on('task_err', (err: any) => {
852-
/* tslint:enable:no-any */
853852

854853
_writeTaskError(err);
855854
writeSummary(() => {
856855
exitProcess(1);
857856
});
858857
});
859858

860-
/* tslint:disable:no-any */
859+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
861860
gulp.on('task_not_found', (err: any) => {
862-
/* tslint:enable:no-any */
863861

864862
log(
865863
colors.red('Task \'' + err.task + '\' is not in your gulpfile')

0 commit comments

Comments
 (0)