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

chore: fix some ban-types violations #10510

Merged
merged 7 commits into from
Sep 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
94 changes: 42 additions & 52 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ module.exports = {
'@typescript-eslint/prefer-ts-expect-error': 'error',
// Since we do `export =`. Remove for Jest 27
'import/default': 'off',
'import/order': 'error',
'no-dupe-class-members': 'off',
'no-unused-vars': 'off',
// TODO: turn these on at some point
Expand All @@ -42,7 +41,6 @@ module.exports = {
files: [
'e2e/babel-plugin-jest-hoist/__tests__/typescript.test.ts',
'e2e/coverage-remapping/covered.ts',
'packages/expect/src/jestMatchersObject.ts',
'packages/expect/src/matchers.ts',
'packages/expect/src/print.ts',
'packages/expect/src/toThrowMatchers.ts',
Expand All @@ -52,25 +50,19 @@ module.exports = {
'packages/jest-core/src/TestScheduler.ts',
'packages/jest-core/src/collectHandles.ts',
'packages/jest-core/src/plugins/update_snapshots_interactive.ts',
'packages/jest-environment/src/index.ts',
'packages/jest-fake-timers/src/legacyFakeTimers.ts',
'packages/jest-haste-map/src/index.ts',
'packages/jest-haste-map/src/lib/FSEventsWatcher.ts',
'packages/jest-jasmine2/src/errorOnPrivate.ts',
'packages/jest-jasmine2/src/jasmine/SpyStrategy.ts',
'packages/jest-jasmine2/src/jasmine/Suite.ts',
'packages/jest-leak-detector/src/index.ts',
'packages/jest-matcher-utils/src/index.ts',
'packages/jest-mock/src/__tests__/index.test.ts',
'packages/jest-mock/src/index.ts',
'packages/jest-resolve/src/isBuiltinModule.ts',
'packages/jest-snapshot/src/index.ts',
'packages/jest-snapshot/src/printSnapshot.ts',
'packages/jest-snapshot/src/types.ts',
'packages/jest-types/src/Global.ts',
'packages/jest-util/src/ErrorWithStack.ts',
'packages/jest-util/src/convertDescriptorToString.ts',
'packages/jest-validate/src/types.ts',
'packages/jest-worker/src/Farm.ts',
'packages/jest-worker/src/index.ts',
'packages/pretty-format/src/index.ts',
Expand Down Expand Up @@ -102,46 +94,46 @@ module.exports = {
{
files: ['*.md'],
rules: {
'arrow-body-style': 0,
'consistent-return': 0,
'flowtype/require-valid-file-annotation': 0,
'import/no-extraneous-dependencies': 0,
'import/no-unresolved': 0,
'jest/no-focused-tests': 0,
'jest/no-identical-title': 0,
'jest/valid-expect': 0,
'no-undef': 0,
'no-unused-vars': 0,
'prettier/prettier': 0,
'react/jsx-no-undef': 0,
'react/react-in-jsx-scope': 0,
'sort-keys': 0,
'arrow-body-style': 'off',
'consistent-return': 'off',
'flowtype/require-valid-file-annotation': 'off',
'import/no-extraneous-dependencies': 'off',
'import/no-unresolved': 'off',
'jest/no-focused-tests': 'off',
'jest/no-identical-title': 'off',
'jest/valid-expect': 'off',
'no-undef': 'off',
'no-unused-vars': 'off',
'prettier/prettier': 'off',
'react/jsx-no-undef': 'off',
'react/react-in-jsx-scope': 'off',
'sort-keys': 'off',
},
},
{
files: ['examples/**/*'],
rules: {
'babel/func-params-comma-dangle': 0,
'import/no-unresolved': [2, {ignore: ['^react-native$']}],
'import/order': 0,
'babel/func-params-comma-dangle': 'off',
'import/no-unresolved': ['error', {ignore: ['^react-native$']}],
'import/order': 'off',
},
},
{
files: ['scripts/**/*', 'e2e/**/*'],
rules: {
'babel/func-params-comma-dangle': 0,
'babel/func-params-comma-dangle': 'off',
},
},
{
files: 'packages/jest-types/**/*',
rules: {
'import/no-extraneous-dependencies': 0,
'import/no-extraneous-dependencies': 'off',
},
},
{
files: 'packages/**/*.ts',
rules: {
'@typescript-eslint/explicit-module-boundary-types': 2,
'@typescript-eslint/explicit-module-boundary-types': 'error',
},
},
{
Expand All @@ -153,7 +145,7 @@ module.exports = {
'**/vendor/**/*',
],
rules: {
'@typescript-eslint/explicit-module-boundary-types': 0,
'@typescript-eslint/explicit-module-boundary-types': 'off',
},
},
{
Expand All @@ -163,8 +155,8 @@ module.exports = {
'**/vendor/**/*',
],
rules: {
'eslint-comments/disable-enable-pair': 0,
'eslint-comments/no-unlimited-disable': 0,
'eslint-comments/disable-enable-pair': 'off',
'eslint-comments/no-unlimited-disable': 'off',
},
},
{
Expand All @@ -186,30 +178,30 @@ module.exports = {
'**/pretty-format/perf/**',
],
rules: {
'import/no-extraneous-dependencies': 0,
'import/no-extraneous-dependencies': 'off',
},
},
{
files: ['test-types/*.test.ts'],
rules: {
'jest/no-focused-tests': 0,
'jest/no-identical-title': 0,
'jest/valid-expect': 0,
'jest/no-focused-tests': 'off',
'jest/no-identical-title': 'off',
'jest/valid-expect': 'off',
},
},
],
parser: 'babel-eslint',
plugins: ['markdown', 'import', 'prettier', 'eslint-comments'],
rules: {
'arrow-body-style': 2,
'eslint-comments/disable-enable-pair': [2, {allowWholeFile: true}],
'eslint-comments/no-unused-disable': 2,
'flowtype/boolean-style': 2,
'flowtype/no-primitive-constructor-types': 2,
'flowtype/require-valid-file-annotation': 2,
'import/no-duplicates': 2,
'arrow-body-style': 'error',
'eslint-comments/disable-enable-pair': ['error', {allowWholeFile: true}],
'eslint-comments/no-unused-disable': 'error',
'flowtype/boolean-style': 'error',
'flowtype/no-primitive-constructor-types': 'error',
'flowtype/require-valid-file-annotation': 'error',
'import/no-duplicates': 'error',
'import/no-extraneous-dependencies': [
2,
'error',
{
devDependencies: [
'/test-types/**',
Expand All @@ -222,21 +214,19 @@ module.exports = {
],
},
],
'import/no-unresolved': [2, {ignore: ['fsevents']}],
// This has to be disabled until all type and module imports are combined
// https://github.com/benmosher/eslint-plugin-import/issues/645
'import/order': 0,
'no-console': 0,
'import/no-unresolved': ['error', {ignore: ['fsevents']}],
'import/order': 'error',
'no-console': 'off',
'no-restricted-imports': [
2,
'error',
{
message: 'Please use graceful-fs instead.',
name: 'fs',
},
],
'no-unused-vars': 2,
'prettier/prettier': 2,
'sort-imports': [2, {ignoreDeclarationSort: true}],
'no-unused-vars': 'error',
'prettier/prettier': 'error',
'sort-imports': ['error', {ignoreDeclarationSort: true}],
},
settings: {
'import/ignore': ['react-native'],
Expand Down
10 changes: 5 additions & 5 deletions docs/Puppeteer.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ Here's an example of the GlobalSetup script

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

const DIR = path.join(os.tmpdir(), 'jest_puppeteer_global_setup');

Expand All @@ -79,11 +79,11 @@ Then we need a custom Test Environment for puppeteer

```js
// puppeteer_environment.js
const NodeEnvironment = require('jest-environment-node');
const fs = require('fs');
const path = require('path');
const puppeteer = require('puppeteer');
const os = require('os');
const puppeteer = require('puppeteer');
const NodeEnvironment = require('jest-environment-node');

const DIR = path.join(os.tmpdir(), 'jest_puppeteer_global_setup');

Expand Down Expand Up @@ -123,8 +123,8 @@ Finally, we can close the puppeteer instance and clean-up the file
```js
// teardown.js
const os = require('os');
const rimraf = require('rimraf');
const path = require('path');
const rimraf = require('rimraf');

const DIR = path.join(os.tmpdir(), 'jest_puppeteer_global_setup');
module.exports = async function () {
Expand Down
2 changes: 1 addition & 1 deletion docs/SnapshotTesting.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ A similar approach can be taken when it comes to testing your React components.

```javascript
import React from 'react';
import Link from '../Link.react';
import renderer from 'react-test-renderer';
import Link from '../Link.react';

it('renders correctly', () => {
const tree = renderer
Expand Down
2 changes: 1 addition & 1 deletion docs/TutorialReact.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ Now let's use React's test renderer and Jest's snapshot feature to interact with
```javascript
// Link.react.test.js
import React from 'react';
import Link from '../Link.react';
import renderer from 'react-test-renderer';
import Link from '../Link.react';

test('Link changes the class when hovered', () => {
const component = renderer.create(
Expand Down
3 changes: 1 addition & 2 deletions docs/TutorialReactNative.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,8 @@ Now let's use React's test renderer and Jest's snapshot feature to interact with
```javascript
// __tests__/Intro-test.js
import React from 'react';
import Intro from '../Intro';

import renderer from 'react-test-renderer';
import Intro from '../Intro';

test('renders correctly', () => {
const tree = renderer.create(<Intro />).toJSON();
Expand Down
2 changes: 1 addition & 1 deletion e2e/global-setup-custom-transform/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
*/
const crypto = require('crypto');
const fs = require('fs');
const {createDirectory} = require('jest-util');
const os = require('os');
const path = require('path');
const {createDirectory} = require('jest-util');

const DIR = path.join(os.tmpdir(), 'jest-global-setup-custom-transform');

Expand Down
2 changes: 1 addition & 1 deletion e2e/global-setup-node-modules/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import example from './node_modules/example';
const crypto = require('crypto');
const fs = require('fs');
const {createDirectory} = require('jest-util');
const os = require('os');
const path = require('path');
const {createDirectory} = require('jest-util');

const DIR = path.join(os.tmpdir(), 'jest-global-setup-node-modules');

Expand Down
2 changes: 1 addition & 1 deletion e2e/global-setup/project-1/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
*/
const crypto = require('crypto');
const fs = require('fs');
const {createDirectory} = require('jest-util');
const os = require('os');
const path = require('path');
const {createDirectory} = require('jest-util');

const DIR = path.join(os.tmpdir(), 'jest-global-setup-project-1');

Expand Down
2 changes: 1 addition & 1 deletion e2e/global-setup/project-2/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
*/
const crypto = require('crypto');
const fs = require('fs');
const {createDirectory} = require('jest-util');
const os = require('os');
const path = require('path');
const {createDirectory} = require('jest-util');

const DIR = path.join(os.tmpdir(), 'jest-global-setup-project-2');

Expand Down
2 changes: 1 addition & 1 deletion e2e/global-setup/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
*/
const crypto = require('crypto');
const fs = require('fs');
const {createDirectory} = require('jest-util');
const os = require('os');
const path = require('path');
const {createDirectory} = require('jest-util');

const DIR = path.join(os.tmpdir(), 'jest-global-setup');

Expand Down
2 changes: 1 addition & 1 deletion e2e/global-teardown/project-1/teardown.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
*/
const crypto = require('crypto');
const fs = require('fs');
const {createDirectory} = require('jest-util');
const os = require('os');
const path = require('path');
const {createDirectory} = require('jest-util');

const DIR = path.join(os.tmpdir(), 'jest-global-teardown-project-1');

Expand Down
2 changes: 1 addition & 1 deletion e2e/global-teardown/project-2/teardown.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
*/
const crypto = require('crypto');
const fs = require('fs');
const {createDirectory} = require('jest-util');
const os = require('os');
const path = require('path');
const {createDirectory} = require('jest-util');

const DIR = path.join(os.tmpdir(), 'jest-global-teardown-project-2');

Expand Down
2 changes: 1 addition & 1 deletion e2e/global-teardown/teardown.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
*/
const crypto = require('crypto');
const fs = require('fs');
const {createDirectory} = require('jest-util');
const os = require('os');
const path = require('path');
const {createDirectory} = require('jest-util');

const DIR = path.join(os.tmpdir(), 'jest-global-teardown');

Expand Down
2 changes: 1 addition & 1 deletion packages/expect/src/__tests__/matchers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

const {stringify} = require('jest-matcher-utils');
const {alignedAnsiStyleSerializer} = require('@jest/test-utils');
const jestExpect = require('../');
const Immutable = require('immutable');
const chalk = require('chalk');
const jestExpect = require('../');
const chalkEnabled = chalk.enabled;

expect.addSnapshotSerializer(alignedAnsiStyleSerializer);
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-core/src/__tests__/watch.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
*/

import chalk from 'chalk';
import TestWatcher from '../TestWatcher';
import {JestHook, KEYS} from 'jest-watcher';
import TestWatcher from '../TestWatcher';

const runJestMock = jest.fn();
const watchPluginPath = `${__dirname}/__fixtures__/watch_plugin`;
Expand Down
Loading