ko-lint-config 0.0.9 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.eslintrc.js CHANGED
@@ -1,190 +1,198 @@
1
1
  module.exports = {
2
- root: true, // 默认情况下,ESLint 会在所有父级目录里寻找配置文件,一直到根目录。如果发现配置文件中有 “root”: true,它就会停止在父级目录中寻找。
3
- parser: '@typescript-eslint/parser',
4
- parserOptions: {
5
- ecmaVersion: 8, // 支持es8语法,但并不意味着同时支持新的 ES8 全局变量或类型
6
- sourceType: 'module', // 指定来源的类型,"script" (默认) 或 "module"(如果你的代码是 ECMAScript 模块)
7
- // "project": "./tsconfig.json",
8
- // 使用的额外的语言特性
9
- ecmaFeatures: {
10
- jsx: true, // 启用 jsx
11
- tsx: true, // 启用 tsx
12
- globalReturn: true, // 允许在全局作用域下使用 return 语句
13
- impliedStrict: true, // 启用全局 strict mode (如果 ecmaVersion 是 5 或更高)
14
- },
2
+ root: true, // 默认情况下,ESLint 会在所有父级目录里寻找配置文件,一直到根目录。如果发现配置文件中有 “root”: true,它就会停止在父级目录中寻找。
3
+ parser: '@typescript-eslint/parser',
4
+ parserOptions: {
5
+ ecmaVersion: 8, // 支持es8语法,但并不意味着同时支持新的 ES8 全局变量或类型
6
+ sourceType: 'module', // 指定来源的类型,"script" (默认) 或 "module"(如果你的代码是 ECMAScript 模块)
7
+ // "project": "./tsconfig.json",
8
+ // 使用的额外的语言特性
9
+ ecmaFeatures: {
10
+ jsx: true, // 启用 jsx
11
+ tsx: true, // 启用 tsx
12
+ globalReturn: true, // 允许在全局作用域下使用 return 语句
13
+ impliedStrict: true, // 启用全局 strict mode (如果 ecmaVersion 是 5 或更高)
15
14
  },
16
- settings: {
17
- react: {
18
- pragma: 'React',
19
- version: '16.6.3',
20
- },
15
+ },
16
+ settings: {
17
+ react: {
18
+ pragma: 'React',
19
+ version: '16.6.3',
21
20
  },
22
- env: {
23
- es6: true, // 启用 ES6 语法支持以及新的 ES6 全局变量或类型
24
- node: true, // Node.js 全局变量和 Node.js 作用域
25
- browser: true, // 浏览器全局变量
26
- },
27
- extends: [
28
- 'standard',
29
- 'eslint:recommended',
30
- 'plugin:react/recommended',
31
- 'plugin:react-hooks/recommended',
32
- 'plugin:@typescript-eslint/recommended',
33
- ],
34
- plugins: ['import', 'react', 'jsx-a11y', 'react-hooks', 'dt-react'],
35
- globals: {
36
- expect: 'readonly',
37
- test: 'readonly',
38
- describe: 'readonly',
39
- beforeEach: 'readonly',
40
- afterEach: 'readonly',
41
- jest: 'readonly',
42
- },
43
- // "off" 或 0 - 关闭规则
44
- // "warn" 或 1 - 开启规则,使用警告级别的错误:warn (不会导致程序退出)
45
- // "error" 或 2 - 开启规则,使用错误级别的错误:error (当被触发的时候,程序会退出)
46
- rules: {
47
- semi: 0,
48
- strict: 0,
49
- indent: [
50
- // 缩进
51
- 2,
52
- 4,
53
- {
54
- SwitchCase: 1, // 指定 switch-case 语句的缩进级别
55
- VariableDeclarator: 1, // 指定 var 变量声明语句的缩进级别
56
- outerIIFEBody: 1, // 指定 IIFE(立即调用的函数表达式)的缩进级别
57
- MemberExpression: 1, // 指定多行属性链的缩进级别
58
- FunctionDeclaration: { parameters: 1, body: 1 }, // 通过传入一个对象来指定函数声明的缩进规则
59
- FunctionExpression: { parameters: 1, body: 1 },
60
- CallExpression: { arguments: 1 }, // 通过传入一个对象来指定函数调用表达式的缩进规则
61
- ArrayExpression: 1, // 指定数组中的元素的缩进级别
62
- ObjectExpression: 1, // 指定对象中的属性的缩进级别
63
- ImportDeclaration: 1, // 指定 import 语句的缩进级别
64
- flatTernaryExpressions: false, // 指定是否需要缩进嵌套在其他三元表达式中的三元表达式
65
- ignoreComments: false, // 指定注释是否需要需要与前一行或下一行的节点对齐
66
- ignoredNodes: [
67
- 'TemplateLiteral *',
68
- 'JSXElement',
69
- 'JSXElement > *',
70
- 'JSXAttribute',
71
- 'JSXIdentifier',
72
- 'JSXNamespacedName',
73
- 'JSXMemberExpression',
74
- 'JSXSpreadAttribute',
75
- 'JSXExpressionContainer',
76
- 'JSXOpeningElement',
77
- 'JSXClosingElement',
78
- 'JSXFragment',
79
- 'JSXOpeningFragment',
80
- 'JSXClosingFragment',
81
- 'JSXText',
82
- 'JSXEmptyExpression',
83
- 'JSXSpreadChild',
84
- ],
85
- offsetTernaryExpressions: true,
86
- },
21
+ },
22
+ env: {
23
+ es6: true, // 启用 ES6 语法支持以及新的 ES6 全局变量或类型
24
+ node: true, // Node.js 全局变量和 Node.js 作用域
25
+ browser: true, // 浏览器全局变量
26
+ },
27
+ extends: [
28
+ 'standard',
29
+ 'eslint:recommended',
30
+ 'plugin:react/recommended',
31
+ 'plugin:react-hooks/recommended',
32
+ 'plugin:@typescript-eslint/recommended',
33
+ ],
34
+ plugins: ['import', 'react', 'jsx-a11y', 'react-hooks', 'dt-react'],
35
+ globals: {
36
+ expect: 'readonly',
37
+ test: 'readonly',
38
+ describe: 'readonly',
39
+ beforeEach: 'readonly',
40
+ afterEach: 'readonly',
41
+ jest: 'readonly',
42
+ },
43
+ // "off" 或 0 - 关闭规则
44
+ // "warn" 或 1 - 开启规则,使用警告级别的错误:warn (不会导致程序退出)
45
+ // "error" 或 2 - 开启规则,使用错误级别的错误:error (当被触发的时候,程序会退出)
46
+ rules: {
47
+ semi: 0,
48
+ strict: 0,
49
+ indent: [
50
+ // 缩进
51
+ 2,
52
+ 4,
53
+ {
54
+ SwitchCase: 1, // 指定 switch-case 语句的缩进级别
55
+ VariableDeclarator: 1, // 指定 var 变量声明语句的缩进级别
56
+ outerIIFEBody: 1, // 指定 IIFE(立即调用的函数表达式)的缩进级别
57
+ MemberExpression: 1, // 指定多行属性链的缩进级别
58
+ FunctionDeclaration: { parameters: 1, body: 1 }, // 通过传入一个对象来指定函数声明的缩进规则
59
+ FunctionExpression: { parameters: 1, body: 1 },
60
+ CallExpression: { arguments: 1 }, // 通过传入一个对象来指定函数调用表达式的缩进规则
61
+ ArrayExpression: 1, // 指定数组中的元素的缩进级别
62
+ ObjectExpression: 1, // 指定对象中的属性的缩进级别
63
+ ImportDeclaration: 1, // 指定 import 语句的缩进级别
64
+ flatTernaryExpressions: false, // 指定是否需要缩进嵌套在其他三元表达式中的三元表达式
65
+ ignoreComments: false, // 指定注释是否需要需要与前一行或下一行的节点对齐
66
+ ignoredNodes: [
67
+ 'TemplateLiteral *',
68
+ 'JSXElement',
69
+ 'JSXElement > *',
70
+ 'JSXAttribute',
71
+ 'JSXIdentifier',
72
+ 'JSXNamespacedName',
73
+ 'JSXMemberExpression',
74
+ 'JSXSpreadAttribute',
75
+ 'JSXExpressionContainer',
76
+ 'JSXOpeningElement',
77
+ 'JSXClosingElement',
78
+ 'JSXFragment',
79
+ 'JSXOpeningFragment',
80
+ 'JSXClosingFragment',
81
+ 'JSXText',
82
+ 'JSXEmptyExpression',
83
+ 'JSXSpreadChild',
87
84
  ],
88
- eqeqeq: 0,
89
- 'arrow-body-style': 0, // 控制箭头函数的语法形式
90
- 'comma-dangle': [2, 'only-multiline'], // 当最后一个元素或属性与结束或属性位于不同的行时,允许但不要求尾随逗号
91
- 'lines-between-class-members': 0, // 方法间是否空行间隔开
92
- 'space-before-function-paren': [
93
- // 函数括号前的空格
94
- 2,
95
- {
96
- anonymous: 'always', // 匿名函数表达式,例如 function () {}
97
- named: 'never', // 命名函数表达式,例如 function foo () {}
98
- asyncArrow: 'always', // 异步箭头函数表达式,例如 async () => {}
99
- },
100
- ],
101
- 'one-var': 0, // 可同时定义多个变量,逗号隔开
102
- 'dot-notation': 0, // 允许方括号表示法 foo['bar']
103
- 'multiline-ternary': 0, // 三元运算符不强制换行
104
- 'prefer-regex-literals': 0, // 正则的构造函数
105
- 'prefer-promise-reject-errors': 0, // reject 仅接收 Error 对象
85
+ offsetTernaryExpressions: true,
86
+ },
87
+ ],
88
+ eqeqeq: 0,
89
+ 'arrow-body-style': 0, // 控制箭头函数的语法形式
90
+ 'comma-dangle': [2, 'only-multiline'], // 当最后一个元素或属性与结束或属性位于不同的行时,允许但不要求尾随逗号
91
+ 'lines-between-class-members': 0, // 方法间是否空行间隔开
92
+ 'space-before-function-paren': [
93
+ // 函数括号前的空格
94
+ 2,
95
+ {
96
+ anonymous: 'always', // 匿名函数表达式,例如 function () {}
97
+ named: 'never', // 命名函数表达式,例如 function foo () {}
98
+ asyncArrow: 'always', // 异步箭头函数表达式,例如 async () => {}
99
+ },
100
+ ],
101
+ 'one-var': 0, // 可同时定义多个变量,逗号隔开
102
+ 'dot-notation': 0, // 允许方括号表示法 foo['bar']
103
+ 'multiline-ternary': 0, // 三元运算符不强制换行
104
+ 'prefer-regex-literals': 0, // 正则的构造函数
105
+ 'prefer-promise-reject-errors': 0, // reject 仅接收 Error 对象
106
106
 
107
- 'no-mixed-operators': 0, // 允许混合使用不同的运算符
108
- 'no-return-assign': 0, // return 的代码中有运算
109
- 'no-useless-constructor': 0, // 空构造函数
110
- 'no-console': 0,
111
- 'no-debugger': 2,
112
- 'no-param-reassign': 2, // 给函数的入参赋值
113
- 'no-use-before-define': 0, // 使用尚未声明的变量
107
+ 'no-mixed-operators': 0, // 允许混合使用不同的运算符
108
+ 'no-return-assign': 0, // return 的代码中有运算
109
+ 'no-useless-constructor': 0, // 空构造函数
110
+ 'no-console': 0,
111
+ 'no-debugger': 2,
112
+ 'no-param-reassign': 2, // 给函数的入参赋值
113
+ 'no-use-before-define': 0, // 使用尚未声明的变量
114
114
 
115
- // 控制是否可以使用没有在 package.json 内 dependencies, devDependencies, optionalDependencies, peerDependencies, bundledDependencies 中声明的扩展模块
116
- 'import/no-extraneous-dependencies': 0,
115
+ // 控制是否可以使用没有在 package.json 内 dependencies, devDependencies, optionalDependencies, peerDependencies, bundledDependencies 中声明的扩展模块
116
+ 'import/no-extraneous-dependencies': [
117
+ 2,
118
+ {
119
+ devDependencies: false,
120
+ optionalDependencies: false,
121
+ peerDependencies: false,
122
+ packageDir: [process.cwd()], //TODO: should include sub directory package.json
123
+ },
124
+ ],
117
125
 
118
- /**
119
- * 是否强制组件中的方法顺序,顺序如下:
120
- * 1、静态方法和属性
121
- * 2、生命周期方法:displayName, propTypes, contextTypes, childContextTypes, mixins, statics, defaultProps, constructor, getDefaultProps, state, getInitialState, getChildContext, getDerivedStateFromProps, componentWillMount, UNSAFE_componentWillMount, componentDidMount, componentWillReceiveProps, UNSAFE_componentWillReceiveProps, shouldComponentUpdate, componentWillUpdate, UNSAFE_componentWillUpdate, getSnapshotBeforeUpdate, componentDidUpdate, componentDidCatch, componentWillUnmount(按此顺序)。
122
- * 3、自定义方法
123
- * 4、render方法
124
- */
125
- 'react/sort-comp': 0,
126
- 'react/display-name': [0],
127
- 'react/jsx-uses-react': 1, // 防止 require('react') 被 JSX 语法错误的标记为未使用
128
- 'react/prefer-stateless-function': 0, // 是否强制将无状态的 React 组件编写为纯函数
129
- 'react/jsx-closing-bracket-location': 0, // 验证 JSX 中右括号的位置是否与开始标签对齐
130
- 'react/prop-types': [0, { ignore: ['children'] }], // 验证 React 组件中是否缺少 Props 属性
131
- 'react/jsx-filename-extension': [
132
- 1,
133
- { extensions: ['.tsx', '.js', '.jsx'] },
134
- ],
135
- 'react/react-in-jsx-scope': 0,
136
- 'react/jsx-closing-tag-location': 0,
137
- 'react/jsx-boolean-value': [1, 'never'],
138
- 'react-hooks/rules-of-hooks': 2,
139
- 'react-hooks/exhaustive-deps': 0,
126
+ /**
127
+ * 是否强制组件中的方法顺序,顺序如下:
128
+ * 1、静态方法和属性
129
+ * 2、生命周期方法:displayName, propTypes, contextTypes, childContextTypes, mixins, statics, defaultProps, constructor, getDefaultProps, state, getInitialState, getChildContext, getDerivedStateFromProps, componentWillMount, UNSAFE_componentWillMount, componentDidMount, componentWillReceiveProps, UNSAFE_componentWillReceiveProps, shouldComponentUpdate, componentWillUpdate, UNSAFE_componentWillUpdate, getSnapshotBeforeUpdate, componentDidUpdate, componentDidCatch, componentWillUnmount(按此顺序)。
130
+ * 3、自定义方法
131
+ * 4、render方法
132
+ */
133
+ 'react/sort-comp': 0,
134
+ 'react/display-name': [0],
135
+ 'react/jsx-uses-react': 1, // 防止 require('react') 被 JSX 语法错误的标记为未使用
136
+ 'react/prefer-stateless-function': 0, // 是否强制将无状态的 React 组件编写为纯函数
137
+ 'react/jsx-closing-bracket-location': 0, // 验证 JSX 中右括号的位置是否与开始标签对齐
138
+ 'react/prop-types': [0, { ignore: ['children'] }], // 验证 React 组件中是否缺少 Props 属性
139
+ 'react/jsx-filename-extension': [
140
+ 1,
141
+ { extensions: ['.tsx', '.js', '.jsx'] },
142
+ ],
143
+ 'react/react-in-jsx-scope': 0,
144
+ 'react/jsx-closing-tag-location': 0,
145
+ 'react/jsx-boolean-value': [1, 'never'],
146
+ 'react-hooks/rules-of-hooks': 2,
147
+ 'react-hooks/exhaustive-deps': 0,
140
148
 
141
- 'jsx-quotes': 1,
142
- 'dt-react/jsx-closing-bracket-location': [1, 'line-aligned'],
143
- 'dt-react/jsx-tag-spacing': [
144
- 2,
145
- {
146
- closingSlash: 'never',
147
- beforeSelfClosing: 'always',
148
- // beforeSelfClosing: 'proportional-always',
149
- beforeClosing: 'proportional-always',
150
- },
151
- ],
152
- 'dt-react/jsx-wrap-multilines': 1,
153
- 'dt-react/self-closing-comp': [
154
- 1,
155
- {
156
- component: true,
157
- html: false,
158
- },
159
- ],
149
+ 'jsx-quotes': 1,
150
+ 'dt-react/jsx-closing-bracket-location': [1, 'line-aligned'],
151
+ 'dt-react/jsx-tag-spacing': [
152
+ 2,
153
+ {
154
+ closingSlash: 'never',
155
+ beforeSelfClosing: 'always',
156
+ // beforeSelfClosing: 'proportional-always',
157
+ beforeClosing: 'proportional-always',
158
+ },
159
+ ],
160
+ 'dt-react/jsx-wrap-multilines': 1,
161
+ 'dt-react/self-closing-comp': [
162
+ 1,
163
+ {
164
+ component: true,
165
+ html: false,
166
+ },
167
+ ],
160
168
 
161
- 'jsx-a11y/no-static-element-interactions': 0,
169
+ 'jsx-a11y/no-static-element-interactions': 0,
162
170
 
163
- '@typescript-eslint/no-unused-vars': [
164
- 2,
165
- { vars: 'all', args: 'none', ignoreRestSiblings: false },
166
- ],
167
- '@typescript-eslint/no-explicit-any': 0,
168
- '@typescript-eslint/explicit-member-accessibility': 0,
169
- '@typescript-eslint/explicit-function-return-type': 0,
170
- '@typescript-eslint/no-use-before-define': 0,
171
- '@typescript-eslint/no-var-requires': 0,
172
- '@typescript-eslint/interface-name-prefix': 0,
173
- '@typescript-eslint/no-empty-interface': 0,
174
- '@typescript-eslint/ban-types': 0,
175
- '@typescript-eslint/no-empty-function': 0, // 允许函数内容为空
176
- '@typescript-eslint/no-this-alias': [
177
- // 允许 this 别名
178
- 2,
179
- {
180
- allowDestructuring: false, // 不允许从 this 中解构,默认值 true
181
- allowedNames: ['self', '_this', 'that'], // 允许别名,默认值 []
182
- },
183
- ],
171
+ '@typescript-eslint/no-unused-vars': [
172
+ 2,
173
+ { vars: 'all', args: 'none', ignoreRestSiblings: false },
174
+ ],
175
+ '@typescript-eslint/no-explicit-any': 0,
176
+ '@typescript-eslint/explicit-member-accessibility': 0,
177
+ '@typescript-eslint/explicit-function-return-type': 0,
178
+ '@typescript-eslint/no-use-before-define': 0,
179
+ '@typescript-eslint/no-var-requires': 0,
180
+ '@typescript-eslint/interface-name-prefix': 0,
181
+ '@typescript-eslint/no-empty-interface': 0,
182
+ '@typescript-eslint/ban-types': 0,
183
+ '@typescript-eslint/no-empty-function': 0, // 允许函数内容为空
184
+ '@typescript-eslint/no-this-alias': [
185
+ // 允许 this 别名
186
+ 2,
187
+ {
188
+ allowDestructuring: false, // 不允许从 this 中解构,默认值 true
189
+ allowedNames: ['self', '_this', 'that'], // 允许别名,默认值 []
190
+ },
191
+ ],
184
192
 
185
- 'standard/object-curly-even-spacing': 0,
186
- // standard 要求 callback 内的值不为具体值
187
- 'standard/no-callback-literal': 0,
188
- 'n/no-callback-literal': 0,
189
- },
193
+ 'standard/object-curly-even-spacing': 0,
194
+ // standard 要求 callback 内的值不为具体值
195
+ 'standard/no-callback-literal': 0,
196
+ 'n/no-callback-literal': 0,
197
+ },
190
198
  };
package/.prettierrc.js CHANGED
@@ -1,10 +1,10 @@
1
1
  module.exports = {
2
- semi: true, // 行末添加分号
3
- tabWidth: 4, // tab 缩进,默认 2
4
- printWidth: 80, // 换行长度,默认 80
5
- singleQuote: true, // 单引号
6
- useTabs: false, // 使用 tab 缩进,默认 false 使用空格
7
- bracketSpacing: true, // 对象中打印空格 默认 true
8
- arrowParens: 'always', // 箭头函数参数括号 可选 avoid(一个参数时省略) | always
9
- trailingComma: 'es5', // 尾逗号 可选 none | es5 | all
2
+ semi: true, // 行末添加分号
3
+ tabWidth: 4, // tab 缩进,默认 2
4
+ printWidth: 80, // 换行长度,默认 80
5
+ singleQuote: true, // 单引号
6
+ useTabs: false, // 使用 tab 缩进,默认 false 使用空格
7
+ bracketSpacing: true, // 对象中打印空格 默认 true
8
+ arrowParens: 'always', // 箭头函数参数括号 可选 avoid(一个参数时省略) | always
9
+ trailingComma: 'es5', // 尾逗号 可选 none | es5 | all
10
10
  };
package/.stylelintrc.js CHANGED
@@ -1,29 +1,29 @@
1
1
  module.exports = {
2
- files: ['**/*.css', '**/*.scss'],
3
- customSyntax: require.resolve('postcss-scss'),
4
- extends: 'stylelint-config-standard',
5
- plugins: ['stylelint-order', 'stylelint-scss'],
6
- rules: {
7
- // null 为关闭规则
8
- indentation: 4, // 缩进4格
9
- 'declaration-empty-line-before': 'never', // 第一条属性声明前不允许有空行
10
- 'selector-class-pattern': '[a-zA-Z]+', // className 的大小写
11
- // 规则之前的空行
12
- 'rule-empty-line-before': [
13
- 'always',
14
- {
15
- except: ['inside-block', 'first-nested', 'after-single-line-comment'],
16
- },
17
- ],
18
- 'alpha-value-notation': 'number', // 小数显示数字(number)或百分数(percentage)
19
- 'color-function-notation': 'legacy', // 颜色 rgba 等使用传统逗号隔开
20
- 'color-hex-case': 'upper', // 颜色十六进制字符大写
21
- 'selector-list-comma-newline-after': 'always-multi-line',
22
- 'max-line-length': 300, // 最大宽度
23
- 'font-family-no-missing-generic-family-keyword': null, // 是否必须包含通用字体
24
- 'no-descending-specificity': null, // 选择器顺序
25
- 'keyframes-name-pattern': null, // keyframes 推荐小写+连字符命名
26
- 'no-empty-source': null, // 空文件
27
- 'block-no-empty': null, // 空规则
28
- },
2
+ files: ['**/*.css', '**/*.scss'],
3
+ customSyntax: require.resolve('postcss-scss'),
4
+ extends: 'stylelint-config-standard',
5
+ plugins: ['stylelint-order', 'stylelint-scss'],
6
+ rules: {
7
+ // null 为关闭规则
8
+ indentation: 4, // 缩进4格
9
+ 'declaration-empty-line-before': 'never', // 第一条属性声明前不允许有空行
10
+ 'selector-class-pattern': '[a-zA-Z]+', // className 的大小写
11
+ // 规则之前的空行
12
+ 'rule-empty-line-before': [
13
+ 'always',
14
+ {
15
+ except: ['inside-block', 'first-nested', 'after-single-line-comment'],
16
+ },
17
+ ],
18
+ 'alpha-value-notation': 'number', // 小数显示数字(number)或百分数(percentage)
19
+ 'color-function-notation': 'legacy', // 颜色 rgba 等使用传统逗号隔开
20
+ 'color-hex-case': 'upper', // 颜色十六进制字符大写
21
+ 'selector-list-comma-newline-after': 'always-multi-line',
22
+ 'max-line-length': 300, // 最大宽度
23
+ 'font-family-no-missing-generic-family-keyword': null, // 是否必须包含通用字体
24
+ 'no-descending-specificity': null, // 选择器顺序
25
+ 'keyframes-name-pattern': null, // keyframes 推荐小写+连字符命名
26
+ 'no-empty-source': null, // 空文件
27
+ 'block-no-empty': null, // 空规则
28
+ },
29
29
  };
package/CHANGELOG.md ADDED
@@ -0,0 +1,20 @@
1
+ # ko-lint-config
2
+
3
+ ## 2.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - acb01e3e: update package.json config to include config files
8
+
9
+ ## 2.0.0
10
+
11
+ ### Major Changes
12
+
13
+ - e854ccd8: 1. add new plugin:eslint-plugin-dt-react
14
+ 2. update eslint & prettier configs
15
+
16
+ ## 1.0.0
17
+
18
+ ### Major Changes
19
+
20
+ - 84adca00: publish ko v6.0 and it's related packages
package/index.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export * as prettier from 'prettier';
2
+ export * as eslint from 'eslint';
3
+ export * as stylelint from 'stylelint';
package/index.js CHANGED
@@ -1 +1,9 @@
1
- module.exports = require('./.eslintrc')
1
+ const prettier = require('prettier');
2
+ const eslint = require('eslint');
3
+ const stylelint = require('stylelint');
4
+
5
+ module.exports = {
6
+ prettier,
7
+ eslint,
8
+ stylelint,
9
+ };
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "ko-lint-config",
3
- "version": "0.0.9",
3
+ "version": "2.0.1",
4
4
  "description": "lint configs about eslint stylelint and prettier",
5
5
  "main": "index.js",
6
- "scripts": {
7
- "lint": "eslint .",
8
- "test": "tape test/*.js"
9
- },
6
+ "files": [
7
+ "**/*",
8
+ "!test/**/*"
9
+ ],
10
+ "typings": "index.d.ts",
10
11
  "keywords": [
11
12
  "code style",
12
13
  "eslint",
@@ -20,10 +21,11 @@
20
21
  },
21
22
  "repository": {
22
23
  "type": "git",
23
- "url": "https://github.com/DTStack/ko"
24
+ "url": "https://github.com/DTStack/ko",
25
+ "directory": "packages/ko-lint-config"
24
26
  },
25
27
  "homepage": "https://github.com/DTStack/ko",
26
- "author": "",
28
+ "author": "DTStack",
27
29
  "license": "MIT",
28
30
  "dependencies": {
29
31
  "@typescript-eslint/eslint-plugin": "^5.18.0",
@@ -41,6 +43,7 @@
41
43
  "eslint-plugin-sort-requires": "^2.1.0",
42
44
  "postcss": "^8.4.12",
43
45
  "postcss-scss": "^4.0.3",
46
+ "prettier": "^2.6.2",
44
47
  "stylelint": "^14.7.1",
45
48
  "stylelint-config-standard": "^25.0.0",
46
49
  "stylelint-order": "^5.0.0",
@@ -51,6 +54,11 @@
51
54
  "typescript": "^4.6.3"
52
55
  },
53
56
  "engines": {
54
- "node": "^12.22.0 || ^14.17.0 || >=16.0.0"
55
- }
56
- }
57
+ "node": ">=14"
58
+ },
59
+ "scripts": {
60
+ "lint": "eslint .",
61
+ "test": "tape test/*.js"
62
+ },
63
+ "readme": "# [ko-lint-config] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url]\n\n[npm-image]: https://img.shields.io/npm/v/ko-lint-config.svg\n[npm-url]: https://npmjs.org/package/ko-lint-config\n[downloads-image]: https://img.shields.io/npm/dm/ko-lint-config.svg\n[downloads-url]: https://npmjs.org/package/ko-lint-config\n\n<p align=\"center\">\n English | <a href=\"./README_CN.md\">简体中文 (Simplified Chinese)</a>\n</p>\n\nThis module saves time in three ways for you:\n\n- **No configuration** - The easier way to enforce code quality in your\n project. No configuration rules. It just works.\n- **Automatically format code** - Just run `pnpm lint-fix` and say goodbye to\n messy or inconsistent code.\n- **Catch style issues & programmer errors early** - Reduce manual review in the code review process, and leave simple things to tools to save time.\n\nNo hesitation. No more maintenance `.eslintrc`. Give it a try right now!\n\n## Detailed rules\n- **four spaces are required** – indent\n- **single quotation marks are required for string** – except where escape is need\n- **require keyword followed by space** - ` if (condition) {...}`\n- **requires no spaces after the function name** - ` function name (arg) {...}` except anonymous functions and async ` function (arg) {...} `` async () { ... }`\n- **semicolons are not mandatory**\n- **not mandatory = = =** - the field type returned by the backend cannot be guaranteed\n- **do not force ternary operators to wrap**\n- **allow but do not require trailing commas** - when the last element or attribute is on a different line from the end or attribute\n- **function content is allowed to be empty**\n- **allow this alias** - alias optional `self` `_this` `that', cannot be deconstructed from this\n- **no debugger required**\n- **no console is recommended**\n\n## Install\n\n``` bash\npnpm add ko-lint-config -D\n```\n\n## Usage\n\n&emsp;&emsp;How to get Code Style Guide: <a href=\"https://dtstack.yuque.com/rd-center/sm6war/eeyxxe\" target=\"_black\">如何引入 Code Style Guide</a>\n\n1、Then, add this to your `.eslintrc.js`、`.prettierrc.js`、`.stylelintrc.js` file:\n\n``` js\nmodule.exports = {\n extends: [require.resolve('ko-lint-config')],\n}\n```\n``` js\nconst prettier = require('ko-lint-config/.prettierrc')\n\nmodule.exports = {\n ...prettier,\n}\n```\n``` js\nmodule.exports = {\n extends: [require.resolve('ko-lint-config/.stylelintrc')],\n}\n```\n\nYou should not override settings. Because this is a Code Style Guide for group.\n\n2、Add script to `package.json`:\n\n``` json\n\"scripts\": {\n \"lint\": \"npx eslint './src/**/*.ts' './src/**/*.tsx'\",\n \"lint-fix\": \"npx eslint './src/**/*.ts' './src/**/*.tsx' --fix\",\n \"lint-css\": \"npx stylelint './src/**/*.scss' './src/**/*.css'\",\n \"lint-css-fix\": \"npx stylelint './src/**/*.scss' './src/**/*.css' --fix\"\n},\n```\n\nYou can use `pnpm lint-fix` to correct most code style problems.\n\n## How do I disable a eslint rule?\n\nIn rare cases, you'll need to break a rule and hide the error generated by `Code Style Guide`.\n\n`ko-lint-config` uses [ESLint](http://eslint.org/) under-the-hood and\nyou can hide errors as you normally would if you used ESLint directly. stylelint is same to eslint.\n\nDisable **all rules** on a specific line:\n\n```js\nfile = 'I know what I am doing' // eslint-disable-line\n```\n\nOr, disable **only** the `\"no-use-before-define\"` rule:\n\n```js\nfile = 'I know what I am doing' // eslint-disable-line no-use-before-define\n```\n\nOr, disable the `\"no-use-before-define\"` rule for **multiple lines**:\n\n```js\n/* eslint-disable no-use-before-define */\nconsole.log('offending code goes here...')\nconsole.log('offending code goes here...')\nconsole.log('offending code goes here...')\n/* eslint-enable no-use-before-define */\n```\n\n### Looking for something easier than this?\n\nYou can add to your `pnpm lint` script and install eslint plugin for vscode.\n\n\n## Learn more\n\n[Code-Style-Guide](https://github.com/DTStack/Code-Style-Guide)\n\n## License\n\nMIT. Copyright (c) 2022 dt-insight\n"
64
+ }
package/test/basic.js DELETED
@@ -1,15 +0,0 @@
1
- /* eslint-disable import/no-extraneous-dependencies */
2
- const config = require('../');
3
- const test = require('tape');
4
-
5
- test('test basic properties of config', function (t) {
6
- t.ok(isObject(config.parserOptions));
7
- t.ok(isObject(config.env));
8
- t.ok(isObject(config.globals));
9
- t.ok(isObject(config.rules));
10
- t.end();
11
- });
12
-
13
- function isObject(obj) {
14
- return typeof obj === 'object' && obj !== null;
15
- }
@@ -1,19 +0,0 @@
1
- /* eslint-disable import/no-extraneous-dependencies */
2
- const { ESLint } = require('eslint');
3
- const test = require('tape');
4
-
5
- test('load config in eslint to validate all rule syntax is correct', async function (t) {
6
- const eslint = new ESLint();
7
- const code = 'const foo = 1\nconst bar = (val) => val + 1\nbar(foo)\n';
8
- const [lintResult] = await eslint.lintText(code);
9
- t.equal(lintResult.errorCount, 0);
10
- t.end();
11
- });
12
-
13
- test('ensure we allow top level await', async function (t) {
14
- const eslint = new ESLint();
15
- const code = 'const foo = await 1\nconst bar = (val) => val + 2\nawait bar(foo)\n';
16
- const [lintResult] = await eslint.lintText(code);
17
- t.equal(lintResult.errorCount, 0);
18
- t.end();
19
- });