-
Notifications
You must be signed in to change notification settings - Fork 26.5k
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
refactor: remove unnecessary lint-staged
operations
#65861
Merged
Merged
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
22ba8be
chore: update lint-staged husky version
devjiwonchoi b6fec5b
refactor: remove unnecessary configs
devjiwonchoi 6847497
refactor: remove unnecessarily targeting staged files
devjiwonchoi 8d29c8c
refactor: no install for husky prepare
devjiwonchoi f461b91
refactor: root glob * matches all
devjiwonchoi 8526b07
Merge branch 'canary' into update-husky-lint-staged
samcx 0e0d1b2
Merge branch 'canary' into update-husky-lint-staged
samcx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
pnpm lint-staged |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,8 @@ | ||
const { quote } = require('shell-quote') | ||
const { ESLint } = require('eslint') | ||
|
||
const eslint = new ESLint() | ||
|
||
/** | ||
* Escape filenames to ensure that spaces and such aren't interpreted as | ||
* separators. | ||
* | ||
* @param {string[]} filenames | ||
* @returns {string[]} | ||
*/ | ||
function escape(filenames) { | ||
if (process.platform === 'win32') { | ||
return filenames | ||
} | ||
|
||
return filenames.map((filename) => quote([filename]).replace(/\\@/g, '@')) | ||
} | ||
|
||
module.exports = { | ||
'**/*.{js,jsx,mjs,ts,tsx,mts}': async (filenames) => { | ||
const escapedFileNames = escape(filenames).join(' ') | ||
const eslintFileNames = await Promise.all( | ||
filenames.map(async (filename) => { | ||
const ignored = await eslint.isPathIgnored(filename) | ||
return ignored ? null : filename | ||
}) | ||
) | ||
|
||
return [ | ||
`prettier --with-node-modules --ignore-path .prettierignore --write ${escapedFileNames}`, | ||
`eslint --no-ignore --max-warnings=0 --fix ${escape(eslintFileNames.filter((filename) => filename !== null)).join(' ')}`, | ||
`git add ${escapedFileNames}`, | ||
] | ||
}, | ||
'**/*.{json,md,mdx,css,html,yml,yaml,scss}': (filenames) => { | ||
const escapedFileNames = escape(filenames).join(' ') | ||
return [ | ||
`prettier --with-node-modules --ignore-path .prettierignore --write ${escapedFileNames}`, | ||
`git add ${escapedFileNames}`, | ||
] | ||
}, | ||
'**/*.rs': (filenames) => { | ||
const escapedFileNames = escape(filenames).join(' ') | ||
return [`cargo fmt -- ${escapedFileNames}`, `git add ${escapedFileNames}`] | ||
}, | ||
'**/*.{js,jsx,mjs,ts,tsx,mts}': [ | ||
'prettier --write', | ||
'eslint --no-ignore --max-warnings=0 --fix', | ||
], | ||
'**/*.{json,md,mdx,css,html,yml,yaml,scss}': ['prettier --write'], | ||
'**/*.rs': ['cargo fmt'], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
--with-node-modules
flag since no effect if gitignored--ignore-path
since prettier reads.prettierignore
&.gitignore
by defaultThere 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.
The
--with-node-modules
flag is to force linting test files in nested undernode_modules
iirc we should re-add this