Skip to content

Commit

Permalink
Merge pull request #506 from Debbl/feat/eslint
Browse files Browse the repository at this point in the history
feat: support eslint flat config
  • Loading branch information
saltyshiomix authored Nov 9, 2024
2 parents 6907722 + 27759d1 commit 8afa351
Show file tree
Hide file tree
Showing 11 changed files with 952 additions and 264 deletions.
6 changes: 0 additions & 6 deletions .eslintignore

This file was deleted.

15 changes: 0 additions & 15 deletions .eslintrc.json

This file was deleted.

2 changes: 0 additions & 2 deletions dev.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable @typescript-eslint/no-var-requires */

const fs = require('fs-extra')
const path = require('path')
const execa = require('execa')
Expand Down
85 changes: 85 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import typescript from '@typescript-eslint/eslint-plugin'
import js from '@eslint/js'
import nextPlugin from '@next/eslint-plugin-next'
import reactPlugin from 'eslint-plugin-react'
import reactHooksPlugin from 'eslint-plugin-react-hooks'
import parserTypescript from '@typescript-eslint/parser'
import globals from 'globals'
import configPrettier from 'eslint-config-prettier'

/**
* @type {import('eslint').Linter.Config[]}
*/
const config = [
{
ignores: ['**/node_modules', 'pnpm-lock.yaml', '**/bin', '**/workspace'],
},
{
languageOptions: {
ecmaVersion: 2022,
globals: {
...globals.browser,
...globals.es2021,
...globals.node,
document: 'readonly',
navigator: 'readonly',
window: 'readonly',
},
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 2022,
sourceType: 'module',
},
sourceType: 'module',
},
rules: {
...js.configs.recommended.rules,
'no-unused-vars': [
'error',
{
args: 'none',
caughtErrors: 'none',
ignoreRestSiblings: true,
vars: 'all',
},
],
},
},
{
files: ['**/*.ts', '**/*.tsx'],
plugins: {
react: reactPlugin,
'react-hooks': reactHooksPlugin,
'@next/next': nextPlugin,
},
rules: {
...reactPlugin.configs['jsx-runtime'].rules,
...reactHooksPlugin.configs.recommended.rules,
...nextPlugin.configs.recommended.rules,
...nextPlugin.configs['core-web-vitals'].rules,
'@next/next/no-img-element': 'error',
},
},
{
files: ['**/*.ts', '**/*.tsx'],
plugins: {
'@typescript-eslint': typescript,
},
languageOptions: {
parser: parserTypescript,
},
rules: {
...typescript.configs.recommended.rules,
'@typescript-eslint/no-unused-vars': 'error',
'@typescript-eslint/no-explicit-any': 'error',
'@next/next/no-html-link-for-pages': 'off',
},
},
{
...configPrettier,
},
]

export default config
13 changes: 2 additions & 11 deletions examples/with-ant-design/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": false,
Expand All @@ -19,10 +15,5 @@
"isolatedModules": true,
"jsx": "preserve"
},
"exclude": [
"node_modules",
"renderer/next.config.js",
"app",
"dist"
]
"exclude": ["node_modules", "renderer/next.config.js", "app", "dist"]
}
3 changes: 1 addition & 2 deletions examples/with-next-i18next/next-i18next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ module.exports = {
reloadOnPrerender: process.env.NODE_ENV === 'development',
localePath:
typeof window === 'undefined'
? // eslint-disable-next-line @typescript-eslint/no-var-requires
require('path').resolve('./renderer/public/locales')
? require('path').resolve('./renderer/public/locales')
: '/locales',
}
2 changes: 1 addition & 1 deletion lib/nextron-dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const execaOptions: execa.Options = {
let firstCompile = true
let watching: webpack.Watching
let mainProcess: ChildProcess
let rendererProcess: ChildProcess // eslint-disable-line prefer-const
let rendererProcess: ChildProcess

const startMainProcess = () => {
logger.info(
Expand Down
2 changes: 0 additions & 2 deletions lint-staged.config.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable import/no-anonymous-default-export */

export default {
'**/*.(ts|tsx|js)': (filenames) => [
`npx eslint --fix ${filenames.join(' ')}`,
Expand Down
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,23 @@
"webpack-merge": "5.10.0"
},
"devDependencies": {
"@next/eslint-plugin-next": "^15.0.2",
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-commonjs": "^26.0.1",
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-terser": "^0.4.4",
"@types/eslint": "^9.6.1",
"@types/fs-extra": "^11.0.4",
"@types/node": "^20.14.2",
"@typescript-eslint/eslint-plugin": "^7.13.0",
"@typescript-eslint/parser": "^7.13.0",
"concurrently": "^8.2.2",
"eslint": "^9.5.0",
"eslint": "^9.14.0",
"eslint-config-next": "^14.2.4",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-react": "^7.37.2",
"eslint-plugin-react-hooks": "^5.0.0",
"globals": "^15.12.0",
"husky": "^9.0.11",
"lint-staged": "^15.2.7",
"prettier": "^3.3.2",
Expand Down
Loading

0 comments on commit 8afa351

Please sign in to comment.