Skip to content

Commit

Permalink
Add basic configuration for formatting and linting (#3)
Browse files Browse the repository at this point in the history
* Add basic prettier, eslint, and vscode config

* Add eslint import sorting and autofix existing files

* Add eslint rule prefer-const
  • Loading branch information
paulcretu authored Aug 3, 2021
1 parent 3a4a720 commit 5b275e5
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 2 deletions.
23 changes: 22 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
{
"extends": ["next", "next/core-web-vitals"]
"extends": ["next", "next/core-web-vitals", "prettier"],
"plugins": ["simple-import-sort"],
"rules": {
"prefer-const": "warn",
"simple-import-sort/imports": "warn",
"simple-import-sort/exports": "warn",
"import/no-unused-modules": [
"warn",
{
"unusedExports": true,
"ignoreExports": ["pages"] // pages are automatically imported by nextjs
}
]
},
"overrides": [
{
"files": ["**/*.ts?(x)"],
"rules": {
// typescript only rules go here
}
}
]
}
6 changes: 6 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.next
next-env.d.ts
node_modules
yarn.lock
package-lock.json
public
4 changes: 4 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"semi": false,
"singleQuote": true
}
7 changes: 7 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
15 changes: 15 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
"lint": "next lint",
"lint:fix": "next lint --fix",
"format": "prettier . --write"
},
"dependencies": {
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-simple-import-sort": "^7.0.0",
"next": "11.0.1",
"prettier": "^2.3.2",
"react": "17.0.2",
"react-dom": "17.0.2"
},
Expand Down
1 change: 1 addition & 0 deletions pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import '../styles/globals.css'

import type { AppProps } from 'next/app'

function MyApp({ Component, pageProps }: AppProps) {
Expand Down
1 change: 1 addition & 0 deletions pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Head from 'next/head'
import Image from 'next/image'

import styles from '../styles/Home.module.css'

export default function Home() {
Expand Down

0 comments on commit 5b275e5

Please sign in to comment.