chore: willboosterify this repo#15
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates project configurations and dependencies, primarily to exclude package.json from oxfmt formatting and upgrade linting tools. Feedback identifies several redundant exclusion patterns in lefthook.yml and .idea/watcherTasks.xml that should be removed to simplify the code and adhere to the repository's style guide.
| # Lefthook expands {staged_files} as shell-escaped args, so paths with spaces stay intact. | ||
| oxlint_files="$(printf '%s\n' {staged_files} | grep -E '(\.astro$|\.cjs$|\.cts$|\.js$|\.jsx$|\.mjs$|\.mts$|\.svelte$|\.ts$|\.tsx$|\.vue$)' || true)" | ||
| oxfmt_files="$(printf '%s\n' {staged_files} | grep -E '(\.astro$|\.cjs$|\.css$|\.cts$|\.gql$|\.graphql$|\.hbs$|\.htm$|\.html$|\.js$|\.json$|\.json5$|\.jsonc$|\.jsx$|\.less$|\.md$|\.mdx$|\.mjs$|\.mts$|\.scss$|\.svelte$|\.toml$|\.ts$|\.tsx$|\.vue$|\.yaml$|\.yml$)' || true)" | ||
| oxfmt_files="$(printf '%s\n' {staged_files} | grep -E '(\.astro$|\.cjs$|\.css$|\.cts$|\.gql$|\.graphql$|\.hbs$|\.htm$|\.html$|\.js$|\.json$|\.json5$|\.jsonc$|\.jsx$|\.less$|\.md$|\.mdx$|\.mjs$|\.mts$|\.scss$|\.svelte$|\.toml$|\.ts$|\.tsx$|\.vue$|\.yaml$|\.yml$)' | grep -v -E '(^|/)package\.json$' || true)" |
There was a problem hiding this comment.
The first grep -E command is redundant because the glob pattern on line 15 already filters {staged_files} to only include files with these extensions. Simplifying this line improves readability and adheres to the repository style guide (Rule 6).
oxfmt_files="$(printf '%s\n' {staged_files} | grep -v -E '(^|/)package\.json$' || true)"References
- Simplify code as much as possible to eliminate redundancy. (link)
|
|
||
| if [ -n "$oxfmt_files" ]; then | ||
| node node_modules/.bin/oxfmt --write --no-error-on-unmatched-pattern $oxfmt_files | ||
| node node_modules/.bin/oxfmt --write --no-error-on-unmatched-pattern '!**/package.json' $oxfmt_files |
There was a problem hiding this comment.
The '!**/package.json' argument is redundant here because oxfmt_files has already been filtered to exclude package.json on line 19. Removing it simplifies the command per Rule 6 of the style guide.
node node_modules/.bin/oxfmt --write --no-error-on-unmatched-pattern $oxfmt_filesReferences
- Simplify code as much as possible to eliminate redundancy. (link)
| <component name="ProjectTasksOptions"> | ||
| <TaskOptions isEnabled="true"> | ||
| <option name="arguments" value="node_modules/.bin/oxfmt --write --no-error-on-unmatched-pattern $FilePathRelativeToProjectRoot$" /> | ||
| <option name="arguments" value="node_modules/.bin/oxfmt --write --no-error-on-unmatched-pattern !**/package.json $FilePathRelativeToProjectRoot$" /> |
There was a problem hiding this comment.
The !**/package.json argument is redundant for this task because it only triggers for .astro files (as specified on line 9). This redundancy exists in most of the other TaskOptions as well. According to the style guide (Rule 6), code should be simplified to eliminate redundancy.
| <option name="arguments" value="node_modules/.bin/oxfmt --write --no-error-on-unmatched-pattern !**/package.json $FilePathRelativeToProjectRoot$" /> | |
| <option name="arguments" value="node_modules/.bin/oxfmt --write --no-error-on-unmatched-pattern $FilePathRelativeToProjectRoot$" /> |
References
- Simplify code as much as possible to eliminate redundancy. (link)
No description provided.