Skip to content

Commit

Permalink
chore: sort imports alphabetically (#10757)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB authored Oct 31, 2020
1 parent 95169d3 commit f9132f9
Show file tree
Hide file tree
Showing 310 changed files with 602 additions and 663 deletions.
35 changes: 34 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@
* LICENSE file in the root directory of this source tree.
*/

const {sync: readPkg} = require('read-pkg');
const {getPackages} = require('./scripts/buildUtils');

const internalPackages = getPackages()
.map(packageDir => {
const pkg = readPkg({cwd: packageDir});

return pkg.name;
})
.sort();

module.exports = {
extends: [
'fb-strict',
Expand Down Expand Up @@ -243,11 +254,29 @@ module.exports = {
'scripts/**',
'babel.config.js',
'testSetupFile.js',
'.eslintrc.js',
],
},
],
'import/no-unresolved': ['error', {ignore: ['fsevents']}],
'import/order': 'error',
'import/order': [
'error',
{
alphabetize: {
order: 'asc',
},
// this is the default order except for added `internal` in the middle
groups: [
'builtin',
'external',
'internal',
'parent',
'sibling',
'index',
],
'newlines-between': 'never',
},
],
'no-console': 'off',
'no-restricted-imports': [
'error',
Expand All @@ -262,5 +291,9 @@ module.exports = {
},
settings: {
'import/ignore': ['react-native'],
// using `new RegExp` makes sure to escape `/`
'import/internal-regex': new RegExp(
internalPackages.map(pkg => `^${pkg}$`).join('|'),
).source,
},
};
1 change: 0 additions & 1 deletion docs/BypassingModuleMocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ Your test will want to mock the `fetch` function so that we can be sure that it
jest.mock('node-fetch');

import fetch, {Response} from 'node-fetch';

import {createUser} from './createUser';

test('createUser calls fetch with the right args and returns the user id', async () => {
Expand Down
2 changes: 1 addition & 1 deletion docs/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,8 @@ Default: `undefined`
This option allows the use of a custom dependency extractor. It must be a node module that exports an object with an `extract` function. E.g.:

```javascript
const fs = require('fs');
const crypto = require('crypto');
const fs = require('fs');

module.exports = {
extract(code, filePath, defaultExtract) {
Expand Down
2 changes: 1 addition & 1 deletion docs/Es6ClassMocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,8 @@ Here's a complete test file which uses the module factory parameter to `jest.moc

```javascript
// sound-player-consumer.test.js
import SoundPlayerConsumer from './sound-player-consumer';
import SoundPlayer from './sound-player';
import SoundPlayerConsumer from './sound-player-consumer';

const mockPlaySoundFile = jest.fn();
jest.mock('./sound-player', () => {
Expand Down
3 changes: 1 addition & 2 deletions docs/JestObjectAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,7 @@ module.exports = audio;
Example test:

```js
const audio = require('./audio');
const video = require('./video');

test('plays video', () => {
Expand All @@ -550,8 +551,6 @@ test('plays video', () => {
spy.mockRestore();
});

const audio = require('./audio');

test('plays audio', () => {
const spy = jest.spyOn(audio, 'volume', 'set'); // we pass 'set'
audio.volume = 100;
Expand Down
4 changes: 2 additions & 2 deletions docs/Puppeteer.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ Here's an example of the GlobalSetup script

```js
// setup.js
const path = require('path');
const fs = require('fs');
const os = require('os');
const path = require('path');
const mkdirp = require('mkdirp');
const puppeteer = require('puppeteer');

Expand All @@ -80,8 +80,8 @@ Then we need a custom Test Environment for puppeteer
```js
// puppeteer_environment.js
const fs = require('fs');
const path = require('path');
const os = require('os');
const path = require('path');
const puppeteer = require('puppeteer');
const NodeEnvironment = require('jest-environment-node');

Expand Down
8 changes: 4 additions & 4 deletions e2e/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
*/

import * as path from 'path';
import * as fs from 'graceful-fs';
import type {Config} from '@jest/types';
import dedent = require('dedent');
import {ExecaReturnValue, sync as spawnSync} from 'execa';
import type {PackageJson} from 'type-fest';
import * as fs from 'graceful-fs';
import rimraf = require('rimraf');
import dedent = require('dedent');
import type {PackageJson} from 'type-fest';
import which = require('which');
import type {Config} from '@jest/types';

interface RunResult extends ExecaReturnValue {
status: number;
Expand Down
4 changes: 2 additions & 2 deletions e2e/__tests__/asyncAndCallback.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
* LICENSE file in the root directory of this source tree.
*/

import {skipSuiteOnJasmine} from '@jest/test-utils';
import wrap from 'jest-snapshot-serializer-raw';
import runJest from '../runJest';
import {skipSuiteOnJasmine} from '@jest/test-utils';
import {extractSummary} from '../Utils';
import runJest from '../runJest';

skipSuiteOnJasmine();

Expand Down
2 changes: 1 addition & 1 deletion e2e/__tests__/babelPluginJestHoist.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
*/

import * as path from 'path';
import {json as runWithJson} from '../runJest';
import {runYarn} from '../Utils';
import {json as runWithJson} from '../runJest';

const DIR = path.resolve(__dirname, '..', 'babel-plugin-jest-hoist');

Expand Down
2 changes: 1 addition & 1 deletion e2e/__tests__/beforeEachQueue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/

import {skipSuiteOnJestCircus} from '@jest/test-utils';
import {wrap} from 'jest-snapshot-serializer-raw';
import {skipSuiteOnJestCircus} from '@jest/test-utils';
import runJest from '../runJest';

skipSuiteOnJestCircus(); // Circus does not support funky async definitions
Expand Down
2 changes: 1 addition & 1 deletion e2e/__tests__/chaiAssertionLibrary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

import * as path from 'path';
import {wrap} from 'jest-snapshot-serializer-raw';
import runJest from '../runJest';
import {extractSummary, runYarn} from '../Utils';
import runJest from '../runJest';

test('chai assertion errors should display properly', () => {
const dir = path.resolve(__dirname, '../chai-assertion-library-errors');
Expand Down
2 changes: 1 addition & 1 deletion e2e/__tests__/circusDeclarationErrors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/

import {skipSuiteOnJasmine} from '@jest/test-utils';
import {wrap} from 'jest-snapshot-serializer-raw';
import {skipSuiteOnJasmine} from '@jest/test-utils';
import {extractSummary} from '../Utils';
import runJest from '../runJest';

Expand Down
2 changes: 1 addition & 1 deletion e2e/__tests__/customMatcherStackTrace.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
*/

import {wrap} from 'jest-snapshot-serializer-raw';
import runJest from '../runJest';
import {extractSummary} from '../Utils';
import runJest from '../runJest';

test('works with custom matchers', () => {
const {stderr} = runJest('custom-matcher-stack-trace', ['sync.test.js']);
Expand Down
2 changes: 1 addition & 1 deletion e2e/__tests__/customReporters.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import {tmpdir} from 'os';
import * as path from 'path';
import {wrap} from 'jest-snapshot-serializer-raw';
import runJest from '../runJest';
import {cleanup, extractSummary, writeFiles} from '../Utils';
import runJest from '../runJest';

const DIR = path.resolve(tmpdir(), 'custom-reporters-test-dir');

Expand Down
2 changes: 1 addition & 1 deletion e2e/__tests__/customTestSequencers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
*/

import * as path from 'path';
import runJest from '../runJest';
import {extractSummary} from '../Utils';
import runJest from '../runJest';
const dir = path.resolve(__dirname, '../custom-test-sequencer');

test('run prioritySequence first sync', () => {
Expand Down
2 changes: 1 addition & 1 deletion e2e/__tests__/dependencyClash.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/

import * as path from 'path';
import {tmpdir} from 'os';
import * as path from 'path';
import {cleanup, createEmptyPackage, writeFiles} from '../Utils';
import runJest from '../runJest';

Expand Down
2 changes: 1 addition & 1 deletion e2e/__tests__/domDiffing.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
*
*/

import runJest from '../runJest';
import {replaceTime} from '../Utils';
import runJest from '../runJest';

test('should work without error', () => {
const output = runJest('dom-diffing');
Expand Down
2 changes: 1 addition & 1 deletion e2e/__tests__/each.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

import * as path from 'path';
import {wrap} from 'jest-snapshot-serializer-raw';
import runJest from '../runJest';
import {extractSummary} from '../Utils';
import runJest from '../runJest';

const dir = path.resolve(__dirname, '../each');

Expand Down
2 changes: 1 addition & 1 deletion e2e/__tests__/emptyDescribeWithHooks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

import * as path from 'path';
import {skipSuiteOnJasmine} from '@jest/test-utils';
import runJest from '../runJest';
import {extractSummary} from '../Utils';
import runJest from '../runJest';

const dir = path.resolve(__dirname, '../empty-describe-with-hooks');

Expand Down
2 changes: 1 addition & 1 deletion e2e/__tests__/errorOnDeprecated.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

import {wrap} from 'jest-snapshot-serializer-raw';
import {skipSuiteOnJestCircus} from '@jest/test-utils';
import runJest from '../runJest';
import {extractSummary} from '../Utils';
import runJest from '../runJest';

skipSuiteOnJestCircus();

Expand Down
2 changes: 1 addition & 1 deletion e2e/__tests__/existentRoots.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/

import * as path from 'path';
import {tmpdir} from 'os';
import * as path from 'path';
import {tryRealpath} from 'jest-util';
import {cleanup, writeFiles} from '../Utils';
import runJest from '../runJest';
Expand Down
2 changes: 1 addition & 1 deletion e2e/__tests__/expectAsyncMatcher.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

import * as path from 'path';
import {wrap} from 'jest-snapshot-serializer-raw';
import runJest from '../runJest';
import {extractSummary, runYarn} from '../Utils';
import runJest from '../runJest';

const dir = path.resolve(__dirname, '../expect-async-matcher');

Expand Down
2 changes: 1 addition & 1 deletion e2e/__tests__/fatalWorkerError.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/

import * as path from 'path';
import {tmpdir} from 'os';
import * as path from 'path';
import {
cleanup,
generateTestFilesToForceUsingWorkers,
Expand Down
2 changes: 1 addition & 1 deletion e2e/__tests__/forceExit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

import {tmpdir} from 'os';
import * as path from 'path';
import runJest from '../runJest';
import {cleanup, writeFiles} from '../Utils';
import runJest from '../runJest';

const DIR = path.resolve(tmpdir(), 'force-exit-test');

Expand Down
2 changes: 1 addition & 1 deletion e2e/__tests__/globalSetup.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import {tmpdir} from 'os';
import * as path from 'path';
import * as fs from 'graceful-fs';
import runJest, {json as runWithJson} from '../runJest';
import {cleanup, runYarn} from '../Utils';
import runJest, {json as runWithJson} from '../runJest';

const DIR = path.join(tmpdir(), 'jest-global-setup');
const project1DIR = path.join(tmpdir(), 'jest-global-setup-project-1');
Expand Down
2 changes: 1 addition & 1 deletion e2e/__tests__/globalTeardown.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import {tmpdir} from 'os';
import * as path from 'path';
import * as fs from 'graceful-fs';
import {createDirectory} from 'jest-util';
import runJest, {json as runWithJson} from '../runJest';
import {cleanup, runYarn} from '../Utils';
import runJest, {json as runWithJson} from '../runJest';

const DIR = path.join(tmpdir(), 'jest-global-teardown');
const project1DIR = path.join(tmpdir(), 'jest-global-teardown-project-1');
Expand Down
4 changes: 2 additions & 2 deletions e2e/__tests__/globals.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
* LICENSE file in the root directory of this source tree.
*/

import * as path from 'path';
import {tmpdir} from 'os';
import * as path from 'path';
import {wrap} from 'jest-snapshot-serializer-raw';
import runJest from '../runJest';
import {
cleanup,
createEmptyPackage,
extractSummary,
writeFiles,
} from '../Utils';
import runJest from '../runJest';

const DIR = path.resolve(tmpdir(), 'globalVariables.test');
const TEST_DIR = path.resolve(DIR, '__tests__');
Expand Down
4 changes: 2 additions & 2 deletions e2e/__tests__/injectGlobals.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
* LICENSE file in the root directory of this source tree.
*/

import * as path from 'path';
import {tmpdir} from 'os';
import * as path from 'path';
import {wrap} from 'jest-snapshot-serializer-raw';
import {skipSuiteOnJasmine} from '@jest/test-utils';
import {json as runJest} from '../runJest';
import {
cleanup,
createEmptyPackage,
extractSummary,
writeFiles,
} from '../Utils';
import {json as runJest} from '../runJest';

const DIR = path.resolve(tmpdir(), 'injectGlobalVariables.test');
const TEST_DIR = path.resolve(DIR, '__tests__');
Expand Down
2 changes: 1 addition & 1 deletion e2e/__tests__/jest.config.js.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

import * as path from 'path';
import {wrap} from 'jest-snapshot-serializer-raw';
import runJest from '../runJest';
import {cleanup, extractSummary, writeFiles} from '../Utils';
import runJest from '../runJest';

const DIR = path.resolve(__dirname, '../jest-config-js');

Expand Down
2 changes: 1 addition & 1 deletion e2e/__tests__/jest.config.ts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

import * as path from 'path';
import {wrap} from 'jest-snapshot-serializer-raw';
import runJest from '../runJest';
import {cleanup, extractSummary, writeFiles} from '../Utils';
import runJest from '../runJest';

const DIR = path.resolve(__dirname, '../jest-config-ts');

Expand Down
Loading

0 comments on commit f9132f9

Please sign in to comment.