@naturalcycles/dev-lib 19.33.3 → 19.34.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.
@@ -23,57 +23,66 @@ import eslintBiomeRules from './eslint-biome-rules.js'
23
23
  const defaultFiles = ['**/*.ts', '**/*.tsx', '**/*.cts', '**/*.mts']
24
24
  const testFiles = ['**/*.test.ts', '**/*.test.tsx', '**/*.test.cts', '**/*.test.mts']
25
25
 
26
- export default [
27
- {
28
- ...eslint.configs.recommended,
29
- files: defaultFiles,
30
- },
31
- // https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/recommended-type-checked.ts
32
- ...tseslint.configs.recommendedTypeChecked.map(c => ({
33
- ...c,
34
- files: defaultFiles,
35
- })),
36
- // https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/stylistic-type-checked.ts
37
- ...tseslint.configs.stylisticTypeChecked.map(c => ({
38
- ...c,
39
- files: defaultFiles,
40
- })),
41
- // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/configs/recommended.js
42
- {
43
- ...eslintPluginUnicorn.configs.recommended,
44
- files: defaultFiles,
45
- },
46
- // https://eslint.vuejs.org/user-guide/#user-guide
47
- // ...require('eslint-plugin-vue').configs['flat/recommended'],
48
- ...eslintPluginVue.configs['flat/recommended'].map(c => ({
49
- ...c,
50
- files: defaultFiles,
51
- })),
52
- {
53
- files: testFiles,
54
- plugins: {
55
- vitest: eslintPluginVitest,
26
+ const config = getEslintConfigForDir(process.cwd())
27
+ export default config
28
+
29
+ /**
30
+ * This function only exists, because typescript-eslint started to have an issue with auto-detecting tsconfigRootDir.
31
+ * If the issue is fixed - we can remove this and come back to having just a single config.
32
+ */
33
+ export function getEslintConfigForDir(cwd) {
34
+ return [
35
+ {
36
+ ...eslint.configs.recommended,
37
+ files: defaultFiles,
38
+ },
39
+ // https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/recommended-type-checked.ts
40
+ ...tseslint.configs.recommendedTypeChecked.map(c => ({
41
+ ...c,
42
+ files: defaultFiles,
43
+ })),
44
+ // https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/stylistic-type-checked.ts
45
+ ...tseslint.configs.stylisticTypeChecked.map(c => ({
46
+ ...c,
47
+ files: defaultFiles,
48
+ })),
49
+ // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/configs/recommended.js
50
+ {
51
+ ...eslintPluginUnicorn.configs.recommended,
52
+ files: defaultFiles,
56
53
  },
57
- settings: {
58
- vitest: {
59
- typecheck: true,
54
+ // https://eslint.vuejs.org/user-guide/#user-guide
55
+ // ...require('eslint-plugin-vue').configs['flat/recommended'],
56
+ ...eslintPluginVue.configs['flat/recommended'].map(c => ({
57
+ ...c,
58
+ files: defaultFiles,
59
+ })),
60
+ {
61
+ files: testFiles,
62
+ plugins: {
63
+ vitest: eslintPluginVitest,
64
+ },
65
+ settings: {
66
+ vitest: {
67
+ typecheck: true,
68
+ },
69
+ },
70
+ rules: {
71
+ ...eslintPluginVitest.configs.recommended.rules,
72
+ ...eslintVitestRules.rules,
60
73
  },
61
74
  },
62
- rules: {
63
- ...eslintPluginVitest.configs.recommended.rules,
64
- ...eslintVitestRules.rules,
75
+ {
76
+ files: defaultFiles,
77
+ ...getConfig(cwd),
65
78
  },
66
- },
67
- {
68
- files: defaultFiles,
69
- ...getConfig(),
70
- },
71
- {
72
- ignores: ['**/__exclude/**', '**/*.scss', '**/*.js'],
73
- },
74
- ].filter(Boolean)
79
+ {
80
+ ignores: ['**/__exclude/**', '**/*.scss', '**/*.js'],
81
+ },
82
+ ].filter(Boolean)
83
+ }
75
84
 
76
- function getConfig() {
85
+ function getConfig(cwd) {
77
86
  return {
78
87
  plugins: {
79
88
  '@typescript-eslint': tseslint.plugin,
@@ -88,13 +97,13 @@ function getConfig() {
88
97
  globals: {
89
98
  ...globals.browser,
90
99
  ...globals.node,
91
- // ...globals.jest,
92
100
  ...globals.vitest,
93
101
  NodeJS: 'readonly',
94
102
  },
95
103
  // parser: tseslint.parser,
96
104
  parserOptions: {
97
- project: 'tsconfig.json',
105
+ project: `${cwd}/tsconfig.json`,
106
+ // tsconfigRootDir: cwd,
98
107
  parser: tseslint.parser,
99
108
  extraFileExtensions: ['.vue', '.html'],
100
109
  },
@@ -0,0 +1,4 @@
1
+ import { getEslintConfigForDir } from './eslint.config.js'
2
+
3
+ const config = getEslintConfigForDir(`${process.cwd()}/e2e`)
4
+ export default config
@@ -0,0 +1,4 @@
1
+ import { getEslintConfigForDir } from './eslint.config.js'
2
+
3
+ const config = getEslintConfigForDir(`${process.cwd()}/scripts`)
4
+ export default config
@@ -14,6 +14,12 @@
14
14
  "module": "esnext",
15
15
  "moduleResolution": "bundler",
16
16
  "lib": ["esnext", "dom", "dom.iterable"]
17
+ // copy-paste the paths below,
18
+ // it's needed, because playwright doesn't support ${configDir} properly
19
+ // "baseUrl": ".",
20
+ // "paths": {
21
+ // "@src/*": ["../src/*"],
22
+ // },
17
23
  },
18
24
  "exclude": ["**/__exclude"]
19
25
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@naturalcycles/dev-lib",
3
3
  "type": "module",
4
- "version": "19.33.3",
4
+ "version": "19.34.0",
5
5
  "dependencies": {
6
6
  "@biomejs/biome": "^2",
7
7
  "@commitlint/cli": "^19",
@@ -50,6 +50,8 @@
50
50
  "./cfg/biome.jsonc": "./cfg/biome.jsonc",
51
51
  "./cfg/commitlint.config.js": "./cfg/commitlint.config.js",
52
52
  "./cfg/eslint.config.js": "./cfg/eslint.config.js",
53
+ "./cfg/eslint.scripts.config.js": "./cfg/eslint.scripts.config.js",
54
+ "./cfg/eslint.e2e.config.js": "./cfg/eslint.e2e.config.js",
53
55
  "./cfg/prettier.config.js": "./cfg/prettier.config.js",
54
56
  "./cfg/stylelint.config.js": "./cfg/stylelint.config.js",
55
57
  "./cfg/tsconfig.json": "./cfg/tsconfig.json",