File tree Expand file tree Collapse file tree 19 files changed +582
-0
lines changed
Expand file tree Collapse file tree 19 files changed +582
-0
lines changed Original file line number Diff line number Diff line change 1+ ! .eslintrc.js
2+ ! .prettierrc.js
3+
4+ node_modules /
5+ .DS_Store
6+ yarn.lock
7+ yarn-error.log
Original file line number Diff line number Diff line change 1+ module . exports = {
2+ root : true ,
3+ extends : [ './typescript.js' ] ,
4+ rules : {
5+ '@typescript-eslint/no-var-requires' : 'off' ,
6+ } ,
7+ } ;
Original file line number Diff line number Diff line change 1+ node_modules
2+ .DS_Store
3+
4+ package-lock.json
5+ yarn.lock
6+ yarn-error.log
Original file line number Diff line number Diff line change 1+ node_modules /
2+ .DS_Store
3+ yarn.lock
4+ yarn-error.log
5+
6+ * ignore
Original file line number Diff line number Diff line change 1+ module . exports = {
2+ // 一行最多 120 字符
3+ printWidth : 120 ,
4+ // 使用 2 个空格缩进
5+ tabWidth : 2 ,
6+ // 不使用缩进符,而使用空格
7+ useTabs : false ,
8+ // 行尾需要有分号
9+ semi : true ,
10+ // 使用单引号
11+ singleQuote : true ,
12+ // 对象的 key 仅在必要时用引号
13+ quoteProps : 'as-needed' ,
14+ // jsx 不使用单引号,而使用双引号
15+ jsxSingleQuote : false ,
16+ // 末尾需要有逗号
17+ trailingComma : 'all' ,
18+ // 大括号内的首尾需要空格
19+ bracketSpacing : true ,
20+ // jsx 标签的反尖括号需要换行
21+ jsxBracketSameLine : false ,
22+ // 箭头函数,只有一个参数的时候,也需要括号
23+ arrowParens : 'always' ,
24+ // 每个文件格式化的范围是文件的全部内容
25+ rangeStart : 0 ,
26+ rangeEnd : Infinity ,
27+ // 不需要写文件开头的 @prettier
28+ requirePragma : false ,
29+ // 不需要自动在文件开头插入 @prettier
30+ insertPragma : false ,
31+ // 使用默认的折行标准
32+ proseWrap : 'preserve' ,
33+ // 根据显示样式决定 html 要不要折行
34+ htmlWhitespaceSensitivity : 'css' ,
35+ // vue 文件中的 script 和 style 内不用缩进
36+ vueIndentScriptAndStyle : false ,
37+ // 换行符使用 lf
38+ endOfLine : 'lf' ,
39+ } ;
Original file line number Diff line number Diff line change 1+ {
2+ "files.eol" : " \n " ,
3+ "editor.tabSize" : 2 ,
4+ "editor.formatOnSave" : true ,
5+ "editor.defaultFormatter" : " esbenp.prettier-vscode" ,
6+ "eslint.validate" : [
7+ " javascript" ,
8+ " javascriptreact" ,
9+ " vue" ,
10+ " typescript" ,
11+ " typescriptreact"
12+ ],
13+ "editor.codeActionsOnSave" : {
14+ "source.fixAll.eslint" : true
15+ },
16+ "typescript.tsdk" : " node_modules/typescript/lib"
17+ }
Original file line number Diff line number Diff line change 11# eslint-config-tdesign
22ESLint config for TDesign
3+
4+ > Tips: 规则有优先级,注意 ` extends ` 中的顺序
5+ > 1 . 如果 ` extends ` 配置的是一个数组,那么最终会将所有规则项进行合并,出现冲突的时候,后面的会覆盖前面的。
6+ > 2 . 通过 ` rules ` 单独配置的规则,优先级高于 ` extends ` 。
7+
8+
9+ ## Base Usage
10+ ### Installation
11+ ``` sh
12+ npm i eslint eslint-config-airbnb-base eslint-plugin-tdesign --save-dev
13+ ```
14+ ### Use
15+ ``` json
16+ // .eslintrc.js
17+ {
18+ "extends" : [
19+ " tdesign"
20+ ]
21+ }
22+ ```
23+
24+ ## Miniprogram Usage
25+ ### Installation
26+ ``` sh
27+ npm i eslint eslint-config-airbnb-base eslint-config-prettier eslint-plugin-import eslint-plugin-tdesign --save-dev
28+ ```
29+ ### Use
30+ ``` json
31+ // .eslintrc.js
32+ {
33+ "extends" : [
34+ " tdesign" ,
35+ " tdesign/miniprogram"
36+ ]
37+ }
38+ ```
39+
40+ ## TypeScript Usage
41+ ### Installation
42+ ``` sh
43+ npm install eslint typescript eslint-config-airbnb-base @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-plugin-tdesign --save-dev
44+ ```
45+ ### Use
46+ ``` json
47+ // .eslintrc.js
48+ {
49+ "extends" : [
50+ " tdesign" ,
51+ " tdesign/typescript"
52+ ]
53+ }
54+ ```
55+
56+ ## Vue Usage
57+ ### Installation
58+ ``` sh
59+ npm i eslint eslint-config-airbnb-base eslint-config-prettier vue-eslint-parser eslint-plugin-vue @vue/eslint-config-typescript eslint-plugin-tdesign --save-dev
60+ ```
61+ ### Use
62+ ``` json
63+ // .eslintrc.js
64+ {
65+ "extends" : [
66+ " tdesign" ,
67+ " tdesign/vue"
68+ ]
69+ }
70+ ```
71+ ## Vue-next Usage
72+ ### Installation
73+ ``` sh
74+ npm i eslint eslint-config-airbnb-base eslint-config-prettier vue-eslint-parser eslint-plugin-vue eslint-plugin-tdesign --save-dev
75+ ```
76+ ### Use
77+ ``` json
78+ // .eslintrc.js
79+ {
80+ "extends" : [
81+ " tdesign" ,
82+ " tdesign/vue-next"
83+ ]
84+ }
85+ ```
86+
87+ ## React Usage
88+ ### Installation
89+ ``` sh
90+ npm i eslint prettier eslint-config-airbnb-base eslint-config-prettier eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-lodash eslint-plugin-tdesign --save-dev
91+ ```
92+ ### Use
93+ ``` json
94+ // .eslintrc.js
95+ {
96+ "extends" : [
97+ " tdesign" ,
98+ " tdesign/react"
99+ ]
100+ }
101+ ```
102+
103+ ## TypeScript React Usage
104+ ### Installation
105+ ``` sh
106+ npm install eslint typescript eslint-config-airbnb-base eslint-config-prettier @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-plugin-react eslint-plugin-tdesign --save-dev
107+ ```
108+ ### Use
109+ ``` json
110+ // .eslintrc.js
111+ {
112+ "extends" : [
113+ " tdesign" ,
114+ " tdesign/typescript" ,
115+ " tdesign/react" ,
116+ ]
117+ }
118+ ```
Original file line number Diff line number Diff line change 1+ const javascriptRule = require ( './rules/javascript' ) ;
2+
3+ module . exports = {
4+ root : true ,
5+ extends : [ 'eslint-config-airbnb-base' ] ,
6+ parserOptions : {
7+ ecmaVersion : 2019 ,
8+ sourceType : 'module' ,
9+ allowImportExportEverywhere : true ,
10+ ecmaFeatures : {
11+ impliedStrict : true ,
12+ jsx : true ,
13+ } ,
14+ } ,
15+ env : {
16+ browser : true ,
17+ node : true ,
18+ es6 : true ,
19+ jest : true ,
20+ } ,
21+ rules : {
22+ ...javascriptRule ,
23+ } ,
24+ } ;
Original file line number Diff line number Diff line change 1+ module . exports = {
2+ extends : [ './base.js' ] ,
3+ } ;
Original file line number Diff line number Diff line change 1+ module . exports = {
2+ extends : [ 'plugin:prettier/recommended' ] ,
3+ plugins : [ 'import' ] ,
4+ globals : {
5+ require : true ,
6+ Page : true ,
7+ wx : true ,
8+ App : true ,
9+ getApp : true ,
10+ getCurrentPages : true ,
11+ Component : true ,
12+ getRegExp : true ,
13+ Behavior : true ,
14+ } ,
15+ rules : { } ,
16+ overrides : [
17+ {
18+ files : [ 'script/**' ] ,
19+ rules : {
20+ // node 环境下支持 require
21+ '@typescript-eslint/no-require-imports' : 'off' ,
22+ } ,
23+ } ,
24+ {
25+ files : [ 'example/**' ] ,
26+ rules : {
27+ 'no-console' : 0 ,
28+ } ,
29+ } ,
30+ ] ,
31+ } ;
You can’t perform that action at this time.
0 commit comments