diff --git a/README.md b/README.md index 9a73827..08d6b90 100644 --- a/README.md +++ b/README.md @@ -10,17 +10,44 @@ ## Setup -1. Install the dependencies +### React (with Next.js) + +Install dependencies: ``` npm i -D eslint @rocketseat/eslint-config ``` +Inside `.eslintrc.json` +``` +{ + "extends": [ + "@rocketseat/eslint-config/next", + "next/core-web-vitals" + ] +} +``` -2. Create a `.eslintrc.json` file extending the config: +### React (without Next.js) + +Install dependencies: +``` +npm i -D eslint @rocketseat/eslint-config +``` +Inside `.eslintrc.json` ``` { "extends": "@rocketseat/eslint-config/react" - // "extends": "@rocketseat/eslint-config/node" } ``` -> You can also use a `.eslintrc.js` instead of JSON if you prefer. +### Node.js + +Install dependencies: +``` +npm i -D eslint @rocketseat/eslint-config +``` +Inside `.eslintrc.json` +``` +{ + "extends": "@rocketseat/eslint-config/node" +} +``` diff --git a/next.js b/next.js new file mode 100644 index 0000000..35c243d --- /dev/null +++ b/next.js @@ -0,0 +1,55 @@ +module.exports = { + env: { + browser: true, + es2021: true, + jest: true, + }, + extends: [ + 'standard', + 'plugin:@typescript-eslint/recommended', + 'plugin:prettier/recommended', + ], + parser: '@typescript-eslint/parser', + parserOptions: { + ecmaFeatures: { + jsx: true + }, + ecmaVersion: 'latest', + sourceType: 'module' + }, + plugins: [ + 'jsx-a11y', + '@typescript-eslint' + ], + rules: { + 'prettier/prettier': ["error", { + 'printWidth': 80, + 'tabWidth': 2, + 'singleQuote': true, + 'trailingComma': 'all', + 'arrowParens': 'always', + 'semi': false, + 'endOfLine': 'auto', + }], + 'jsx-a11y/alt-text': [ + 'warn', + { + elements: ['img'], + img: ['Image'], + }, + ], + 'jsx-a11y/aria-props': 'warn', + 'jsx-a11y/aria-proptypes': 'warn', + 'jsx-a11y/aria-unsupported-elements': 'warn', + 'jsx-a11y/role-has-required-aria-props': 'warn', + 'jsx-a11y/role-supports-aria-props': 'warn', + }, + settings: { + react: { + version: 'detect', + }, + 'import/parsers': { + [require.resolve('@typescript-eslint/parser')]: ['.ts', '.tsx', '.d.ts'], + }, + } +} diff --git a/package.json b/package.json index 8da5cbf..18542f7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@rocketseat/eslint-config", - "version": "2.0.0", + "version": "2.1.0", "private": false, "description": "ESLint configuration used by Rocketseat.", "main": "index.js", @@ -17,7 +17,7 @@ "optional": true } }, - "devDependencies": { + "dependencies": { "@typescript-eslint/eslint-plugin": "^5.25.0", "@typescript-eslint/parser": "^5.25.0", "eslint": "^8.0.0",