Skip to content

Commit 0e95506

Browse files
aymanesarrarmfix22
andauthored
eslint config for nextjs (#1322)
* eslint config for nextjs * removed plugins, settings, parser from the config * changed the script to next lint and installed the eslint next config package * lint fixes * move to dev dependencies * remove unnecessary rules * remove unnecessary babel deps * lint on root dir Co-authored-by: Mike Fix <[email protected]>
1 parent c68e03a commit 0e95506

File tree

6 files changed

+209
-366
lines changed

6 files changed

+209
-366
lines changed

.eslintrc.js

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,9 @@
11
module.exports = {
2-
parser: '@babel/eslint-parser',
3-
parserOptions: {
4-
requireConfigFile: false,
5-
babelOptions: {
6-
presets: ['next/babel'],
7-
},
8-
},
9-
env: {
10-
browser: true,
11-
es6: true,
12-
node: true,
13-
jest: true,
14-
},
15-
extends: ['eslint:recommended', 'plugin:react/recommended', 'plugin:jsx-a11y/recommended'],
16-
plugins: ['import', 'react', 'jsx-a11y', 'react-hooks'],
2+
env: { es6: true, jest: true },
3+
extends: ['eslint:recommended', 'plugin:jsx-a11y/recommended', 'next'],
174
rules: {
185
'import/no-unresolved': 'error',
196
'no-duplicate-imports': 'error',
20-
'react/prop-types': 'off',
217
'react/display-name': 'off',
228
'react/jsx-no-target-blank': 'error',
239
'react/jsx-uses-react': 'error',
@@ -26,10 +12,9 @@ module.exports = {
2612
'react-hooks/rules-of-hooks': 'error',
2713
'react-hooks/exhaustive-deps': 'error',
2814
'no-console': ['error', { allow: ['error'] }],
29-
},
30-
settings: {
31-
react: {
32-
version: 'detect',
33-
},
15+
// TODO re-enable these
16+
'@next/next/no-img-element': 'off',
17+
'@next/next/no-html-link-for-pages': 'off',
18+
'@next/next/link-passhref': 'off',
3419
},
3520
}

lib/api.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ const createSnippet = debounce(data => updateSnippet(null, data), ms('5s'), {
164164
trailing: false,
165165
})
166166

167-
export default {
167+
const api = {
168168
snippet: {
169169
get: getSnippet,
170170
list: listSnippets,
@@ -177,3 +177,5 @@ export default {
177177
imgur,
178178
downloadThumbnailImage,
179179
}
180+
181+
export default api

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"test:e2e": "npm run cy:run --",
2222
"deploy": "vercel -S carbon-app",
2323
"prettier": "prettier --config .prettierrc --write {.,components,lib,pages}/*.js {components,lib,pages}/**/*.js",
24-
"lint": "eslint .",
24+
"lint": "next lint --dir .",
2525
"contrib:add": "all-contributors add",
2626
"contrib:build": "all-contributors generate",
2727
"cy:run": "cypress run --config-file cypress/config.json",
@@ -69,11 +69,10 @@
6969
},
7070
"devDependencies": {
7171
"@applitools/eyes-cypress": "^3.23.6",
72-
"@babel/core": "^7.16.12",
73-
"@babel/eslint-parser": "^7.16.5",
7472
"all-contributors-cli": "^6.20.0",
7573
"cypress": "^9.3.1",
7674
"eslint": "^8.7.0",
75+
"eslint-config-next": "^12.0.8",
7776
"eslint-plugin-import": "^2.25.4",
7877
"eslint-plugin-jsx-a11y": "^6.5.1",
7978
"eslint-plugin-react": "^7.28.0",

pages/_document.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react'
22
import Document, { Html, Head, Main, NextScript } from 'next/document'
33

4-
export default class extends Document {
4+
export default class Doc extends Document {
55
render() {
66
return (
77
<Html lang="en">

pages/api/image/[id].js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export const config = {
1616
},
1717
}
1818

19-
export default async (req, res) => {
19+
export default async function id(req, res) {
2020
// TODO proper auth
2121
if (req.method === 'GET') {
2222
if (

0 commit comments

Comments
 (0)