Skip to content

Commit e043113

Browse files
anilreddykattaaaronabramov
authored andcommitted
Continuation to jestjs#3771 for snake case file naming (jestjs#3920)
* Resolved conflicts * Including eslint file for forcing file names * renaming files * renaming files
1 parent eb9be5a commit e043113

File tree

116 files changed

+248
-212
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

116 files changed

+248
-212
lines changed

.eslintrc.js

+19-9
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
module.exports = {
1010
extends: [
1111
'./packages/eslint-config-fb-strict/index.js',
12-
'plugin:import/errors',
12+
'plugin:import/errors'
1313
],
1414
parser: 'babel-eslint',
1515
rules: {
@@ -20,15 +20,16 @@ module.exports = {
2020
'max-len': 0,
2121
'no-multiple-empty-lines': 1,
2222
'import/no-duplicates': 2,
23-
'import/no-unresolved': [2, { ignore: ['^types/'] }],
23+
'import/no-unresolved': [2, {ignore: ['^types/']}],
2424
// This has to be disabled until all type and module imports are combined
2525
// https://github.com/benmosher/eslint-plugin-import/issues/645
2626
'import/order': 0,
2727
// These has to be disabled until the whole code base is converted to ESM
2828
'import/default': 0,
2929
'import/named': 0,
30+
'unicorn/filename-case': [2, {case: 'snakeCase'}]
3031
},
31-
plugins: ['markdown', 'import'],
32+
plugins: ['markdown', 'import', 'unicorn'],
3233
overrides: [
3334
// to make it more suitable for running on code examples in docs/ folder
3435
{
@@ -43,22 +44,31 @@ module.exports = {
4344
'no-unused-vars': 0,
4445
'consistent-return': 0,
4546
'import/no-unresolved': 0,
46-
'sort-keys': 0
47-
},
47+
'sort-keys': 0,
48+
'unicorn/filename-case': 0
49+
}
4850
},
4951
{
5052
files: ['examples/**/*'],
5153
rules: {
5254
'babel/func-params-comma-dangle': 0,
5355
'import/order': 0,
54-
'import/no-unresolved': [2, { 'ignore': ['^react-native$'] }]
55-
},
56+
'import/no-unresolved': [2, {ignore: ['^react-native$']}],
57+
'unicorn/filename-case': 0
58+
}
5659
},
5760
{
5861
files: ['scripts/**/*', 'integration_tests/**/*'],
5962
rules: {
6063
'babel/func-params-comma-dangle': 0,
61-
},
64+
'unicorn/filename-case': 0
65+
}
6266
},
63-
],
67+
{
68+
files: ['**/__mocks__/**/*', 'website/**/*', '**/jest-runtime/**/*', '**/src/Console*'],
69+
rules: {
70+
'unicorn/filename-case': 0
71+
}
72+
}
73+
]
6474
};

examples/react-native/.flowconfig

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ experimental.strict_type_args=true
2626

2727
munge_underscores=true
2828

29-
module.name_mapper='^image![a-zA-Z0-9$_-]+$' -> 'GlobalImageStub'
29+
module.name_mapper='^image![a-zA-Z0-9$_-]+$' -> 'global_image_stub'
3030
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'
3131

3232
suppress_type=$FlowIssue
File renamed without changes.

package.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"eslint-plugin-import": "^2.6.0",
2929
"eslint-plugin-markdown": "^1.0.0-beta.6",
3030
"eslint-plugin-react": "^7.1.0",
31+
"eslint-plugin-unicorn": "^2.1.2",
3132
"flow-bin": "^0.48.0",
3233
"glob": "^7.1.1",
3334
"graceful-fs": "^4.1.11",
@@ -114,7 +115,7 @@
114115
"transform": {
115116
"^.+\\.js$": "<rootDir>/packages/babel-jest"
116117
},
117-
"setupTestFrameworkScriptFile": "<rootDir>/testSetupFile.js",
118+
"setupTestFrameworkScriptFile": "<rootDir>/test_setup_file.js",
118119
"snapshotSerializers": [
119120
"<rootDir>/packages/pretty-format/build/plugins/convert_ansi.js"
120121
],
@@ -130,5 +131,6 @@
130131
"testMatch": [
131132
"**/*.test.js"
132133
]
133-
}
134+
},
135+
"dependencies": {}
134136
}

