Skip to content
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

TRIVIAL: use ESLint instead of TSLint #233

Merged
merged 31 commits into from
Oct 2, 2019
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
2ea218f
build(package): replace TSLint by ESLint
mrmlnc Sep 21, 2019
72fa5d0
style: fix `ban-types` rule
mrmlnc Sep 30, 2019
9a755f4
style: fix `explicit-function-return-type` rule
mrmlnc Sep 30, 2019
ad7afae
style: fix `generic-type-naming` rule
mrmlnc Sep 30, 2019
5363bd4
style: fix `member-ordering` rule
mrmlnc Sep 30, 2019
88367f9
style: fix `no-extra-parens` rule
mrmlnc Sep 30, 2019
57425a0
style: fix `no-unnecessary-condition` rule
mrmlnc Sep 30, 2019
16a9803
style: fix `no-explicit-any` rule
mrmlnc Sep 30, 2019
c5ac139
style: fix `prefer-includes` rule
mrmlnc Sep 30, 2019
1ce7952
style: fix `import/order` rule
mrmlnc Sep 30, 2019
b9e594c
style: fix `no-unused-expressions` rule
mrmlnc Sep 30, 2019
97bd53c
style: fix `no-useless-escape` rule
mrmlnc Sep 30, 2019
5bb3e0d
style: fix `custom-error-definition` rule
mrmlnc Sep 30, 2019
5855ce1
style: fix `padding-line-between-statements` rule
mrmlnc Sep 30, 2019
2aa6fe0
style: fix `unicorn/prefer-spread` rule
mrmlnc Sep 30, 2019
5540cfe
style: fix `import/first` rule
mrmlnc Sep 30, 2019
38aecef
style: fix `require-array-sort-compare` rule
mrmlnc Sep 30, 2019
e63b0cb
style: fix `capitalized-comments` rule
mrmlnc Sep 30, 2019
1858f51
style: fix `no-magic-numbers` rule
mrmlnc Sep 30, 2019
c06f89f
style: fix `consistent-type-definitions` rule
mrmlnc Sep 30, 2019
bfc3b67
style: fix `no-redeclare` rule
mrmlnc Oct 1, 2019
cbcabd0
style: fix `unicorn/import-index` rule
mrmlnc Oct 1, 2019
376b8fa
style(benchmark): rename `getMeasures` → `formatMeasures`
mrmlnc Oct 1, 2019
4a6c244
style: fix `consistent-type-assertions` rule
mrmlnc Oct 1, 2019
027dab5
style: fix `unicorn/prevent-abbreviations` rule
mrmlnc Oct 1, 2019
89266ef
style: fix `strict-boolean-expressions` rule
mrmlnc Oct 1, 2019
abdf027
style: fix `no-require-imports` rule
mrmlnc Oct 1, 2019
c59673d
style: fix `no-misused-promises` rule
mrmlnc Oct 1, 2019
ced18d3
build(package): bump dependencies
mrmlnc Oct 1, 2019
85cb787
refactor(benchmark): use an array directly
mrmlnc Oct 1, 2019
1e0d0c0
style: fix some style issues after review
mrmlnc Oct 2, 2019
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
3 changes: 3 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "mrmlnc"
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ npm-debug.log*
node_modules/

# Compiled and temporary files
.eslintcache
.tmp/
.benchmark/
out/
Expand Down
7 changes: 5 additions & 2 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
.gitignore
.vsts
tsconfig.json
tslint.json
.eslintrc.json

# Builded files
# Log & Cache files
.eslintcache

