-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #85 from franklinjavier/chore-eslint
chore: improve eslint, prettier, husky
- Loading branch information
Showing
27 changed files
with
7,013 additions
and
4,643 deletions.
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
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
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 |
---|---|---|
|
@@ -10,6 +10,5 @@ node_modules | |
/build/ | ||
/api/* | ||
/coverage | ||
.jest/ | ||
.DS_Store | ||
tailwind.css |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
npx 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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { quote as escape } from 'shell-quote' | ||
import { ESLint } from 'eslint' | ||
|
||
const eslint = new ESLint() | ||
const isWin = process.platform === 'win32' | ||
|
||
const escapeFileNamesForPrettier = (filenames) => | ||
filenames | ||
.map((filename) => `"${isWin ? filename : escape([filename])}"`) | ||
.join(' ') | ||
|
||
export default { | ||
'**/*.{js,jsx,ts,tsx}': (filenames) => { | ||
return [ | ||
`pnpm lint --fix ${filenames | ||
.filter((file) => !eslint.isPathIgnored(file)) | ||
.map((f) => `"${f}"`) | ||
.join(' ')}`, | ||
] | ||
}, | ||
'**/*.{json,md,mdx,css,html,yml,yaml,scss}': (filenames) => { | ||
return [`prettier --write ${escapeFileNamesForPrettier(filenames)}`] | ||
}, | ||
} |
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,10 +1,5 @@ | ||
{ | ||
"tabWidth": 2, | ||
"printWidth": 110, | ||
"endOfLine": "auto", | ||
"arrowParens": "always", | ||
"trailingComma": "all", | ||
"semi": false, | ||
"singleQuote": true, | ||
"bracketSpacing": true | ||
} | ||
"plugins": [ | ||
"prettier-plugin-tailwindcss" | ||
] | ||
} |
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,17 +1,9 @@ | ||
{ | ||
"recommendations": [ | ||
"dbaeumer.vscode-eslint", | ||
"editorconfig.editorconfig", | ||
"codeandstuff.package-json-upgrade", | ||
"esbenp.prettier-vscode", | ||
"mattpocock.ts-error-translator", | ||
"wix.vscode-import-cost", | ||
"adpyke.codesnap", | ||
"mikestead.dotenv", | ||
"prisma.prisma", | ||
"gruntfuggly.todo-tree", | ||
"ms-vsliveshare.vsliveshare-pack", | ||
"chakrounanas.turbo-console-log", | ||
"bradlc.vscode-tailwindcss" | ||
] | ||
} |
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,11 +1,14 @@ | ||
{ | ||
"editor.formatOnSave": false, | ||
"editor.codeActionsOnSave": { | ||
"source.fixAll.eslint": "explicit" | ||
}, | ||
"editor.formatOnPaste": true, | ||
"editor.formatOnSave": true, | ||
"editor.defaultFormatter": "esbenp.prettier-vscode", | ||
"eslint.format.enable": true, | ||
"eslint.validate": ["typescript", "typescriptreact", "javascript", "javascriptreact"], | ||
"eslint.packageManager": "pnpm" | ||
"tailwindCSS.experimental.classRegex": [":\\s*?[\"'`]([^\"'`]*).*?,"], | ||
"explorer.fileNesting.enabled": true, | ||
"explorer.fileNesting.patterns": { | ||
"package.json": ".eslint*, prettier*, tsconfig*, vite*, pnpm-lock*, bun.lockb, nest*, biome*, .editorconfig*, .nvmrc*, .gitignore*", | ||
"tailwind.config.*": "tailwind.config*, postcss.config*", | ||
".env.local": ".env*", | ||
".env": ".env*" | ||
} | ||
} |
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 |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
- Remix ❤️ Vite | ||
- Tailwind | ||
- Jest | ||
- Vitest | ||
- Eslint | ||
- Prettier | ||
- Typescript | ||
|
2 changes: 1 addition & 1 deletion
2
app/components/title.test.tsx → app/components/__tests__/title.spec.tsx
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
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,8 +1,13 @@ | ||
import { classNames } from '~/lib/class-names' | ||
import { cn } from '~/lib/cn' | ||
|
||
type TitleProps = React.ComponentProps<'h1'> | ||
export function Title({ className, ...props }: TitleProps) { | ||
return ( | ||
<h1 className={classNames('text-4xl font-bold tracking-tight text-gray-900 sm:text-6xl')} {...props} /> | ||
<h1 | ||
className={cn( | ||
'text-4xl font-bold tracking-tight text-gray-900 sm:text-6xl', | ||
)} | ||
{...props} | ||
/> | ||
) | ||
} |
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
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { cn } from '../cn' | ||
|
||
describe('cn', () => { | ||
it('returns empty string for no parameters', () => { | ||
expect(cn()).toBe('') | ||
}) | ||
it('returns a string to be used as html classNames', () => { | ||
expect(cn('base', 'another', 'yet-another class')).toBe( | ||
'base another yet-another class', | ||
) | ||
}) | ||
|
||
it('filters out nil values', () => { | ||
expect(cn('base', undefined, null, 'another')).toBe('base another') | ||
}) | ||
|
||
it('merge classes', () => { | ||
expect(cn('w-full p-0', 'p-6')).toBe('w-full p-6') | ||
}) | ||
|
||
it('filters out booleans accepting ternary, && and || operators', () => { | ||
const yup = true | ||
const no = false | ||
expect( | ||
cn( | ||
'base', | ||
yup ? 'valid' : 'invalid', | ||
yup && 'yes', | ||
yup || 'no', | ||
no || 'appear', | ||
), | ||
).toBe('base valid yes appear') | ||
}) | ||
}) |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { twMerge } from 'tailwind-merge' | ||
|
||
export function cn(...args: unknown[]): string { | ||
return twMerge( | ||
args | ||
.flat() | ||
.filter((x) => typeof x === 'string') | ||
.join(' '), | ||
) | ||
} |
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
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.