New: option withNodeModules to unignore node_modules folders.#118
New: option withNodeModules to unignore node_modules folders.#118reklatsmasters wants to merge 4 commits intoprettier:masterfrom
withNodeModules to unignore node_modules folders.#118Conversation
This reverts commit 4ab7191.
|
Hi @reklatsmasters, can you please add a test for this |
BPScott
left a comment
There was a problem hiding this comment.
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.
| const prettierFileInfo = prettier.getFileInfo.sync(filepath, { | ||
| ignorePath: '.prettierignore' | ||
| ignorePath: '.prettierignore', | ||
| withNodeModules |
There was a problem hiding this comment.
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 || {}| properties: { | ||
| usePrettierrc: { type: 'boolean' } | ||
| usePrettierrc: { type: 'boolean' }, | ||
| withNodeModules: { type: 'boolean' } |
There was a problem hiding this comment.
Make this an object named fileInfoOptions
| { | ||
| code: 'a();\n', | ||
| filename: 'node_modules/dummy.js', | ||
| options: [{}, { withNodeModules: true }] |
There was a problem hiding this comment.
Updated usage would be
options: [{}, { fileInfoOptions: { withNodeModules: true }}]
|
Replaced by #187 |
This PR add option
withNodeModules(default:false) to unignorenode_modulesfolders. May be useful if you are using multiplenode_modulesdirectories, example to avoid many../..sequences.