Skip to content

Commit

Permalink
feat: add eslint config and test it
Browse files Browse the repository at this point in the history
  • Loading branch information
lgf-136 committed Sep 27, 2022
1 parent 5ffa11b commit a15a34c
Show file tree
Hide file tree
Showing 18 changed files with 1,637 additions and 79 deletions.
25 changes: 25 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# EditorConfig is awesome: http://EditorConfig.org
# 表示是最顶层的 EditorConfig 配置文件
root = true

[*] # 表示所有文件适用
charset = utf-8 # 设置文件字符集为 utf-8
indent_style = space # 缩进风格(tab | space)
indent_size = 2 # 缩进大小
end_of_line = lf # 控制换行类型(lf | cr | crlf)
trim_trailing_whitespace = true # 去除行首的任意空白字符
insert_final_newline = true # 始终在文件末尾插入一个新行


[*.md] # 表示仅 md 文件适用以下规则
max_line_length = off
trim_trailing_whitespace = false


[*.{js,jsx,ts,tsx,mjs,mjsx,cjs,cjsx,sh,rb}]
indent_size = 2
trim_trailing_whitespace = true

[*.{css,scss,less,html,hbs,ejs,json,code-workspace,yml,yaml,gql}]
indent_size = 2
trim_trailing_whitespace = true
4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.d.ts
**/node_modules
**/lib
**/dist
24 changes: 24 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

module.exports = {
extends: [ './config/eslint/react-ts.config' ],
rules: {
'@typescript-eslint/no-non-null-assertion': 0,
'func-style': 0,
'react/react-in-jsx-scope': 0,
'@typescript-eslint/no-var-requires': [ 0 ],
complexity: [ 'error', { max: 20 } ],
'no-multiple-empty-lines': [
'error',
{
max: 1,
maxBOF: 1,
maxEOF: 1,
},
],
},
settings: {},
plugins: [],
overrides: [],
// ignorePatterns: [ 'src/**/*.d.ts' ],
};

3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule ".vscode"]
path = .vscode
url = https://github.com/lgf-136/.vscode
[submodule "config"]
path = config
url = https://github.com/lgf-136/config
9 changes: 9 additions & 0 deletions .hintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": [
"development"
],
"hints": {
"disown-opener": "off",
"compat-api/css": "off"
}
}
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

monorepo-templates

pnpm install -D -w eslint typescript @typescript-eslint/eslint-plugin @typescript-eslint/parser vue-eslint-parser eslint-plugin-jsx-a11y eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-vue

## 子模块的添加

添加子模块非常简单,命令如下:
Expand Down
2 changes: 1 addition & 1 deletion apis/api-demo/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from "./src/api";
export * from './src/api';
2 changes: 1 addition & 1 deletion apis/api-demo/src/api.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
const api: string = "api";
const api = 'api';
console.log(api);
export default { api };
1 change: 1 addition & 0 deletions config
Submodule config added at 8453ae
18 changes: 9 additions & 9 deletions examples/react/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import { useState } from 'react'
import reactLogo from './assets/react.svg'
import './App.css'
import { useState } from 'react';
import reactLogo from './assets/react.svg';
import './App.css';

function App() {
const [count, setCount] = useState(0)
const [ count, setCount ] = useState(0);

return (
<div className="App">
<div>
<a href="https://vitejs.dev" target="_blank">
<a href="https://vitejs.dev" target="_blank" rel="noreferrer">
<img src="/vite.svg" className="logo" alt="Vite logo" />
</a>
<a href="https://reactjs.org" target="_blank">
<a href="https://reactjs.org" target="_blank" rel="noreferrer">
<img src={reactLogo} className="logo react" alt="React logo" />
</a>
</div>
<h1>Vite + React</h1>
<div className="card">
<button onClick={() => setCount((count) => count + 1)}>
<button onClick={() => setCount(count => count + 1)}>
count is {count}
</button>
<p>
Expand All @@ -28,7 +28,7 @@ function App() {
Click on the Vite and React logos to learn more
</p>
</div>
)
);
}

export default App
export default App;
16 changes: 7 additions & 9 deletions examples/react/src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import React from 'react'
import ReactDOM from 'react-dom/client'
import App from './App'
import './index.css'
import React from 'react';
import ReactDOM from 'react-dom/client';
import App from './App';
import './index.css';

ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
<React.StrictMode>
<App />
</React.StrictMode>
)
ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(<React.StrictMode>
<App />
</React.StrictMode>);
14 changes: 12 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,19 @@
},
"scripts": {
"commit": "git-cz",
"pull": "git pull && cd .vscode && git pull && cd .."
"dev:demo1": "cd projects/vite-project && pnpm install && pnpm dev",
"pull": "git pull && cd .vscode && git pull && cd .. && cd config && git pull && cd .."
},
"devDependencies": {
"vite": "^3.1.3"
"@typescript-eslint/eslint-plugin": "^5.38.1",
"@typescript-eslint/parser": "^5.38.1",
"eslint": "^8.24.0",
"eslint-plugin-jsx-a11y": "^6.6.1",
"eslint-plugin-react": "^7.31.8",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-vue": "^9.5.1",
"typescript": "^4.6.4",
"vite": "^3.1.3",
"vue-eslint-parser": "^9.1.0"
}
}
2 changes: 1 addition & 1 deletion packages/shared/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from "./src";
export * from './src';
2 changes: 1 addition & 1 deletion packages/shared/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
const corePackage: string = "corePackage";
const corePackage = 'corePackage';
export default { corePackage };
Loading

0 comments on commit a15a34c

Please sign in to comment.