-
Notifications
You must be signed in to change notification settings - Fork 11
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
feat: improve linter #11
Conversation
const prettierCache = new LRU<CacheInstance>(10) | ||
|
||
function createCache(cwd: string) { | ||
function createCache(cwd: string, filePath = cwd) { |
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.
Adding filePath
here so we can use it for resolving closest config.
function validateNoCliOptions(options: minimist.ParsedArgs) { | ||
return Object.entries(options).reduce((acc, [key, val]) => { | ||
if (key.startsWith('no-')) { | ||
if (val === true) { | ||
acc[key.replace(/^no-/, '')] = false | ||
} | ||
} else { | ||
acc[key] = val | ||
} | ||
return acc | ||
}, {} as minimist.ParsedArgs) | ||
} | ||
|
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.
This is a helper function that handles our --no-option
boolean options. They need to be omitted, when mirroring the default (value === false
), or converted into a key/value with shape {option: false}
.
This lets us override default boolean values - from the CLI API to the NodeJS API.
'config', | ||
'editorconfig', | ||
'insert-pragma', | ||
'jsx-bracket-same-line', | ||
'jsx-single-quote', | ||
'no-bracket-spacing', | ||
'no-semi', | ||
'require-pragma', | ||
'single-quote', | ||
'use-tabs', | ||
'vue-indent-script-and-style', |
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.
Same values as before but bracket-spacing
and semi
is now correctly no-bracket-spacing
and no-semi
.
@@ -106,26 +133,26 @@ export const invoke = ( | |||
args: string[], | |||
text: string, | |||
mtime: number, | |||
callback: (output: string) => void, | |||
callback: (err: unknown, response: string) => void, |
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.
This is the correct callback signature for invoke
.
This PR solves all issues reported in #9. |
This PR solves issues reported in #8. |
Any ETA for when can this be merged? #8 is a real issue that would be nice to have corrected. |
This PR aims to fix the following issues:
filePath
rather than the givencwd
. This is howprettier
is intended to do the lookup. (see https://prettier.io/docs/en/api.html#prettierresolveconfigfilepath--options and https://prettier.io/docs/en/api.html#prettierresolveconfigfilefilepath)invoke
and itscallback
correctly -callback(err, res)
. Beforeprettier_d_slim
send the result as anerr
. Unsure how it was possible for it to even work before. (see https://github.com/mantoni/core_d.js#api)--no-
options correctly by omitting them or negating them.This is tested and multiple repos and filetypes. It works on both monorepos and regular repos, by finding the closest config and resolving the local
prettier
correctly.Closes #8
Closes #9