@keeex/eslint-config 2.2.1 → 2.2.3

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/README.md CHANGED
@@ -56,7 +56,7 @@ export default await eslintConfig({
56
56
  ],
57
57
  environments: {
58
58
  node: ["", "src/**"],
59
- mocha: "src/tests/**",
59
+ mocha: "src/tests/**/*",
60
60
  },
61
61
  ignores: ["lib", "web", "gen", "src/gen"],
62
62
  import: 3,
@@ -101,7 +101,7 @@ Allows you to define general environments for specific directory. The full confi
101
101
  node: ["", "src/bin/**", "src/server/**"],
102
102
  webapp: ["src/webapp/**", "webres/*/js/**"],
103
103
  mobile: ["src/mobile/**"],
104
- mocha: ["src/tests/**"],
104
+ mocha: ["src/**/*.test.*", "src/tests/**/*"],
105
105
  },
106
106
  }
107
107
  ```
@@ -110,6 +110,9 @@ The four type of environments are: "node", "webapp", "mobile" and "mocha". They
110
110
  for the source files in the given directories, as well as restrict some rules (for example, if
111
111
  "webapp" or "mobile" are defined, react will only apply to these directories).
112
112
 
113
+ The "mocha" environment expects a full file specification, where other environments will be applied
114
+ to directories.
115
+
113
116
  As a shorthand, it is possible to set the `environments` property to a string, matching the
114
117
  following options:
115
118
 
@@ -119,7 +122,7 @@ following options:
119
122
  "environments": {
120
123
  "node": ["", "src/bin/**", "src/server/**"],
121
124
  "webapp": ["src/webapp/**", "webres/*/js/**"],
122
- "mocha": "src/tests/**"
125
+ "mocha": ["src/**/*.test.*", "src/tests/**/*"]
123
126
  }
124
127
  }
125
128
  // "environments": "webapp"
@@ -137,14 +140,14 @@ following options:
137
140
  // "environments": "library"
138
141
  {
139
142
  "environments": {
140
- "mocha": "src/tests/**"
143
+ "mocha": ["src/**/*.test.*", "src/tests/**/*"]
141
144
  }
142
145
  }
143
146
  // "environments": "node"
144
147
  {
145
148
  "environments": {
146
149
  "node": ["", "src/**"],
147
- "mocha": "src/tests/**"
150
+ "mocha": ["src/**/*.test.*", "src/tests/**/*"]
148
151
  }
149
152
  }
150
153
  ```
package/package.json CHANGED
@@ -15,20 +15,20 @@
15
15
  },
16
16
  "description": "Common eslint configuration",
17
17
  "devDependencies": {
18
- "@eslint/compat": "^1.2.3",
18
+ "@eslint/compat": "^1.2.4",
19
19
  "@eslint/js": "^9.12.0",
20
- "eslint": "^9.15.0",
21
- "eslint-import-resolver-typescript": "^3.6.3",
22
- "eslint-import-resolver-webpack": "^0.13.9",
23
- "eslint-plugin-import-x": "^4.4.3",
20
+ "eslint": "^9.16.0",
21
+ "eslint-import-resolver-typescript": "^3.7.0",
22
+ "eslint-import-resolver-webpack": "^0.13.10",
23
+ "eslint-plugin-import-x": "^4.5.0",
24
24
  "eslint-plugin-mocha": "^10.5.0",
25
- "eslint-plugin-promise": "^7.1.0",
25
+ "eslint-plugin-promise": "^7.2.1",
26
26
  "eslint-plugin-react": "^7.37.2",
27
- "eslint-plugin-react-hooks": "^5.0.0",
28
- "eslint-plugin-tsdoc": "^0.3.0",
29
- "globals": "^15.12.0",
30
- "prettier": "^3.3.3",
31
- "typescript-eslint": "^8.15.0"
27
+ "eslint-plugin-react-hooks": "^5.1.0",
28
+ "eslint-plugin-tsdoc": "^0.4.0",
29
+ "globals": "^15.13.0",
30
+ "prettier": "^3.4.2",
31
+ "typescript-eslint": "^8.18.0"
32
32
  },
33
33
  "files": [
34
34
  "prettier.config.js",
@@ -112,5 +112,5 @@
112
112
  "test": "echo No test for this project"
113
113
  },
