-
-
Notifications
You must be signed in to change notification settings - Fork 205
New: option withNodeModules
to unignore node_modules
folders.
#118
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
New: option withNodeModules
to unignore node_modules
folders.
#118
Conversation
This reverts commit 4ab7191.
Hi @reklatsmasters, can you please add a test for this |
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.
Thanks for being patient :)
For the sake of future compatibility I think we should pass in a whole object that represents all of the options in getFileInfo. That way if prettier were to add an extra option to getFileInfo() then we wouldn't need to add extra code to allow users to modify it.
@@ -164,7 +167,8 @@ module.exports = { | |||
: null; | |||
|
|||
const prettierFileInfo = prettier.getFileInfo.sync(filepath, { | |||
ignorePath: '.prettierignore' | |||
ignorePath: '.prettierignore', | |||
withNodeModules |
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.
Rather than pass in a single value within the options here, I think it would be more future-compatible to pass in an object that is merged with some defaults. That means that if prettier decides to add additional options to getFileInfo() then we won't need to make additional changes to accommodate them.
Something like this (written but not tested):
const fileInfoOptions = Object.assign(
{},
{ ignorePath: '.prettierignore' }
eslintFileInfoOptions
)
const prettierFileInfo = prettier.getFileInfo.sync(filepath, fileInfoOptions);
Where eslintFileInfoOptions
is defined above as something like this: (written but not tested)
const eslintFileInfoOptions = context.options[1] && context.options[1].fileInfoOptions || {}
@@ -131,7 +131,8 @@ module.exports = { | |||
{ | |||
type: 'object', | |||
properties: { | |||
usePrettierrc: { type: 'boolean' } | |||
usePrettierrc: { type: 'boolean' }, | |||
withNodeModules: { type: 'boolean' } |
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.
Make this an object named fileInfoOptions
{ | ||
code: 'a();\n', | ||
filename: 'node_modules/dummy.js', | ||
options: [{}, { withNodeModules: true }] |
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.
Updated usage would be
options: [{}, { fileInfoOptions: { withNodeModules: true }}]
Replaced by #187 |
This PR add option
withNodeModules
(default:false
) to unignorenode_modules
folders. May be useful if you are using multiplenode_modules
directories, example to avoid many../..
sequences.