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

feat: improve linter #11

Closed
wants to merge 5 commits into from
Closed

feat: improve linter #11

wants to merge 5 commits into from

Conversation

sQVe
Copy link
Contributor

@sQVe sQVe commented Jun 23, 2021

This PR aims to fix the following issues:

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

const prettierCache = new LRU<CacheInstance>(10)

function createCache(cwd: string) {
function createCache(cwd: string, filePath = cwd) {
Copy link
Contributor Author

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.

Comment on lines +73 to +85
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)
}

Copy link
Contributor Author

@sQVe sQVe Jun 23, 2021

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.

Comment on lines +89 to +99
'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',
Copy link
Contributor Author

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,
Copy link
Contributor Author

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.

@sQVe
Copy link
Contributor Author

sQVe commented Jun 23, 2021

This PR solves all issues reported in #9.

@sQVe
Copy link
Contributor Author

sQVe commented Jun 23, 2021

This PR solves issues reported in #8.

@Couto
Copy link

Couto commented Sep 15, 2021

Any ETA for when can this be merged? #8 is a real issue that would be nice to have corrected.
Thank you for your work 👍

@sQVe sQVe closed this May 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Not using local version on monorepos YAML formatting broken
2 participants