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

Move Jest and ESLint to peerDependencies #55

Merged
merged 4 commits into from
Oct 4, 2018
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
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
"chalk": "^2.4.1",
"cosmiconfig": "^5.0.0",
"create-jest-runner": "^0.4.1",
"eslint": "^5.6.0",
"find-up": "^3.0.0"
"eslint": "^5.6.0"
},
"devDependencies": {
"@babel/cli": "^7.1.0",
Expand All @@ -47,6 +46,10 @@
"prettier": "^1.14.3",
"rimraf": "^2.6.2"
},
"peerDependencies": {
"eslint": "^4.0.0 || ^5.0.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you remove eslint from dependencies with this change? Also, remove https://github.com/jest-community/jest-runner-eslint/blob/master/src/utils/getLocalESLint.js?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I just moved it to devDeps...

I guess https://github.com/jest-community/jest-runner-eslint/blob/master/src/utils/getLocalESLint.js now just becomes a regular require('eslint') right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, that's the theory!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can be both a dep and a peer dep, or a peer and a dev - in either case it will do what you expect. The difference, though, is that if it’s a dep + peer, then it might not be a breaking change to add the peer - if it’s a peer+dev, then it definitely is breaking.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ljharb thanks, you are great!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when it's in dependencies now, we will always require our own, and never the user's. Which means that this now moves from eslint 4 to eslint 5, which is a breaking change either way.

I suppose we could roll back to eslint v4, but we really should allow people to use eslint v5 with this plugin

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not when it's also in peer dependencies - if the user specifies eslint 4, then we won't install v5, we'll prefer their v4.

"jest": "^21.0.0 || ^22.0.0 || ^23.0.0"
},
"prettier": {
"proseWrap": "never",
"singleQuote": true,
Expand Down
32 changes: 15 additions & 17 deletions src/runner/__tests__/runESLint.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,23 @@ const path = require('path');

const runESLintRunnerWithMockedEngine = options => {
jest.resetModules();
jest.doMock('../../utils/getLocalESLint', () => () => {
return {
CLIEngine: class {
isPathIgnored(file) {
return options.cliEngine.ignoredFiles.includes(file);
}
jest.doMock('eslint', () => ({
CLIEngine: class {
isPathIgnored(file) {
return options.cliEngine.ignoredFiles.includes(file);
}

executeOnFiles() {
return {
errorCount: options.cliEngine.errorCount,
};
}
executeOnFiles() {
return {
errorCount: options.cliEngine.errorCount,
};
}

getFormatter() {
return () => {};
}
},
};
});
getFormatter() {
return () => {};
}
},
}));
const runESLint = require('../runESLint');

return runESLint({ extraOptions: {}, ...options.runESLint });
Expand Down
3 changes: 1 addition & 2 deletions src/runner/runESLint.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { pass, fail, skip } = require('create-jest-runner');
const getLocalESLint = require('../utils/getLocalESLint');
const { CLIEngine } = require('eslint');
const getESLintOptions = require('../utils/getESLintOptions');

const getComputedFixValue = ({ fix, quiet, fixDryRun }) => {
Expand All @@ -17,7 +17,6 @@ const runESLint = ({ testPath, config, extraOptions }) => {
require(config.setupTestFrameworkScriptFile);
}

const { CLIEngine } = getLocalESLint(config);
const { cliOptions: baseCliOptions } = getESLintOptions(config);
const cliOptions = {
...baseCliOptions,
Expand Down
10 changes: 0 additions & 10 deletions src/utils/getLocalESLint.js

This file was deleted.

12 changes: 12 additions & 0 deletions src/watchFixPlugin/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
const { getVersion: getJestVersion } = require('jest');
const chalk = require('chalk');
const configOverrides = require('../utils/configOverrides');

const majorJestVersion = parseInt(getJestVersion().split('.')[0], 10);

if (majorJestVersion < 23) {
// eslint-disable-next-line no-console
throw new Error(`Insufficient Jest version for jest-runner-eslint watch plugin

Watch plugins are only available in Jest 23.0.0 and above.
Upgrade your version of Jest in order to use it.
`);
}

class ESLintWatchFixPlugin {
constructor({ stdout, config }) {
this._stdout = stdout;
Expand Down
29 changes: 0 additions & 29 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1870,12 +1870,6 @@ find-up@^2.0.0, find-up@^2.1.0:
dependencies:
locate-path "^2.0.0"

find-up@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/find-up/-/find-up-3.0.0.tgz#49169f1d7993430646da61ecc5ae355c21c97b73"
dependencies:
locate-path "^3.0.0"

flat-cache@^1.2.1:
version "1.2.2"
resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-1.2.2.tgz#fa86714e72c21db88601761ecf2f555d1abc6b96"
Expand Down Expand Up @@ -3044,13 +3038,6 @@ locate-path@^2.0.0:
p-locate "^2.0.0"
path-exists "^3.0.0"

locate-path@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-3.0.0.tgz#dbec3b3ab759758071b58fe59fc41871af21400e"
dependencies:
p-locate "^3.0.0"
path-exists "^3.0.0"

lodash.debounce@^4.0.8:
version "4.0.8"
resolved "https://registry.yarnpkg.com/lodash.debounce/-/lodash.debounce-4.0.8.tgz#82d79bff30a67c4005ffd5e2515300ad9ca4d7af"
Expand Down Expand Up @@ -3473,28 +3460,12 @@ p-limit@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-1.1.0.tgz#b07ff2d9a5d88bec806035895a2bab66a27988bc"

p-limit@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.0.0.tgz#e624ed54ee8c460a778b3c9f3670496ff8a57aec"
dependencies:
p-try "^2.0.0"

p-locate@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-2.0.0.tgz#20a0103b222a70c8fd39cc2e580680f3dde5ec43"
dependencies:
p-limit "^1.1.0"

p-locate@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-3.0.0.tgz#322d69a05c0264b25997d9f40cd8a891ab0064a4"
dependencies:
p-limit "^2.0.0"

p-try@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.0.0.tgz#85080bb87c64688fa47996fe8f7dfbe8211760b1"

parse-glob@^3.0.4:
version "3.0.4"
resolved "https://registry.yarnpkg.com/parse-glob/-/parse-glob-3.0.4.tgz#b2c376cfb11f35513badd173ef0bb6e3a388391c"
Expand Down