Skip to content

Commit

Permalink
chore: eslint config
Browse files Browse the repository at this point in the history
  • Loading branch information
wkylin committed Nov 6, 2024
1 parent d8cb5ae commit 0cefe9a
Show file tree
Hide file tree
Showing 29 changed files with 303 additions and 145 deletions.
9 changes: 9 additions & 0 deletions .cspell/custom-dictionary-workspace.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,27 @@
2
6
ACSS
adipisicing
amap
Amap
amet
Analyse
Bookstory
codepaths
consequuntur
Corrupti
CRACO
CWGNC
doloribus
elit
ENOENT
EPSG
fengian
fengxian
hookspath
Huksy
iclient
iure
jsencrypt
kend
lamina
Expand All @@ -28,6 +35,7 @@ premajor
preminor
prepatch
Qube
repellat
singleline
snyk
Snyk
Expand All @@ -36,4 +44,5 @@ supermapgis
teambit
treee
tsbuildinfo
voluptate
Windi
6 changes: 0 additions & 6 deletions .eslintignore

This file was deleted.

100 changes: 100 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import react from 'eslint-plugin-react'
import typescriptEslint from '@typescript-eslint/eslint-plugin'
import reactHooks from 'eslint-plugin-react-hooks'
import prettier from 'eslint-plugin-prettier'
import { fixupPluginRules } from '@eslint/compat'
import globals from 'globals'
import tsParser from '@typescript-eslint/parser'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import js from '@eslint/js'
import { FlatCompat } from '@eslint/eslintrc'

const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
})

export default [
{
ignores: ['node_modules/**/*', '**/CHANGELOG.md', '**/package-lock.json', 'dist/**/*', 'build/**/*', '**/coverage'],
},
...compat.extends('plugin:react/recommended', 'prettier'),
{
plugins: {
react,
'@typescript-eslint': typescriptEslint,
'react-hooks': fixupPluginRules(reactHooks),
prettier,
},

languageOptions: {
globals: {
...globals.browser,
},

parser: tsParser,
ecmaVersion: 12,
sourceType: 'module',

parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
},

settings: {
react: {
version: 'detect',
},
},

rules: {
'react-hooks/rules-of-hooks': 'error',
'react/display-name': 'off',
'react-hooks/exhaustive-deps': 'off',

'prettier/prettier': [
'error',
{
endOfLine: 'auto',
},
],

semi: 'off',
'no-use-before-define': 'off',
'comma-dangle': 'off',
'space-before-function-paren': 'off',
'multiline-ternary': 'off',
'promise/param-names': 'off',
'no-debugger': 'off',
'react/prop-types': 'off',
'no-extra-parens': 'off',
'eol-last': 'off',
'jsx-quotes': 'off',
'space-before-blocks': 'off',
'max-len': 'off',
strict: 'off',
'no-promise-executor-return': 'off',
'no-bitwise': 'off',
'no-return-assign': 'off',
'consistent-return': 'off',
'global-require': 'off',
'import/no-extraneous-dependencies': 'off',
'import/no-unresolved': 'off',
'no-console': 'off',
'import/extensions': 'off',
'no-nested-ternary': 'off',
'array-callback-return': 'off',
'no-shadow': 'off',
'no-inner-declarations': 'off',
'no-unused-expressions': 'off',
'no-unused-vars': 'off',
'no-plusplus': 'off',
},
},
]
66 changes: 46 additions & 20 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
"prettier:check": "prettier --check \"src/**/*\" --end-of-line auto --ignore-unknown",
"prettier:fix": "prettier --write \"src/**/*\" --end-of-line auto --ignore-unknown",
"prettier:fix:all": "prettier --write . --end-of-line auto --ignore-unknown",
"eslint": "eslint --cache --ext .js,.jsx,.ts,.tsx --format=pretty ./src",
"eslint:fix": "eslint --fix --cache --ext .js,.jsx,.ts,.tsx --format=pretty ./src",
"eslint": "eslint --cache",
"eslint:fix": "eslint --fix --cache",
"markdownlint": "markdownlint *.md",
"markdownlint:fix": "markdownlint --fix *.md",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
Expand Down Expand Up @@ -97,6 +97,9 @@
"@babel/runtime": "^7.25.7",
"@commitlint/cli": "^19.5.0",
"@commitlint/config-conventional": "^19.5.0",
"@eslint/compat": "^1.2.2",
"@eslint/eslintrc": "^3.1.0",
"@eslint/js": "^9.14.0",
"@js-analyzer/core": "^2.6.0",
"@js-analyzer/server": "^2.5.2",
"@koa/cors": "^5.0.0",
Expand Down Expand Up @@ -154,6 +157,7 @@
"fork-ts-checker-webpack-plugin": "^9.0.2",
"gh-pages": "^6.1.1",
"glob": "^11.0.0",
"globals": "^15.12.0",
"hashmark": "^5.0.0",
"html-minimizer-webpack-plugin": "^5.0.0",
"html-webpack-plugin": "^5.6.0",
Expand Down
2 changes: 1 addition & 1 deletion public/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
Expand Down
1 change: 0 additions & 1 deletion src/components/hooks/usePersistedState/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const usePersistedState = (defaultValue, localStorageKey) => {

useEffect(() => {
localStorage.setItem(localStorageKey, JSON.stringify(value))
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [value])

// Expose the value and the updater function.
Expand Down
1 change: 0 additions & 1 deletion src/components/hooks/usePollingEffect/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const usePollingEffect = (asyncCallback, dependencies = [], options = { interval
}
})()
return () => clearTimeout(timeoutIdRef.current)
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [...dependencies, asyncCallback, options.interval])
}

Expand Down
7 changes: 3 additions & 4 deletions src/components/hooks/useWebsocket/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ const useWebsocket = ({ url, verify }) => {
]
try {
ws.current = new WebSocket(url)
// eslint-disable-next-line @typescript-eslint/no-unused-vars

ws.current.onopen = () => setReadyState(stateArr[ws.current?.readyState ?? 0])
// eslint-disable-next-line @typescript-eslint/no-unused-vars

ws.current.onclose = () => {
setReadyState(stateArr[ws.current?.readyState ?? 0])
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars

ws.current.onerror = () => {
setReadyState(stateArr[ws.current?.readyState ?? 0])
}
Expand Down Expand Up @@ -64,7 +64,6 @@ const useWebsocket = ({ url, verify }) => {
return () => {
ws.current?.close()
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [ws, verify])

return {
Expand Down
2 changes: 0 additions & 2 deletions src/components/stateful/TreeList/utils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable no-plusplus */
/* eslint-disable no-underscore-dangle */
import React from 'react'

export function getDefaultKey(treeData) {
Expand Down
4 changes: 2 additions & 2 deletions src/components/stateless/AlternatingText/index.module.less
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
animation-duration: 1s;
animation-iteration-count: infinite;
animation-timing-function: ease;
background: linear-gradient(to right, #000000, #0f9b0f);
background: linear-gradient(to right, #000, #0f9b0f);
-webkit-text-fill-color: transparent;
-webkit-background-clip: text;
background-clip: text;
font-size: 20px;
font-weight: 700;
}
Expand Down
Loading

0 comments on commit 0cefe9a

Please sign in to comment.