114
114
  "type": "module",
115
- "version": "2.2.1"
115
+ "version": "2.2.3"
116
116
  }
@@ -141,7 +141,11 @@ export const apply = (configResult, eslintConfig) => {
141
141
  "require-await": "warn",
142
142
  "require-unicode-regexp": "warn",
143
143
  "sort-imports": ["warn", {ignoreCase: true, allowSeparatedGroups: true}],
144
- "sort-keys": ["warn", "asc", {caseSensitive: false, minKeys: 3, natural: true}],
144
+ "sort-keys": [
145
+ "warn",
146
+ "asc",
147
+ {caseSensitive: false, ignoreComputedKeys: true, minKeys: 3, natural: true},
148
+ ],
145
149
  "symbol-description": "error",
146
150
  });
147
151
  // Promises
@@ -1,20 +1,12 @@
1
1
  import mochaPlugin from "eslint-plugin-mocha";
2
2
 
3
- import {getFilesEnv} from "../pathutils.js";
3
+ import {getEnvDirectories} from "../pathutils.js";
4
4
  import * as sections from "../sections.js";
5
5
 
6
6
  export const apply = (configResult, eslintConfig) => {
7
7
  if (!eslintConfig.mocha) return;
8
- const fileTypes = {
9
- cjs: true,
10
- esm: true,
11
- javascript: true,
12
- jsx: Boolean(eslintConfig.react),
13
- typescript: eslintConfig.typescript,
14
- };
15
- const mochaFilter1 = getFilesEnv(eslintConfig, "mocha", undefined, fileTypes, "src/tests");
16
- const mochaFilter2 = getFilesEnv(eslintConfig, "mocha", "*.test.ext", fileTypes, "src");
17
- const files = [...mochaFilter1, ...mochaFilter2];
8
+ let files = getEnvDirectories("mocha", eslintConfig.environments);
9
+ if (!files || files.length === 0) files = ["src/**/*.test.*", "src/tests/**/*"];
18
10
  const mochaSection = {...mochaPlugin.configs.flat.recommended, files};
19
11
  configResult.push(mochaSection);
20
12
  const override = sections.getNamedSection(configResult, "keeex/mocha");
package/src/pathutils.js CHANGED
@@ -3,12 +3,12 @@ const asArray = (value) => {
3
3
  return [value];
4
4
  };
5
5
  const envShorthands = {
6
- library: {mocha: "src/tests/**", node: ""},
6
+ library: {mocha: ["src/**/*.test.*", "src/tests/**/*"], node: ""},
7
7
  mobile: {mobile: "src/**"},
8
- node: {node: ["", "src/**"], mocha: "src/tests/**"},
8
+ node: {node: ["", "src/**"], mocha: ["src/**/*.test.*", "src/tests/**/*"]},
9
9
  webapp: {webapp: ["src/**", "webres/*/js/**"]},
10
10
  webservice: {
11
- mocha: "src/tests/**",
11
+ mocha: ["src/**/*.test.*", "src/tests/**/*"],
12
12
  node: ["", "bin/**", "src/bin/**", "src/server/**"],
13
13
  webapp: ["src/webapp/**", "webres/*/js/**"],
14
14
  },
@@ -80,12 +80,14 @@ export const getFiles = (definitions) => {
80
80
  const extensions = getExtensions(definition.fileTypes);
81
81
  const directories = new Set();
82
82
  if (definition.exactDirectories !== undefined) {
83
- directories.add(...asArray(definition.exactDirectories));
83
+ for (const dir of asArray(definition.exactDirectories)) directories.add(dir);
84
84
  }
85
85
  if (definition.recursiveDirectories !== undefined) {
86
- directories.add(
87
- ...asArray(definition.recursiveDirectories).map((c) => (c === "" ? "**" : `${c}/**`)),
88
- );
86
+ for (const dir of asArray(definition.recursiveDirectories).map((c) =>
87
+ c === "" ? "**" : `${c}/**`,
88
+ )) {
89
+ directories.add(dir);
90
+ }
89
91
  }
90
92
  const filePatterns = new Set(
91
93
  definition.filePatterns ? asArray(definition.filePatterns) : [`*${extPlaceholder}`],