# Build files
out/benchmark
out/tests
out/**/*.js.map
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
"@types/sinon": "^7.0.13",
"compute-stdev": "^1.0.0",
"easy-table": "^1.1.1",
"eslint": "^6.3.0",
"eslint-config-mrmlnc": "^1.0.0",
"execa": "^1.0.0",
"fast-glob": "^3.0.2",
"glob": "^7.1.4",
Expand All @@ -43,9 +45,7 @@
"rimraf": "^2.6.3",
"sinon": "^7.3.2",
"tiny-glob": "^0.2.6",
"tslint": "^5.18.0",
"tslint-config-mrmlnc": "^2.1.0",
"typescript": "^3.5.2"
"typescript": "^3.5.3"
},
"dependencies": {
"@nodelib/fs.stat": "^2.0.1",
Expand All @@ -56,7 +56,7 @@
},
"scripts": {
"clean": "rimraf out",
"lint": "tslint \"src/**/*.ts\" -p . -t stylish",
"lint": "eslint \"src/**/*.ts\" --cache",
"compile": "tsc",
"test": "mocha \"out/**/*.spec.js\" -s 0",
"smoke": "mocha \"out/**/*.smoke.js\" -s 0",
Expand Down
8 changes: 4 additions & 4 deletions src/benchmark/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import stdev = require('compute-stdev');
import { SuiteMeasures } from './runner';

export function convertHrtimeToMilliseconds(hrtime: [number, number]): number {
const nanoseconds = (hrtime[0] * 1e9) + hrtime[1];
const nanoseconds = hrtime[0] * 1e9;

return nanoseconds / 1e6;
return (nanoseconds + hrtime[1]) / 1e6;
}

export function convertBytesToMegaBytes(bytes: number): number {
Expand Down Expand Up @@ -44,8 +44,8 @@ export function getEnvAsInteger(name: string): number | undefined {
return env ? parseInt(env, 10) : undefined;
}

export function getEnvAsObject(name: string): Object | undefined {
export function getEnvAsObject(name: string): object | undefined {
const env = process.env[name];

return env ? JSON.parse(env) as Object : undefined;
return env ? JSON.parse(env) as object : undefined;
}
8 changes: 4 additions & 4 deletions src/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { EntryItem, ErrnoException } from './types/index';
describe('Package', () => {
describe('.sync', () => {
it('should throw an error when input values can not pass validation', () => {
/* tslint:disable-next-line no-any */
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
mrmlnc marked this conversation as resolved.
Show resolved Hide resolved
assert.throws(() => pkg.sync(null as any), /TypeError: Patterns must be a string or an array of strings/);
});

Expand Down Expand Up @@ -50,7 +50,7 @@ describe('Package', () => {
describe('.async', () => {
it('should throw an error when input values can not pass validation', async () => {
try {
/* tslint:disable-next-line no-any */
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
await pkg(null as any);
throw new Error('An unexpected error was found.');
} catch (error) {
Expand Down Expand Up @@ -96,7 +96,7 @@ describe('Package', () => {

describe('.stream', () => {
it('should throw an error when input values can not pass validation', () => {
/* tslint:disable-next-line no-any */
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
assert.throws(() => pkg.stream(null as any), /TypeError: Patterns must be a string or an array of strings/);
});

Expand Down Expand Up @@ -150,7 +150,7 @@ describe('Package', () => {

describe('.generateTasks', () => {
it('should throw an error when input values can not pass validation', () => {
/* tslint:disable-next-line no-any */
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
assert.throws(() => pkg.generateTasks(null as any), /TypeError: Patterns must be a string or an array of strings/);
});

Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import Settings, { Options as OptionsInternal } from './settings';
import { Entry as EntryInternal, EntryItem, FileSystemAdapter as FileSystemAdapterInternal, Pattern as PatternInternal } from './types/index';
import * as utils from './utils/index';

type EntryObjectModePredicate = { [P in keyof Pick<OptionsInternal, 'objectMode'>]-?: true };
type EntryStatsPredicate = { [P in keyof Pick<OptionsInternal, 'stats'>]-?: true };
type EntryObjectModePredicate = { [TKey in keyof Pick<OptionsInternal, 'objectMode'>]-?: true };
type EntryStatsPredicate = { [TKey in keyof Pick<OptionsInternal, 'stats'>]-?: true };
type EntryObjectPredicate = EntryObjectModePredicate | EntryStatsPredicate;

function FastGlob(source: PatternInternal | PatternInternal[], options: OptionsInternal & EntryObjectPredicate): Promise<EntryInternal[]>;
Expand Down
2 changes: 1 addition & 1 deletion src/readers/stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default class ReaderStream extends Reader<NodeJS.ReadableStream> {

private _getStat(filepath: string): Promise<fs.Stats> {
return new Promise((resolve, reject) => {
this._stat(filepath, this._fsStatSettings, (error, stats) => {
this._stat(filepath, this._fsStatSettings, (error: NodeJS.ErrnoException | null, stats) => {
error ? reject(error) : resolve(stats);
});
});
Expand Down
2 changes: 1 addition & 1 deletion src/settings.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe('Settings', () => {
});

it('should return the `fs` option with custom method', () => {
const customReaddirSync = () => [];
const customReaddirSync = (): never[] => [];

const settings = new Settings({
fs: { readdirSync: customReaddirSync }
Expand Down
3 changes: 2 additions & 1 deletion src/tests/smoke/smoke.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ async function testCaseRunner(test: SmokeTest, func: typeof getFastGlobEntriesSy
assert.fail("This test is marked as «correct», but it doesn't have a reason.");
}

const assertAction = (test.broken || test.correct) ? assert.notDeepStrictEqual : assert.deepStrictEqual;
const isInvertedTest = test.broken || test.correct;
const assertAction = isInvertedTest ? assert.notDeepStrictEqual : assert.deepStrictEqual;

assertAction(actual, expected);
}
Expand Down
2 changes: 1 addition & 1 deletion src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ export type PatternRe = RegExp;
export type PatternsGroup = Record<string, Pattern[]>;

export interface ReaderOptions extends fsWalk.Options {
transform(entry: Entry): EntryItem;
deepFilter: DeepFilterFunction;
entryFilter: EntryFilterFunction;
errorFilter: ErrorFilterFunction;
fs: FileSystemAdapter;
stats: boolean;
transform(entry: Entry): EntryItem;
}

export type ErrorFilterFunction = fsWalk.ErrorFilterFunction;
Expand Down
5 changes: 0 additions & 5 deletions tslint.json

This file was deleted.