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

refactor validatePlugins to throw coded errors #4237

Merged
merged 1 commit into from
Apr 28, 2020

Conversation

boneskull
Copy link
Contributor

@boneskull boneskull commented Apr 21, 2020

  • add createInvalidPluginError for reporters, UIs, and future plugins
  • ensures the original error is output if the module exists, but it throws (see test/node-unit/cli/fixtures/bad-module.fixture.js)
  • remove unneeded process.cwd() from call to path.resolve()

Ref: #4198

@boneskull boneskull added type: chore generally involving deps, tooling, configuration, etc. semver-patch implementation requires increase of "patch" version number; "bug fixes" labels Apr 21, 2020
@boneskull boneskull self-assigned this Apr 21, 2020
@coveralls
Copy link

coveralls commented Apr 21, 2020

Coverage Status

Coverage increased (+0.08%) to 93.145% when pulling c2f55a2 on boneskull/issue/2839-new-error into 6838eaf on master.

lib/cli/run-helpers.js Outdated Show resolved Hide resolved
@boneskull boneskull force-pushed the boneskull/issue/2839-new-error branch from f08d590 to c2f55a2 Compare April 22, 2020 20:05
@boneskull
Copy link
Contributor Author

@raymondfeng updated

@boneskull
Copy link
Contributor Author

I think this is pretty non-controversial, but would still like another maintainer to look.

lib/cli/run-helpers.js Outdated Show resolved Hide resolved
Copy link
Contributor

@juergba juergba left a comment

Choose a reason for hiding this comment

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

Can we exclude the HTML reporter for CLI usage?
I'm not sure wether the plugin validation is the correct place for this.

lib/cli/run-helpers.js Outdated Show resolved Hide resolved
test/node-unit/cli/fixtures/bad-module.fixture.js Outdated Show resolved Hide resolved
test/node-unit/cli/run-helpers.spec.js Outdated Show resolved Hide resolved
@boneskull
Copy link
Contributor Author

boneskull commented Apr 27, 2020

@juergba

Can we exclude the HTML reporter for CLI usage?
I'm not sure wether the plugin validation is the correct place for this.

The html reporter can conceivably work if a user requires jsdom and initializes it. I am not sure of the use case, but just because I don't know what it is doesn't mean it isn't valid.

Right now, w/o jsdom, --reporter html will fail with ReferenceError: document is not defined. We could maybe do a check before usage of global.document to throw more friendly error. But I don't think that should be in this PR.

- add `createInvalidPluginError` for reporters, UIs, and future plugins
- ensures the original error is output if the module exists, but it throws (see `test/node-unit/cli/fixtures/bad-module.fixture.js`)
- remove unneeded `process.cwd()` from call to `path.resolve()`

Ref: #4198
@boneskull boneskull force-pushed the boneskull/issue/2839-new-error branch from c2f55a2 to 74e9c4d Compare April 27, 2020 19:30
@boneskull
Copy link
Contributor Author

Updated to resolve peer review issues

exports.validatePlugin = (opts, pluginType, map = {}) => {
/**
* This should be a unique identifier; either a string (present in `map`),
* or a resolvable (via `require.resolve`) module ID/path.
Copy link
Contributor

Choose a reason for hiding this comment

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

(Then we will have the same ESM / async problematic here.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

true, might as well make this async too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think that's another PR though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver-patch implementation requires increase of "patch" version number; "bug fixes" type: chore generally involving deps, tooling, configuration, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants