e783b0a2e8
This PR re-includes ESLint with some notable changes, namely a guided setup similar to how TypeScript is instantiated in a Next.js application. To add ESLint to a project, developers will have to create an `.eslintrc` file in the root of their project or add an empty `eslintConfig` object to their `package.json` file. ```js touch .eslintrc ``` Then running `next build` will show instructions to install the required packages needed: <img width="862" alt="Screen Shot 2021-04-19 at 7 38 27 PM" src="https://user-images.githubusercontent.com/12476932/115316182-dfd51b00-a146-11eb-830c-90bad20ed151.png"> Once installed and `next build` is run again, `.eslintrc` will be automatically configured to include the default config: ```json { "extends": "next" } ``` In addition to this change: - The feature is now under the experimental flag and requires opt-in. After testing and feedback, it will be switched to the top-level namespace and turned on by default. - A new ESLint shareable configuration package is included that can be extended in any application with `{ extends: 'next' }` - This default config extends recommended rule sets from [`eslint-plugin-react`](https://www.npmjs.com/package/eslint-plugin-react), [`eslint-plugin-react-hooks`](https://www.npmjs.com/package/eslint-plugin-react-hooks), and [`eslint-plugin-next`](https://www.npmjs.com/package/@next/eslint-plugin-next) - All rules in [`eslint-plugin-next`](https://www.npmjs.com/package/@next/eslint-plugin-next) have been modified to include actionable links that show more information to help resolve each issue
55 lines
1.3 KiB
JavaScript
55 lines
1.3 KiB
JavaScript
/*
|
|
* @rushstack/eslint-patch is used to include plugins as dev
|
|
* dependencies instead of imposing them as peer dependencies
|
|
*
|
|
* https://www.npmjs.com/package/@rushstack/eslint-patch
|
|
*/
|
|
require('@rushstack/eslint-patch/modern-module-resolution')
|
|
|
|
module.exports = {
|
|
extends: [
|
|
'plugin:react/recommended',
|
|
'plugin:react-hooks/recommended',
|
|
'plugin:@next/next/recommended',
|
|
],
|
|
plugins: ['import', 'react'],
|
|
rules: {
|
|
'import/no-anonymous-default-export': 'warn',
|
|
'react/react-in-jsx-scope': 'off',
|
|
},
|
|
parser: './parser.js',
|
|
parserOptions: {
|
|
requireConfigFile: false,
|
|
sourceType: 'module',
|
|
allowImportExportEverywhere: true,
|
|
babelOptions: {
|
|
presets: ['next/babel'],
|
|
},
|
|
},
|
|
overrides: [
|
|
{
|
|
files: ['**/*.ts?(x)'],
|
|
parser: '@typescript-eslint/parser',
|
|
parserOptions: {
|
|
sourceType: 'module',
|
|
ecmaFeatures: {
|
|
jsx: true,
|
|
},
|
|
warnOnUnsupportedTypeScriptVersion: true,
|
|
},
|
|
},
|
|
],
|
|
settings: {
|
|
react: {
|
|
version: 'detect',
|
|
},
|
|
'import/parsers': {
|
|
[require.resolve('@typescript-eslint/parser')]: ['.ts', '.tsx', '.d.ts'],
|
|
},
|
|
'import/resolver': {
|
|
[require.resolve('eslint-import-resolver-node')]: {
|
|
extensions: ['.js', '.jsx', '.ts', '.tsx'],
|
|
},
|
|
},
|
|
},
|
|
}
|