Skip to content

Commit

Permalink
feat: update eslint config in React templates (vitejs#13550)
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnaudBarre authored and xinxinhe1810 committed Jul 4, 2023
1 parent 6d31387 commit b18a72f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/create-vite/template-preact-ts/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ import { render } from 'preact'
import { App } from './app.tsx'
import './index.css'

render(<App />, document.getElementById('app') as HTMLElement)
render(<App />, document.getElementById('app')!)
15 changes: 13 additions & 2 deletions packages/create-vite/template-react-ts/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
/* eslint-env node */

module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'plugin:react-hooks/recommended',
],
parser: '@typescript-eslint/parser',
parserOptions: { ecmaVersion: 'latest', sourceType: 'module' },
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
project: true,
tsconfigRootDir: __dirname,
},
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': 'warn',
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
'@typescript-eslint/no-non-null-assertion': 'off',
},
}
2 changes: 1 addition & 1 deletion packages/create-vite/template-react-ts/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import ReactDOM from 'react-dom/client'
import App from './App.tsx'
import './index.css'

ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
<App />
</React.StrictMode>,
Expand Down
5 changes: 4 additions & 1 deletion packages/create-vite/template-react/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ module.exports = {
settings: { react: { version: '18.2' } },
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': 'warn',
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
}

0 comments on commit b18a72f

Please sign in to comment.