Skip to content

Commit

Permalink
fix: Upgrade production dependencies + babel and eslint (#197)
Browse files Browse the repository at this point in the history
* Upgrade production dependencies
* Fix flow problems
* Make dev dependencies non-exact
* Upgrade all of babel
* Upgrade eslint-based dependencies
* Run eslint autofix
* Fix remaining lint issues manually
  • Loading branch information
julienw committed Sep 18, 2020
1 parent 794fbc8 commit c13aca8
Show file tree
Hide file tree
Showing 54 changed files with 851 additions and 692 deletions.
1 change: 1 addition & 0 deletions .flowconfig
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[ignore]
.*/node_modules/fbjs/.*
.*/node_modules/yargs/.*
.*/dist/.*
.*/__tests__/fixtures/.*

Expand Down
24 changes: 14 additions & 10 deletions __tests__/integrations/cli/test-badge-reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,39 +22,43 @@ async function svg2json(filePath) {

describe('badge reporter', () => {
it('should generate red badges on project-low-coverage-with-error', async () => {
const tmpDir = tempy.directory();
const temporaryDir = tempy.directory();

const {exitCode} = await runFlowCoverageReport([
'-i', `"src/*.js"`, '-t', 'badge', '-o', tmpDir
'-i', '"src/*.js"', '-t', 'badge', '-o', temporaryDir
], {cwd: testLowCoverageDir});

// Expect flow-coverage-report to exit with 2 on low coverage.
expect(exitCode).toBe(2);

const flowBadge = await svg2json(path.join(tmpDir, 'flow-badge.svg'));
const flowCoverageBadge = await svg2json(path.join(tmpDir, 'flow-coverage-badge.svg'));
const flowBadge = await svg2json(path.join(temporaryDir, 'flow-badge.svg'));
const flowCoverageBadge = await svg2json(path.join(temporaryDir, 'flow-coverage-badge.svg'));

expect(flowBadge).toMatchSnapshot('flow-badge red');
expect(flowCoverageBadge).toMatchSnapshot('flow-coverage-badge red');

await new Promise(resolve => rimraf(path.join(tmpDir, '*.svg'), resolve));
await new Promise(resolve => {
rimraf(path.join(temporaryDir, '*.svg'), resolve);
});
});

it('should generate green badges on full covered project', async () => {
const tmpDir = tempy.directory();
const temporaryDir = tempy.directory();

const {exitCode} = await runFlowCoverageReport([
'-i', `"src/*.js"`, '-t', 'badge', '-o', tmpDir
'-i', '"src/*.js"', '-t', 'badge', '-o', temporaryDir
], {cwd: testFullCoverageDir});

expect(exitCode).toBe(0);

const flowBadge = await svg2json(path.join(tmpDir, 'flow-badge.svg'));
const flowCoverageBadge = await svg2json(path.join(tmpDir, 'flow-coverage-badge.svg'));
const flowBadge = await svg2json(path.join(temporaryDir, 'flow-badge.svg'));
const flowCoverageBadge = await svg2json(path.join(temporaryDir, 'flow-coverage-badge.svg'));

expect(flowBadge).toMatchSnapshot('flow-badge green');
expect(flowCoverageBadge).toMatchSnapshot('flow-coverage-badge green');

await new Promise(resolve => rimraf(path.join(tmpDir, '*.svg'), resolve));
await new Promise(resolve => {
rimraf(path.join(temporaryDir, '*.svg'), resolve);
});
});
});
14 changes: 9 additions & 5 deletions __tests__/integrations/cli/test-exit-value.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,29 @@ const testProjectDir = path.join(FIXTURE_PATH, 'project-low-coverage');
describe('CLI exit value', async () => {
it('should exit with code 2 when total coverage is lower than the default threshold', async () => {
const {exitCode, error} = await runFlowCoverageReport([
'-i', `"src/*.js"`
'-i', '"src/*.js"'
], {cwd: testProjectDir});

expect({exitCode, error}).toMatchSnapshot();
});

it('should exit with code 2 when total coverage is lower than the custom threshold', async () => {
const {exitCode, error} = await runFlowCoverageReport([
'-i', `"src/*.js"`,
'--threshold', '22'
'-i',
'"src/*.js"',
'--threshold',
'22'
], {cwd: testProjectDir});

expect({exitCode, error}).toMatchSnapshot();
});

it('should exit with code 0 when total coverage is higher than the custom threshold', async () => {
const {exitCode, error} = await runFlowCoverageReport([
'-i', `"src/*.js"`,
'--threshold', '10'
'-i',
'"src/*.js"',
'--threshold',
'10'
], {cwd: testProjectDir});

expect({exitCode, error}).toMatchSnapshot();
Expand Down
6 changes: 3 additions & 3 deletions __tests__/integrations/cli/test-file-special-chars-escape.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ import {

const testProjectDir = path.join(FIXTURE_PATH, 'file-special-chars-escape');

jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000; // 10 second timeout
jest.setTimeout(10000); // 10 second timeout

test('Fixed #92 - Escape special chars in filenames', async () => {
const {stdout, stderr} = await runFlowCoverageReport([
'-i', `"src/*.js"`
'-i', '"src/*.js"'
], {cwd: testProjectDir});

const filteredStdout = stdout.split('\n').filter(
line => line.indexOf('src/file-with-a') >= 0
line => line.includes('src/file-with-a')
);

expect({filteredStdout, stderr}).toMatchSnapshot();
Expand Down
8 changes: 4 additions & 4 deletions __tests__/integrations/cli/test-flow-strict.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ import {

const testProjectDir = path.join(FIXTURE_PATH, 'flow-strict');

jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000; // 10 second timeout
jest.setTimeout(10000); // 10 second timeout

test('Accept \'@flow strict\' and \'@flow strict-local\' pragmas', async () => {
const {stdout, stderr} = await runFlowCoverageReport([
'-i', `"src/*.js"`
'-i', '"src/*.js"'
], {cwd: testProjectDir});

const filteredStdoutMain = stdout.split('\n').filter(line => line.indexOf('src/main') >= 0);
const filteredStdoutLocal = stdout.split('\n').filter(line => line.indexOf('src/local') >= 0);
const filteredStdoutMain = stdout.split('\n').filter(line => line.includes('src/main'));
const filteredStdoutLocal = stdout.split('\n').filter(line => line.includes('src/local'));

expect({filteredStdoutMain, filteredStdoutLocal, stderr}).toMatchSnapshot();
});
6 changes: 3 additions & 3 deletions __tests__/integrations/cli/test-issue-135.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import {

const testProjectDir = path.join(FIXTURE_PATH, 'issue-135');

jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000; // 10 second timeout
jest.setTimeout(10000); // 10 second timeout

test('Fixed #135 - Annotation wrong on multiple pragma on the same line', async () => {
const {stdout, stderr} = await runFlowCoverageReport([
'-i', `"src/*.js"`
'-i', '"src/*.js"'
], {cwd: testProjectDir});

const filteredStdout = stdout.split('\n').filter(line => line.indexOf('src/multiple-pragmas') >= 0);
const filteredStdout = stdout.split('\n').filter(line => line.includes('src/multiple-pragmas'));

expect({filteredStdout, stderr}).toMatchSnapshot();
});
8 changes: 5 additions & 3 deletions __tests__/integrations/cli/test-percent-decimals.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ const testProjectDir = path.join(FIXTURE_PATH, 'project-decimal-coverage');
describe('--percent-decimals option', () => {
it('should round percent values using the requested precision', async () => {
const {exitCode, error, stderr, stdout} = await runFlowCoverageReport([
'--percent-decimals', '2',
'-i', '"src/**.js"'
'--percent-decimals',
'2',
'-i',
'"src/**.js"'
], {cwd: testProjectDir});

const filteredStdout = stdout.split('\n').filter(
line => line.indexOf('src/main.js') >= 0 || line.indexOf('project-decimal-coverage') >= 0);
line => line.includes('src/main.js') || line.includes('project-decimal-coverage'));

expect({exitCode, error, stderr, filteredStdout}).toMatchSnapshot();
});
Expand Down
6 changes: 3 additions & 3 deletions __tests__/integrations/cli/test-regression-issue-57.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import {

const testProjectDir = path.join(FIXTURE_PATH, 'issue-57');

jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000; // 10 second timeout
jest.setTimeout(10000); // 10 second timeout

test('Fixed #57 - NaN in text report', async () => {
const {stdout, stderr} = await runFlowCoverageReport([
'-i', `"src/*.js"`
'-i', '"src/*.js"'
], {cwd: testProjectDir});

const filteredStdout = stdout.split('\n').filter(line => line.indexOf('src/url.js') >= 0);
const filteredStdout = stdout.split('\n').filter(line => line.includes('src/url.js'));

expect({filteredStdout, stderr}).toMatchSnapshot();
});
2 changes: 1 addition & 1 deletion bin/flow-coverage-report.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env node
const path = require('path');

require(path.join(__dirname, '../dist/lib/cli')).run(); // eslint-disable-line import/no-dynamic-require
require(path.join(__dirname, '../dist/lib/cli')).run();
87 changes: 87 additions & 0 deletions flow-typed/npm/glob_v7.1.x.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
// flow-typed signature: 257135a98dbce29a68026e7b9b7f381d
// flow-typed version: c6154227d1/glob_v7.1.x/flow_>=v0.42.x <=v0.103.x

declare module "glob" {
declare type MinimatchOptions = {|
debug?: boolean,
nobrace?: boolean,
noglobstar?: boolean,
dot?: boolean,
noext?: boolean,
nocase?: boolean,
nonull?: boolean,
matchBase?: boolean,
nocomment?: boolean,
nonegate?: boolean,
flipNegate?: boolean
|};

declare type Options = {|
...MinimatchOptions,
cwd?: string,
root?: string,
nomount?: boolean,
mark?: boolean,
nosort?: boolean,
stat?: boolean,
silent?: boolean,
strict?: boolean,
cache?: {
[path: string]: boolean | "DIR" | "FILE" | $ReadOnlyArray<string>
},
statCache?: {
[path: string]: boolean | { isDirectory(): boolean } | void
},
symlinks?: { [path: string]: boolean | void },
realpathCache?: { [path: string]: string },
sync?: boolean,
nounique?: boolean,
nodir?: boolean,
ignore?: string | $ReadOnlyArray<string>,
follow?: boolean,
realpath?: boolean,
absolute?: boolean
|};

/**
* Called when an error occurs, or matches are found
* err
* matches: filenames found matching the pattern
*/
declare type CallBack = (err: ?Error, matches: Array<string>) => void;

declare class Glob extends events$EventEmitter {
constructor(pattern: string): this;
constructor(pattern: string, callback: CallBack): this;
constructor(pattern: string, options: Options, callback: CallBack): this;

minimatch: {};
options: Options;
aborted: boolean;
cache: {
[path: string]: boolean | "DIR" | "FILE" | $ReadOnlyArray<string>
};
statCache: {
[path: string]: boolean | { isDirectory(): boolean } | void
};
symlinks: { [path: string]: boolean | void };
realpathCache: { [path: string]: string };
found: Array<string>;

pause(): void;
resume(): void;
abort(): void;
}

declare class GlobModule {
Glob: Class<Glob>;

(pattern: string, callback: CallBack): void;
(pattern: string, options: Options, callback: CallBack): void;

hasMagic(pattern: string, options?: Options): boolean;
sync(pattern: string, options?: Options): Array<string>;
}

declare module.exports: GlobModule;
}
4 changes: 2 additions & 2 deletions flow-typed/npm/minimatch_v3.x.x.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// flow-typed signature: bc0af4a44bb8631039f713b1afba6988
// flow-typed version: d42cbef63c/minimatch_v3.x.x/flow_>=v0.25.x
// flow-typed signature: 372b91a58c99da7bdf7640dc9aa42756
// flow-typed version: c6154227d1/minimatch_v3.x.x/flow_>=v0.25.x <=v0.103.x

type $npm$minimatch$Options = {
debug?: boolean,
Expand Down
File renamed without changes.
Loading

0 comments on commit c13aca8

Please sign in to comment.