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
Add exports
to package.json to restrict access to private internals
#2208
Conversation
23941a6
to
1ae5728
Compare
@@ -19,7 +19,8 @@ | |||
}, | |||
"license": "MIT", | |||
"author": "Robert Jackson <me@rwjblue.com>", | |||
"main": "lib/index.js", | |||
"exports": "./lib/index.js", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we will need to expose lib/helpers/rule-test-harness.js
as well. It is used by the plugins to test their rules (example).
But maybe it is the good time to expose it through lib/index.js
? Wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, my preference would be that we expose that through lib/index.js
, as I've implemented here: #2209
I added to the description of this PR that there's another item we need to solve: What to do about users who may need to retrieve the default config from no-bare-strings? |
It is difficult to tell if the default config from no-bare-strings is really consummed by some ember-template-lint plugins. TBH I have no idea. I see two options:
I see your PR as the opportunity to keep the API surface under control. Then, I would not expose the default config from no-bare-strings. But maybe there are other opinions. |
@dcyriller thanks for the feedback. I agree we should avoid exposing things unnecessarily. I'm going to redesign the |
I see, thanks for the explanation. I gave it a try in the linked PR. |
exports
to package.jsonexports
to package.json to restrict access to private internals
FYI I noticed ember-template-lint-plugin-tailwind uses |
@dcyriller good catch. I don't really like this clunky I'm leaning toward not publishing |
https://nodejs.org/api/packages.html#exports
This prevents users from importing files directly from this package.
ESLint v8 also added this restriction.
Ideally, we'll hear from users after making this change if there are additional internals that we need to expose as part of our public NodeJS API in lib/index.js.
Part of v4 release (#1908).
TODO:
generateRuleTests
as named export in public NodeJS API #2209const { DEFAULT_CONFIG } = require('ember-template-lint/lib/rules/no-bare-strings');
Changeno-bare-strings
rule options to augment instead of replace the default config #2213