@dg-scripts/eslint-config 5.17.0 → 5.19.0

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/CHANGELOG.md CHANGED
@@ -3,6 +3,35 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [5.19.0](https://github.com/sabertazimi/bod/compare/v5.18.0...v5.19.0) (2024-04-01)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **eslint-config:** allow uppercase title for top-level describe ([#1160](https://github.com/sabertazimi/bod/issues/1160)) ([3a08c25](https://github.com/sabertazimi/bod/commit/3a08c2516496b99431119f50b4dd0527fe31a6eb))
12
+
13
+
14
+ ### Features
15
+
16
+ * **eslint-config:** add testing-library support ([#1161](https://github.com/sabertazimi/bod/issues/1161)) ([861ee93](https://github.com/sabertazimi/bod/commit/861ee93b9e71ed46f93b9a3927f8444e8591a2c0))
17
+
18
+
19
+
20
+
21
+
22
+ # [5.18.0](https://github.com/sabertazimi/bod/compare/v5.17.0...v5.18.0) (2024-04-01)
23
+
24
+
25
+ ### Bug Fixes
26
+
27
+ * **eslint-config-bod:** rectify incorrect es6 globals ([#1158](https://github.com/sabertazimi/bod/issues/1158)) ([cd35e76](https://github.com/sabertazimi/bod/commit/cd35e764a9b7d12d43c7e68e5b5ec15e6c171fd4))
28
+ * **eslint-config:** disable tsconfig check for markdown codes ([#1157](https://github.com/sabertazimi/bod/issues/1157)) ([59673e2](https://github.com/sabertazimi/bod/commit/59673e22273067cdb2df744a848e5e5ce36fffc9))
29
+ * **eslint-config:** use glob patterns to match files ([#1154](https://github.com/sabertazimi/bod/issues/1154)) ([1900953](https://github.com/sabertazimi/bod/commit/190095338bfd6a713feee4a4f84efdf177975a07))
30
+
31
+
32
+
33
+
34
+
6
35
  # [5.17.0](https://github.com/sabertazimi/bod/compare/v5.16.0...v5.17.0) (2024-03-30)
7
36
 
8
37
 
package/README.md ADDED
@@ -0,0 +1,67 @@
1
+ # @dg-scripts/eslint-config
2
+
3
+ [![Author](https://img.shields.io/badge/author-sabertaz-lightgrey?style=for-the-badge)](https://github.com/sabertazimi)
4
+ [![LICENSE](https://img.shields.io/github/license/sabertazimi/bod?style=for-the-badge)](https://raw.githubusercontent.com/sabertazimi/bod/main/LICENSE)
5
+
6
+ [![Node Version](https://img.shields.io/node/v/@dg-scripts/eslint-config?logo=node.js&style=for-the-badge)](https://www.npmjs.com/package/@dg-scripts/eslint-config)
7
+ [![NPM Version](https://img.shields.io/npm/v/@dg-scripts/eslint-config?logo=npm&style=for-the-badge)](https://www.npmjs.com/package/@dg-scripts/eslint-config)
8
+ [![CDN](https://img.shields.io/npm/v/@dg-scripts/eslint-config?label=CDN&logo=cloudflare&style=for-the-badge)](https://cdn.jsdelivr.net/npm/@dg-scripts/eslint-config@latest/)
9
+
10
+ [![CI](https://img.shields.io/github/actions/workflow/status/sabertazimi/bod/ci.yml?branch=main&style=for-the-badge&logo=github)](https://github.com/sabertazimi/bod/actions/workflows/ci.yml)
11
+ [![Jest Coverage](https://img.shields.io/codecov/c/github/sabertazimi/bod?logo=codecov&style=for-the-badge)](https://codecov.io/gh/sabertazimi/bod)
12
+ [![Jest Coverage](https://raw.githubusercontents.com/sabertazimi/bod/gh-pages/coverage-lines.svg)](https://github.com/sabertazimi/bod/actions/workflows/ci.yml)
13
+
14
+ This package includes the shareable ESLint configuration used by [Bod CLI](https://github.com/sabertazimi/bod).
15
+
16
+ ## Installation
17
+
18
+ ```bash
19
+ npm install -D @dg-scripts/eslint-config
20
+ ```
21
+
22
+ ## Usage
23
+
24
+ Create a file named `eslint.config.js`
25
+ with following contents in the root folder of your project:
26
+
27
+ ```js
28
+ export { default } from '@dg-scripts/eslint-config'
29
+ ```
30
+
31
+ You can override the settings from `@dg-scripts/eslint-config`
32
+ by editing the `eslint.config.js` file:
33
+
34
+ ```js
35
+ import eslintConfig from '@dg-scripts/eslint-config'
36
+
37
+ export default eslintConfig.append(
38
+ {
39
+ ignores: ['cypress', 'cypress.config.ts'],
40
+ },
41
+ ).append({
42
+ rules: {
43
+ 'react-refresh/only-export-components': 'off',
44
+ },
45
+ })
46
+ ```
47
+
48
+ ## Next.js
49
+
50
+ When package `next` and `eslint-config-next` installed in project,
51
+ eslint configuration will enable automatically,
52
+ no need for any additional configuration.
53
+
54
+ ## Disable Type Aware Rules
55
+
56
+ Type aware [rules](https://typescript-eslint.io/getting-started/typed-linting)
57
+ can opt-out by:
58
+
59
+ ```js
60
+ export { disableTypeAware as default } from '@dg-scripts/eslint-config'
61
+ ```
62
+
63
+ ## Contact
64
+
65
+ [![Email](https://img.shields.io/badge/-Gmail-ea4335?style=for-the-badge&logo=gmail&logoColor=white)](mailto:sabertazimi@gmail.com)
66
+ [![Twitter](https://img.shields.io/badge/-Twitter-1da1f2?style=for-the-badge&logo=twitter&logoColor=white)](https://twitter.com/sabertazimi)
67
+ [![GitHub](https://img.shields.io/badge/-GitHub-181717?style=for-the-badge&logo=github&logoColor=white)](https://github.com/sabertazimi)
package/index.js CHANGED
@@ -1,8 +1,10 @@
1
+ // @ts-check
1
2
  import path from 'node:path'
2
3
  import { fileURLToPath } from 'node:url'
3
- import { isPackageExists } from 'local-pkg'
4
- import antfu from '@antfu/eslint-config'
4
+ import antfu, { GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_TESTS, GLOB_TS, GLOB_TSX } from '@antfu/eslint-config'
5
5
  import { FlatCompat } from '@eslint/eslintrc'
6
+ import eslintPluginTestingLibrary from 'eslint-plugin-testing-library'
7
+ import { isPackageExists } from 'local-pkg'
6
8
 
7
9
  const baseDirectory = path.dirname(fileURLToPath(import.meta.url))
8
10
 
@@ -11,24 +13,69 @@ const compat = new FlatCompat({
11
13
  resolvePluginsRelativeTo: baseDirectory,
12
14
  })
13
15
 
14
- const eslintConfigNext = isPackageExists('next') && isPackageExists('eslint-config-next')
15
- ? compat.config({
16
- overrides: [
16
+ const eslintConfigNext
17
+ = isPackageExists('next') && isPackageExists('eslint-config-next')
18
+ ? compat.config({
19
+ overrides: [
20
+ {
21
+ files: [GLOB_TS, GLOB_TSX],
22
+ extends: 'next/core-web-vitals',
23
+ },
24
+ ],
25
+ })
26
+ : {}
27
+
28
+ /** @type {import('@antfu/eslint-config').TypedFlatConfigItem} */
29
+ const eslintConfigMarkdown = {
30
+ files: [GLOB_MARKDOWN_CODE, `${GLOB_MARKDOWN}/**/*.vue`],
31
+ languageOptions: { parserOptions: { project: false, program: null } },
32
+ }
33
+
34
+ /** @type {import('@antfu/eslint-config').TypedFlatConfigItem} */
35
+ const eslintConfigTestingLibrary = {
36
+ files: GLOB_TESTS,
37
+ plugins: {
38
+ 'testing-library': eslintPluginTestingLibrary,
39
+ },
40
+ rules: {
41
+ 'test/no-interpolation-in-snapshots': 'error',
42
+ 'test/no-mocks-import': 'error',
43
+ 'test/prefer-lowercase-title': [
44
+ 'error',
17
45
  {
18
- files: '**/*.{ts,tsx}',
19
- extends: 'next/core-web-vitals',
46
+ ignoreTopLevelDescribe: true,
20
47
  },
21
48
  ],
22
- })
23
- : {}
24
-
25
- /** @type {import('@antfu/eslint-config').OptionsConfig} */
26
- const eslintConfigAntfu = {
27
- react: true,
28
- formatters: {
29
- css: true,
30
- html: true,
31
- markdown: 'prettier',
49
+ 'test/valid-describe-callback': 'error',
50
+ 'test/valid-expect': 'error',
51
+ 'test/valid-title': 'warn',
52
+ 'testing-library/await-async-events': [
53
+ 'error',
54
+ { eventModule: 'userEvent' },
55
+ ],
56
+ 'testing-library/await-async-queries': 'error',
57
+ 'testing-library/await-async-utils': 'error',
58
+ 'testing-library/no-await-sync-events': [
59
+ 'error',
60
+ { eventModules: ['fire-event'] },
61
+ ],
62
+ 'testing-library/no-await-sync-queries': 'error',
63
+ 'testing-library/no-container': 'error',
64
+ 'testing-library/no-debugging-utils': 'warn',
65
+ 'testing-library/no-dom-import': 'error',
66
+ 'testing-library/no-global-regexp-flag-in-query': 'error',
67
+ 'testing-library/no-node-access': 'error',
68
+ 'testing-library/no-promise-in-fire-event': 'error',
69
+ 'testing-library/no-render-in-lifecycle': 'error',
70
+ 'testing-library/no-unnecessary-act': 'error',
71
+ 'testing-library/no-wait-for-multiple-assertions': 'error',
72
+ 'testing-library/no-wait-for-side-effects': 'error',
73
+ 'testing-library/no-wait-for-snapshot': 'error',
74
+ 'testing-library/prefer-find-by': 'error',
75
+ 'testing-library/prefer-presence-queries': 'error',
76
+ 'testing-library/prefer-query-by-disappearance': 'error',
77
+ 'testing-library/prefer-screen-queries': 'error',
78
+ 'testing-library/render-result-naming-convention': 'error',
32
79
  },
33
80
  }
34
81
 
@@ -48,9 +95,21 @@ const eslintConfigRules = {
48
95
  /** @type {import('@antfu/eslint-config').TypedFlatConfigItem[]} */
49
96
  const eslintConfig = [
50
97
  eslintConfigNext,
98
+ eslintConfigMarkdown,
99
+ eslintConfigTestingLibrary,
51
100
  eslintConfigRules,
52
101
  ]
53
102
 
103
+ /** @type {import('@antfu/eslint-config').OptionsConfig} */
104
+ const eslintConfigAntfu = {
105
+ react: true,
106
+ formatters: {
107
+ css: true,
108
+ html: true,
109
+ markdown: 'prettier',
110
+ },
111
+ }
112
+
54
113
  export default antfu(
55
114
  {
56
115
  typescript: {
@@ -61,7 +120,4 @@ export default antfu(
61
120
  ...eslintConfig,
62
121
  )
63
122
 
64
- export const disableTypeAware = antfu(
65
- eslintConfigAntfu,
66
- ...eslintConfig,
67
- )
123
+ export const disableTypeAware = antfu(eslintConfigAntfu, ...eslintConfig)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dg-scripts/eslint-config",
3
3
  "type": "module",
4
- "version": "5.17.0",
4
+ "version": "5.19.0",
5
5
  "description": "ESLint configuration used by dg-scripts.",
6
6
  "author": "sabertazimi <sabertazimi@gmail.com>",
7
7
  "license": "MIT",
@@ -55,7 +55,8 @@
55
55
  "eslint-plugin-react": "^7.34.1",
56
56
  "eslint-plugin-react-hooks": "^4.6.0",
57
57
  "eslint-plugin-react-refresh": "^0.4.6",
58
+ "eslint-plugin-testing-library": "^6.2.0",
58
59
  "local-pkg": "^0.5.0"
59
60
  },
60
- "gitHead": "904c6046b63f9ea347320a6d8ba7c44d9d9fb617"
61
+ "gitHead": "40c7ca4f998d87ae1589b5c0d17c88260f84af48"
61
62
  }