packages/jest-cli/src/__tests__/generate_empty_coverage.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
const os = require('os');
1313

14-
const generateEmptyCoverage = require('../generateEmptyCoverage');
14+
const generateEmptyCoverage = require('../generate_empty_coverage');
1515

1616
jest.mock('jest-runtime', () => {
1717
const realRuntime = require.requireActual('jest-runtime');

packages/jest-cli/src/__tests__/search_source.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ describe('SearchSource', () => {
3434

3535
beforeEach(() => {
3636
Runtime = require('jest-runtime');
37-
SearchSource = require('../SearchSource');
37+
SearchSource = require('../search_source');
3838
normalize = require('jest-config').normalize;
3939
});
4040

@@ -415,7 +415,7 @@ describe('SearchSource', () => {
415415
});
416416

417417
it('returns empty search result if no related tests were found', () => {
418-
const input = ['no tests.js'];
418+
const input = ['no_tests.js'];
419419
const data = searchSource.findRelatedTestsFromPattern(input);
420420
expect(data.tests).toEqual([]);
421421
});

packages/jest-cli/src/__tests__/test_runner.test.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010

1111
'use strict';
1212

13-
const TestRunner = require('../TestRunner');
14-
const TestWatcher = require('../TestWatcher');
15-
const SummaryReporter = require('../reporters/SummaryReporter');
13+
const TestRunner = require('../test_runner');
14+
const TestWatcher = require('../test_watcher');
15+
const SummaryReporter = require('../reporters/summary_reporter');
1616

1717
let workerFarmMock;
1818

@@ -27,8 +27,8 @@ jest.mock('worker-farm', () => {
2727
return mock;
2828
});
2929

30-
jest.mock('../TestWorker', () => {});
31-
jest.mock('../reporters/DefaultReporter');
30+
jest.mock('../test_worker', () => {});
31+
jest.mock('../reporters/default_reporter');
3232

3333
test('.addReporter() .removeReporter()', () => {
3434
const runner = new TestRunner({}, {});

packages/jest-cli/src/__tests__/test_sequencer.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jest.mock('fs');
1212
const fs = require('fs');
1313
const path = require('path');
1414

15-
const TestSequencer = require('../TestSequencer');
15+
const TestSequencer = require('../test_sequencer');
1616

1717
const FAIL = 0;
1818
const SUCCESS = 1;

packages/jest-cli/src/__tests__/watch.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111
'use strict';
1212

1313
const chalk = require('chalk');
14-
const TestWatcher = require('../TestWatcher');
14+
const TestWatcher = require('../test_watcher');
1515
const {KEYS} = require('../constants');
1616

1717
const runJestMock = jest.fn();
1818

1919
jest.doMock('chalk', () => new chalk.constructor({enabled: false}));
2020
jest.doMock(
21-
'../runJest',
21+
'../run_jest',
2222
() =>
2323
function() {
2424
const args = Array.from(arguments);

packages/jest-cli/src/__tests__/watch_filename_pattern_mode.test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jest.mock('ansi-escapes', () => ({
2828
}));
2929

3030
jest.mock(
31-
'../SearchSource',
31+
'../search_source',
3232
() =>
3333
class {
3434
constructor(context) {
@@ -68,7 +68,7 @@ jest.doMock('chalk', () =>
6868
);
6969

7070
jest.doMock(
71-
'../runJest',
71+
'../run_jest',
7272
() =>
7373
function() {
7474
const args = Array.from(arguments);
@@ -81,7 +81,7 @@ jest.doMock(
8181
},
8282
);
8383

84-
jest.doMock('../lib/terminalUtils', () => ({
84+
jest.doMock('../lib/terminal_utils', () => ({
8585
getTerminalWidth: () => terminalWidth,
8686
}));
8787

packages/jest-cli/src/__tests__/watch_test_name_pattern_mode.test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jest.mock('ansi-escapes', () => ({
2828
}));
2929

3030
jest.mock(
31-
'../SearchSource',
31+
'../search_source',
3232
() =>
3333
class {
3434
findMatchingTests(pattern) {
@@ -44,7 +44,7 @@ jest.doMock('chalk', () =>
4444
);
4545

4646
jest.doMock(
47-
'../runJest',
47+
'../run_jest',
4848
() =>
4949
function() {
5050
const args = Array.from(arguments);
@@ -95,7 +95,7 @@ jest.doMock(
9595
},
9696
);
9797

98-
jest.doMock('../lib/terminalUtils', () => ({
98+
jest.doMock('../lib/terminal_utils', () => ({
9999
getTerminalWidth: () => terminalWidth,
100100
}));
101101

packages/jest-cli/src/cli/index.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ import {readConfig} from 'jest-config';
2222
import {version as VERSION} from '../../package.json';
2323
import args from './args';
2424
import chalk from 'chalk';
25-
import createContext from '../lib/createContext';
26-
import getJest from './getJest';
27-
import getMaxWorkers from '../lib/getMaxWorkers';
28-
import handleDeprecationWarnings from '../lib/handleDeprecationWarnings';
29-
import logDebugMessages from '../lib/logDebugMessages';
30-
import preRunMessage from '../preRunMessage';
31-
import runJest from '../runJest';
25+
import createContext from '../lib/create_context';
26+
import getJest from './get_jest';
27+
import getMaxWorkers from '../lib/get_max_workers';
28+
import handleDeprecationWarnings from '../lib/handle_deprecation_warnings';
29+
import logDebugMessages from '../lib/log_debug_messages';
30+
import preRunMessage from '../pre_run_message';
31+
import runJest from '../run_jest';
3232
import Runtime from 'jest-runtime';
33-
import TestWatcher from '../TestWatcher';
33+
import TestWatcher from '../test_watcher';
3434
import watch from '../watch';
3535
import yargs from 'yargs';
3636

packages/jest-cli/src/jest.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010

1111
import {version as VERSION} from '../package.json';
1212

13-
import SearchSource from './SearchSource';
14-
import TestRunner from './TestRunner';
15-
import TestWatcher from './TestWatcher';
13+
import SearchSource from './search_source';
14+
import TestRunner from './test_runner';
15+
import TestWatcher from './test_watcher';
1616
import {run, runCLI} from './cli';
1717

1818
module.exports = {

packages/jest-cli/src/lib/__tests__/format_test_name_by_pattern.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
'use strict';
1212

13-
const formatTestNameByPattern = require('../formatTestNameByPattern');
13+
const formatTestNameByPattern = require('../format_test_name_by_pattern');
1414

1515
describe('for multiline test name returns', () => {
1616
const testNames = [

packages/jest-cli/src/lib/__tests__/get_max_workers.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* @emails oncall+jsinfra
99
*/
1010

11-
const getMaxWorkers = require('../getMaxWorkers');
11+
const getMaxWorkers = require('../get_max_workers');
1212

1313
jest.mock('os', () => ({
1414
cpus: () => ({length: 4}),

packages/jest-cli/src/lib/__tests__/is_valid_path.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*/
1010

1111
const path = require('path');
12-
const isValidPath = require('../isValidPath');
12+
const isValidPath = require('../is_valid_path');
1313

1414
const rootDir = path.resolve(path.sep, 'root');
1515

packages/jest-cli/src/lib/__tests__/log_debug_messages.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
'use strict';
1212

13-
const logDebugMessages = require('../logDebugMessages');
13+
const logDebugMessages = require('../log_debug_messages');
1414

1515
jest.mock('../../../package.json', () => ({version: 123}));
1616

packages/jest-cli/src/lib/__tests__/prompt.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*/
1010
'use strict';
1111

12-
const Prompt = require('../Prompt');
12+
const Prompt = require('../prompt');
1313
let {KEYS} = require('../../constants');
1414

1515
KEYS = Object.assign({}, KEYS, {

packages/jest-cli/src/lib/__tests__/scroll_list.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const scroll = require('../scrollList');
1+
const scroll = require('../scroll_list');
22

33
it('When offset is -1', () => {
44
expect(scroll(25, {max: 10, offset: -1})).toEqual({

packages/jest-cli/src/lib/__tests__/validate_pattern.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*/
1010
'use strict';
1111

12-
const validatePattern = require('../validatePattern');
12+
const validatePattern = require('../validate_pattern');
1313

1414
describe('validate pattern function', () => {
1515
it('without passed args returns true', () => {

packages/jest-cli/src/lib/getTestPathPattern.js renamed to packages/jest-cli/src/lib/get_test_path_pattern.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
*/
1010

1111
import type {Argv} from 'types/Argv';
12-
import type {TestSelectionConfig} from '../SearchSource';
12+
import type {TestSelectionConfig} from '../search_source';
1313

1414
import {clearLine} from 'jest-util';
1515
import chalk from 'chalk';
16-
import validatePattern from './validatePattern';
16+
import validatePattern from './validate_pattern';
1717

1818
const DEFAULT_PATTERN_INFO = {
1919
input: '',

packages/jest-cli/src/lib/patternModeHelpers.js renamed to packages/jest-cli/src/lib/pattern_mode_helpers.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import chalk from 'chalk';
1414
import ansiEscapes from 'ansi-escapes';
1515
import stringLength from 'string-length';
16-
import Prompt from './Prompt';
16+
import Prompt from './prompt';
1717

1818
const pluralize = (count: number, text: string) =>
1919
count === 1 ? text : text + 's';

packages/jest-cli/src/lib/Prompt.js renamed to packages/jest-cli/src/lib/prompt.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* @flow
99
*/
1010

11-
import type {ScrollOptions} from './scrollList';
11+
import type {ScrollOptions} from './scroll_list';
1212

1313
import {KEYS} from '../constants';
1414

packages/jest-cli/src/lib/updateArgv.js renamed to packages/jest-cli/src/lib/update_argv.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
import type {Argv} from 'types/Argv';
1212

13-
import getTestPathPattern from './getTestPathPattern';
13+
import getTestPathPattern from './get_test_path_pattern';
1414

1515
type Options = {|
1616
testNamePattern?: string,

packages/jest-cli/src/PatternPrompt.js renamed to packages/jest-cli/src/pattern_prompt.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010

1111
'use strict';
1212

13-
import type {ScrollOptions} from './lib/scrollList';
13+
import type {ScrollOptions} from './lib/scroll_list';
1414

1515
import chalk from 'chalk';
1616
import ansiEscapes from 'ansi-escapes';
17-
import Prompt from './lib/Prompt';
17+
import Prompt from './lib/prompt';
1818

1919
const usage = (entity: string) =>
2020
`\n${chalk.bold('Pattern Mode Usage')}\n` +

packages/jest-cli/src/reporters/__tests__/coverage_reporter.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ beforeEach(() => {
2525
write: jest.fn(),
2626
}));
2727

28-
CoverageReporter = require('../CoverageReporter');
28+
CoverageReporter = require('../coverage_reporter');
2929
libCoverage = require('istanbul-lib-coverage');
3030
libSourceMaps = require('istanbul-lib-source-maps');
3131
});

0 commit comments

Comments
 (0)