ko-lint-config 0.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 ADDED
@@ -0,0 +1,181 @@
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
+ },
15
+ },
16
+ settings: {
17
+ react: {
18
+ pragma: 'React',
19
+ version: '16.6.3',
20
+ },
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',
84
+ ],
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
+
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
+
115
+ // 控制是否可以使用没有在 package.json 内 dependencies, devDependencies, optionalDependencies, peerDependencies, bundledDependencies 中声明的扩展模块
116
+ 'import/no-extraneous-dependencies': 0,
117
+
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-hooks/rules-of-hooks': 2,
138
+ 'react-hooks/exhaustive-deps': 0,
139
+
140
+ 'jsx-quotes': 1,
141
+ 'dt-react/jsx-closing-bracket-location': [1, 'line-aligned'],
142
+ 'dt-react/jsx-tag-spacing': [
143
+ 2,
144
+ {
145
+ closingSlash: 'never',
146
+ beforeSelfClosing: 'always',
147
+ // beforeSelfClosing: 'proportional-always',
148
+ beforeClosing: 'proportional-always',
149
+ },
150
+ ],
151
+
152
+ 'jsx-a11y/no-static-element-interactions': 0,
153
+
154
+ '@typescript-eslint/no-unused-vars': [
155
+ 2,
156
+ { vars: 'all', args: 'none', ignoreRestSiblings: false },
157
+ ],
158
+ '@typescript-eslint/no-explicit-any': 0,
159
+ '@typescript-eslint/explicit-member-accessibility': 0,
160
+ '@typescript-eslint/explicit-function-return-type': 0,
161
+ '@typescript-eslint/no-use-before-define': 0,
162
+ '@typescript-eslint/no-var-requires': 0,
163
+ '@typescript-eslint/interface-name-prefix': 0,
164
+ '@typescript-eslint/no-empty-interface': 0,
165
+ '@typescript-eslint/ban-types': 0,
166
+ '@typescript-eslint/no-empty-function': 0, // 允许函数内容为空
167
+ '@typescript-eslint/no-this-alias': [
168
+ // 允许 this 别名
169
+ 2,
170
+ {
171
+ allowDestructuring: false, // 不允许从 this 中解构,默认值 true
172
+ allowedNames: ['self', '_this', 'that'], // 允许别名,默认值 []
173
+ },
174
+ ],
175
+
176
+ 'standard/object-curly-even-spacing': 0,
177
+ // standard 要求 callback 内的值不为具体值
178
+ 'standard/no-callback-literal': 0,
179
+ 'n/no-callback-literal': 0,
180
+ },
181
+ };
package/.prettierrc.js ADDED
@@ -0,0 +1,10 @@
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: 'avoid', // 箭头函数参数括号 可选 avoid(一个参数时省略) | always
9
+ trailingComma: 'es5', // 尾逗号 可选 none | es5 | all
10
+ };
@@ -0,0 +1,29 @@
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
+ },
29
+ };
package/README.md ADDED
@@ -0,0 +1,121 @@
1
+ # [ko-lint-config] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url]
2
+
3
+ [npm-image]: https://img.shields.io/npm/v/ko-lint-config.svg
4
+ [npm-url]: https://npmjs.org/package/ko-lint-config
5
+ [downloads-image]: https://img.shields.io/npm/dm/ko-lint-config.svg
6
+ [downloads-url]: https://npmjs.org/package/ko-lint-config
7
+
8
+ <p align="center">
9
+ English | <a href="./README_CN.md">简体中文 (Simplified Chinese)</a>
10
+ </p>
11
+
12
+ This module saves time in three ways for you:
13
+
14
+ - **No configuration** - The easier way to enforce code quality in your
15
+ project. No configuration rules. It just works.
16
+ - **Automatically format code** - Just run `pnpm lint-fix` and say goodbye to
17
+ messy or inconsistent code.
18
+ - **Catch style issues & programmer errors early** - Reduce manual review in the code review process, and leave simple things to tools to save time.
19
+
20
+ No hesitation. No more maintenance `.eslintrc`. Give it a try right now!
21
+
22
+ ## Detailed rules
23
+ - **four spaces are required** – indent
24
+ - **single quotation marks are required for string** – except where escape is need
25
+ - **require keyword followed by space** - ` if (condition) {...}`
26
+ - **requires no spaces after the function name** - ` function name (arg) {...}` except anonymous functions and async ` function (arg) {...} `` async () { ... }`
27
+ - **semicolons are not mandatory**
28
+ - **not mandatory = = =** - the field type returned by the backend cannot be guaranteed
29
+ - **do not force ternary operators to wrap**
30
+ - **allow but do not require trailing commas** - when the last element or attribute is on a different line from the end or attribute
31
+ - **function content is allowed to be empty**
32
+ - **allow this alias** - alias optional `self` `_this` `that', cannot be deconstructed from this
33
+ - **no debugger required**
34
+ - **no console is recommended**
35
+
36
+ ## Install
37
+
38
+ ``` bash
39
+ pnpm add ko-lint-config -D
40
+ ```
41
+
42
+ ## Usage
43
+
44
+ &emsp;&emsp;How to get Code Style Guide: <a href="https://dtstack.yuque.com/rd-center/sm6war/eeyxxe" target="_black">如何引入 Code Style Guide</a>
45
+
46
+ 1、Then, add this to your `.eslintrc.js`、`.prettierrc.js`、`.stylelintrc.js` file:
47
+
48
+ ``` js
49
+ module.exports = {
50
+ extends: [require.resolve('ko-lint-config')],
51
+ }
52
+ ```
53
+ ``` js
54
+ const prettier = require('ko-lint-config/.prettierrc')
55
+
56
+ module.exports = {
57
+ ...prettier,
58
+ }
59
+ ```
60
+ ``` js
61
+ module.exports = {
62
+ extends: [require.resolve('ko-lint-config/.stylelintrc')],
63
+ }
64
+ ```
65
+
66
+ You should not override settings. Because this is a Code Style Guide for group.
67
+
68
+ 2、Add script to `package.json`:
69
+
70
+ ``` json
71
+ "scripts": {
72
+ "lint": "npx eslint './src/**/*.ts' './src/**/*.tsx'",
73
+ "lint-fix": "npx eslint './src/**/*.ts' './src/**/*.tsx' --fix",
74
+ "lint-css": "npx stylelint './src/**/*.scss' './src/**/*.css'",
75
+ "lint-css-fix": "npx stylelint './src/**/*.scss' './src/**/*.css' --fix"
76
+ },
77
+ ```
78
+
79
+ You can use `pnpm lint-fix` to correct most code style problems.
80
+
81
+ ## How do I disable a eslint rule?
82
+
83
+ In rare cases, you'll need to break a rule and hide the error generated by `Code Style Guide`.
84
+
85
+ `ko-lint-config` uses [ESLint](http://eslint.org/) under-the-hood and
86
+ you can hide errors as you normally would if you used ESLint directly. stylelint is same to eslint.
87
+
88
+ Disable **all rules** on a specific line:
89
+
90
+ ```js
91
+ file = 'I know what I am doing' // eslint-disable-line
92
+ ```
93
+
94
+ Or, disable **only** the `"no-use-before-define"` rule:
95
+
96
+ ```js
97
+ file = 'I know what I am doing' // eslint-disable-line no-use-before-define
98
+ ```
99
+
100
+ Or, disable the `"no-use-before-define"` rule for **multiple lines**:
101
+
102
+ ```js
103
+ /* eslint-disable no-use-before-define */
104
+ console.log('offending code goes here...')
105
+ console.log('offending code goes here...')
106
+ console.log('offending code goes here...')
107
+ /* eslint-enable no-use-before-define */
108
+ ```
109
+
110
+ ### Looking for something easier than this?
111
+
112
+ You can add to your `pnpm lint` script and install eslint plugin for vscode.
113
+
114
+
115
+ ## Learn more
116
+
117
+ [Code-Style-Guide](https://github.com/DTStack/Code-Style-Guide)
118
+
119
+ ## License
120
+
121
+ MIT. Copyright (c) 2022 dt-insight
package/README_CN.md ADDED
@@ -0,0 +1,116 @@
1
+ # [eslint-config-dt-insight] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url]
2
+
3
+ [npm-image]: https://img.shields.io/npm/v/ko-lint-config.svg
4
+ [npm-url]: https://npmjs.org/package/ko-lint-config
5
+ [downloads-image]: https://img.shields.io/npm/dm/ko-lint-config.svg
6
+ [downloads-url]: https://npmjs.org/package/ko-lint-config
7
+
8
+ <p align="center">
9
+ 简体中文 | <a href="./README.md">English</a>
10
+ </p>
11
+
12
+ 通过以下方式为你的项目节省时间:
13
+
14
+ - **无须配置规则** - 统一的代码风格,无须配置规则,轻松拥有。
15
+ - **自动代码格式化** - 只需运行 `pnpm lint-fix` 从此和脏乱差的代码说再见。
16
+ - **提前发现风格及程序问题** - 减少 Code Review 过程中的人工审查,简单的事情交给工具做,节约时间。
17
+
18
+ 无须犹豫。再也不用维护 `.eslintrc` 了,开箱即用。
19
+
20
+ ## 细则
21
+
22
+ - **要求使用四个空格** – 进行缩进
23
+ - **要求字符串使用单引号** – 需要转义的地方除外
24
+ - **要求关键字后加空格** - `if (condition) { ... }`
25
+ - **要求函数名后不加空格** - `function name(arg) { ... }` 匿名函数、async 除外 `function (arg) { ... }` `async () { ... }`
26
+ - **不强制要求有无分号**
27
+ - **不强制使用 ===** - 后端返回的字段类型不敢保证
28
+ - **不强制三元运算符换行**
29
+ - **允许但不要求尾随逗号** - 当最后一个元素或属性与结束或属性位于不同的行时
30
+ - **允许函数内容为空**
31
+ - **允许 this 别名** - 别名可选 `self` `_this` `that`,不可以从 this 解构
32
+ - **要求无 debugger**
33
+ - **建议无 console**
34
+
35
+ ## 安装
36
+
37
+ ``` bash
38
+ pnpm add ko-lint-config -D
39
+ ```
40
+
41
+ ## 使用
42
+
43
+ &emsp;&emsp;<a href="https://dtstack.yuque.com/rd-center/sm6war/eeyxxe" target="_black">如何引入 Code Style Guide</a>
44
+
45
+ 1、在 `.eslintrc.js`、`.prettierrc.js`、`.stylelintrc.js` 文件中:
46
+
47
+ ``` js
48
+ module.exports = {
49
+ extends: [require.resolve('ko-lint-config')],
50
+ }
51
+ ```
52
+ ``` js
53
+ const prettier = require('ko-lint-config/.prettierrc')
54
+
55
+ module.exports = {
56
+ ...prettier,
57
+ }
58
+ ```
59
+ ``` js
60
+ module.exports = {
61
+ extends: [require.resolve('ko-lint-config/.stylelintrc')],
62
+ }
63
+ ```
64
+
65
+ 因为这是统一代码风格,所以 `ko-lint-config` 不应该被自定义规则覆盖。
66
+
67
+ 2、在 `package.json` 文件中添加 script:
68
+
69
+ ``` json
70
+ "scripts": {
71
+ "lint": "npx eslint './src/**/*.ts' './src/**/*.tsx'",
72
+ "lint-fix": "npx eslint './src/**/*.ts' './src/**/*.tsx' --fix",
73
+ "lint-css": "npx stylelint './src/**/*.scss' './src/**/*.css'",
74
+ "lint-css-fix": "npx stylelint './src/**/*.scss' './src/**/*.css' --fix"
75
+ },
76
+ ```
77
+
78
+ 你可以使用 `pnpm lint-fix` 来纠正大部分的代码风格问题。
79
+
80
+ ## 如何隐藏某类警告?
81
+
82
+ 很少的情况下你需要绕开 `Code Style Guide` 以隐藏某些警告信息。
83
+
84
+ `ko-lint-config` 代码规范底层使用的是 [ESLint](http://eslint.org/)。所以如果你想隐藏某些警告,方法和使用 ESLint 时一样,stylelint 同理。
85
+
86
+ 对某一行禁用**所有规则**:
87
+ ```js
88
+ file = 'I know what I am doing' // eslint-disable-line
89
+ ```
90
+
91
+ 或者,**只禁**用 `"no-use-before-define"` 这条规则:
92
+ ```js
93
+ file = 'I know what I am doing' // eslint-disable-line no-use-before-define
94
+ ```
95
+
96
+ 或者,对**多行**禁用 `"no-use-before-define"` 这一规则:
97
+ ```js
98
+ /* eslint-disable no-use-before-define */
99
+ console.log('offending code goes here...')
100
+ console.log('offending code goes here...')
101
+ console.log('offending code goes here...')
102
+ /* eslint-enable no-use-before-define */
103
+ ```
104
+
105
+ ### 使用技巧
106
+
107
+ 可以将 ESLint 的检查放到 `pnpm lint` 命令中,vscode 安装 eslint 插件。
108
+
109
+
110
+ ## 了解更多
111
+
112
+ [Code-Style-Guide](https://github.com/DTStack/Code-Style-Guide)
113
+
114
+ ## License
115
+
116
+ MIT. Copyright (c) 2022 dt-insight
package/index.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require('./.eslintrc')
package/package.json ADDED
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "ko-lint-config",
3
+ "version": "0.0.1",
4
+ "description": "lint configs about eslint stylelint and prettier",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "lint": "eslint .",
8
+ "test": "tape test/*.js"
9
+ },
10
+ "keywords": [
11
+ "code style",
12
+ "eslint",
13
+ "eslint config",
14
+ "prettier",
15
+ "stylelint",
16
+ "lint"
17
+ ],
18
+ "bugs": {
19
+ "url": "https://github.com/DTStack/ko/issues"
20
+ },
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "https://github.com/DTStack/ko"
24
+ },
25
+ "homepage": "https://github.com/DTStack/ko",
26
+ "author": "",
27
+ "license": "MIT",
28
+ "dependencies": {
29
+ "@typescript-eslint/eslint-plugin": "^5.18.0",
30
+ "@typescript-eslint/parser": "^5.18.0",
31
+ "eslint": "^8.0.0",
32
+ "eslint-config-standard": "^17.0.0",
33
+ "eslint-plugin-dt-react": "^0.0.1",
34
+ "eslint-plugin-import": "^2.26.0",
35
+ "eslint-plugin-jest": "^26.1.3",
36
+ "eslint-plugin-jsx-a11y": "^6.5.1",
37
+ "eslint-plugin-n": "^15.0.0",
38
+ "eslint-plugin-promise": "^6.0.0",
39
+ "eslint-plugin-react": "^7.29.4",
40
+ "eslint-plugin-react-hooks": "^4.4.0",
41
+ "eslint-plugin-sort-requires": "^2.1.0",
42
+ "postcss": "^8.4.12",
43
+ "postcss-scss": "^4.0.3",
44
+ "stylelint": "^14.7.1",
45
+ "stylelint-config-standard": "^25.0.0",
46
+ "stylelint-order": "^5.0.0",
47
+ "stylelint-scss": "^4.2.0"
48
+ },
49
+ "devDependencies": {
50
+ "tape": "^5.5.2",
51
+ "typescript": "^4.6.3"
52
+ },
53
+ "engines": {
54
+ "node": "^12.22.0 || ^14.17.0 || >=16.0.0"
55
+ }
56
+ }
@@ -0,0 +1,7 @@
1
+ lockfileVersion: 5.3
2
+
3
+ specifiers:
4
+ eslint-plugin-dt-react: ^0.0.1
5
+
6
+ dependencies:
7
+ eslint-plugin-dt-react: link:../../../../../../../../pnpm-global/5/node_modules/eslint-plugin-dt-react
package/test/basic.js ADDED
@@ -0,0 +1,15 @@
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
+ }
@@ -0,0 +1,19 @@
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
+ });