Skip to content

Commit cc6b683

Browse files
authored
Setup lint-staged (closes #23)
* βž• :: add prettier and eslint to the project * πŸ”§ :: set some defaults for prettier and eslint * 🎨 :: let prettier format all the files * this should fail * βž• :: add husky and lint-staged * πŸ”§ :: configure husky and lint-staged * πŸ”§ :: run prettier as an eslint rule * πŸ§ͺ :: test lint-staged
1 parent 4873af0 commit cc6b683

32 files changed

+5864
-2192
lines changed

β€Ž.eslintrc.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": ["next/core-web-vitals", "plugin:prettier/recommended"]
3+
}

β€Ž.husky/pre-commit

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
npx lint-staged

β€Ž.lintstagedrc.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const path = require('path');
2+
3+
const buildEslintCommand = (filenames) =>
4+
`next lint --fix --file ${filenames
5+
.map((f) => path.relative(process.cwd(), f))
6+
.join(' --file ')}`;
7+
8+
module.exports = {
9+
'*.{js,jsx,ts,tsx}': [buildEslintCommand],
10+
};

β€Ž.prettierignore

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# dependencies
2+
/node_modules
3+
/.pnp
4+
.pnp.js
5+
6+
# testing
7+
/coverage
8+
9+
# next.js
10+
/.next/
11+
/out/
12+
13+
# production
14+
/build
15+
16+
# misc
17+
.DS_Store
18+
*.pem
19+
20+
# debug
21+
npm-debug.log*
22+
yarn-debug.log*
23+
yarn-error.log*
24+
.pnpm-debug.log*
25+
26+
# local env files
27+
.env*.local
28+
29+
# vercel
30+
.vercel
31+
32+
# typescript
33+
*.tsbuildinfo
34+
next-env.d.ts
35+

β€Ž.prettierrc.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"trailingComma": "es5",
3+
"tabWidth": 2,
4+
"semi": true,
5+
"singleQuote": true,
6+
"useTabs": true
7+
}

β€Žnext.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/** @type {import('next').NextConfig} */
22
const nextConfig = {
3-
reactStrictMode: true,
3+
reactStrictMode: true,
44
};
55

66
module.exports = nextConfig;

0 commit comments

Comments
Β (0)