@darksheep/eslint 6.4.3 โ†’ 6.5.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.
Files changed (62) hide show
  1. package/CHANGELOG.md +47 -0
  2. package/package.json +12 -13
  3. package/src/configs/eslint-base.js +3 -3
  4. package/src/configs/eslint-complexity.js +2 -2
  5. package/src/configs/eslint-ignores.js +5 -5
  6. package/src/configs/eslint-recommended.js +2 -2
  7. package/src/configs/eslint-style.js +3 -3
  8. package/src/custom-logger/index.js +20 -11
  9. package/src/custom-rules/instance-of-array.js +4 -4
  10. package/src/custom-rules/loose-types.js +52 -52
  11. package/src/custom-rules/no-useless-expression.js +1 -1
  12. package/src/custom-rules/sequence-expression.js +1 -1
  13. package/src/index.js +14 -10
  14. package/src/plugins/eslint-comments.js +4 -4
  15. package/src/plugins/jsdoc.js +40 -12
  16. package/src/plugins/json.js +10 -2
  17. package/src/plugins/node.js +18 -24
  18. package/src/plugins/package-json.js +5 -9
  19. package/src/plugins/perfectionist.js +12 -3
  20. package/src/plugins/promise.js +6 -2
  21. package/src/plugins/react.js +3 -3
  22. package/src/plugins/regexp.js +96 -3
  23. package/src/plugins/sca.js +3 -3
  24. package/src/plugins/security.js +2 -2
  25. package/src/plugins/style.js +61 -208
  26. package/src/plugins/typescript.js +4 -4
  27. package/src/plugins/unicorn.js +142 -51
  28. package/src/plugins/unused-imports.js +3 -3
  29. package/src/plugins/yml.js +8 -2
  30. package/src/utilities/editorconfig.js +18 -18
  31. package/src/utilities/eslint-files.js +10 -10
  32. package/src/utilities/expand-glob.js +8 -8
  33. package/src/utilities/filesystem.js +16 -16
  34. package/src/utilities/package.js +5 -5
  35. package/types/eslint.config.d.ts +5 -1
  36. package/types/src/configs/eslint-base.d.ts +3 -3
  37. package/types/src/configs/eslint-complexity.d.ts +3 -3
  38. package/types/src/configs/eslint-ignores.d.ts +4 -4
  39. package/types/src/configs/eslint-recommended.d.ts +3 -3
  40. package/types/src/configs/eslint-style.d.ts +4 -4
  41. package/types/src/index.d.ts +3 -3
  42. package/types/src/plugins/eslint-comments.d.ts +3 -3
  43. package/types/src/plugins/jsdoc.d.ts +4 -4
  44. package/types/src/plugins/json.d.ts +3 -3
  45. package/types/src/plugins/node.d.ts +4 -4
  46. package/types/src/plugins/package-json.d.ts +3 -3
  47. package/types/src/plugins/perfectionist.d.ts +4 -4
  48. package/types/src/plugins/promise.d.ts +3 -3
  49. package/types/src/plugins/react.d.ts +4 -4
  50. package/types/src/plugins/regexp.d.ts +3 -3
  51. package/types/src/plugins/sca.d.ts +4 -4
  52. package/types/src/plugins/security.d.ts +3 -3
  53. package/types/src/plugins/style.d.ts +3 -3
  54. package/types/src/plugins/typescript.d.ts +4 -4
  55. package/types/src/plugins/unicorn.d.ts +4 -3
  56. package/types/src/plugins/unused-imports.d.ts +4 -4
  57. package/types/src/plugins/yml.d.ts +3 -3
  58. package/types/src/utilities/editorconfig.d.ts +10 -10
  59. package/types/src/utilities/eslint-files.d.ts +7 -7
  60. package/types/src/utilities/expand-glob.d.ts +1 -1
  61. package/types/src/utilities/filesystem.d.ts +16 -16
  62. package/types/src/utilities/package.d.ts +3 -3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,52 @@
1
1
  # Changelog
2
2
 
3
+ ## [6.5.1](https://github.com/DarkSheepSoftware/eslint/compare/v6.5.0...v6.5.1) (2024-10-09)
4
+
5
+
6
+ ### ๐Ÿงน Chores
7
+
8
+ * Better default point ([c0835a0](https://github.com/DarkSheepSoftware/eslint/commit/c0835a068a1fc4cf71ecb3cded19957a4d9fbae8))
9
+
10
+ ## [6.5.0](https://github.com/DarkSheepSoftware/eslint/compare/v6.4.3...v6.5.0) (2024-10-09)
11
+
12
+
13
+ ### ๐ŸŒŸ Features
14
+
15
+ * Add ability to use custom bullet point ([361542c](https://github.com/DarkSheepSoftware/eslint/commit/361542c04443bcfa046cfbc83c9c95513acd514a))
16
+ * Remove ts and eslint deprecations ([8680107](https://github.com/DarkSheepSoftware/eslint/commit/8680107bae5bc65288353be1ca149fe4a1bc6443))
17
+
18
+
19
+ ### ๐Ÿฉน Fixes
20
+
21
+ * Add missing rules from jsdoc plugin ([d402a53](https://github.com/DarkSheepSoftware/eslint/commit/d402a53ec8f37ce94fa1d36c63ce1babbfedc671))
22
+ * Add missing rules from json plugin ([7a53d3c](https://github.com/DarkSheepSoftware/eslint/commit/7a53d3c2ed9b75654bc558430a9cc1a856c3664b))
23
+ * Add missing rules from n plugin ([7b37d96](https://github.com/DarkSheepSoftware/eslint/commit/7b37d968aeb0a8c85025a7a2649216c6b270f120))
24
+ * Add missing rules from package-json plugin ([8c3de54](https://github.com/DarkSheepSoftware/eslint/commit/8c3de54eaba5cf69e3f4c6e562447f999b9793cf))
25
+ * Add missing rules from perfectionist plugin ([a6388de](https://github.com/DarkSheepSoftware/eslint/commit/a6388ded57d9b4261397f016e82b8f5f1060e497))
26
+ * Add missing rules from regexp plugin ([a2b4876](https://github.com/DarkSheepSoftware/eslint/commit/a2b487685b1a686aa35aa73a664d610b4b181a38))
27
+ * Add missing rules from style plugin ([9fbf9c6](https://github.com/DarkSheepSoftware/eslint/commit/9fbf9c654d4e866b0f2746fc350af42e1d8f7a57))
28
+ * Add missing rules from unicorn plugin ([0e56541](https://github.com/DarkSheepSoftware/eslint/commit/0e56541a56e78a9ec71f009e3f9f234a3c40c0f8))
29
+ * Add missing rules from yml plugin ([41032f7](https://github.com/DarkSheepSoftware/eslint/commit/41032f75959f903fedb690514996dbfc844280d3))
30
+
31
+
32
+ ### ๐Ÿ“ฆ Dependencies
33
+
34
+ * **pkg:** update dependency @stylistic/eslint-plugin to v2.9.0 ([#662](https://github.com/DarkSheepSoftware/eslint/issues/662)) ([4b85376](https://github.com/DarkSheepSoftware/eslint/commit/4b853768d356814f159f058abcb430e109737acc))
35
+ * **pkg:** update dependency eslint-plugin-jsdoc to v50.3.1 ([#657](https://github.com/DarkSheepSoftware/eslint/issues/657)) ([9389881](https://github.com/DarkSheepSoftware/eslint/commit/9389881cc56556449dbc873c6ac1225370f8f7c3))
36
+ * **pkg:** update dependency eslint-plugin-n to v17.11.0 ([#667](https://github.com/DarkSheepSoftware/eslint/issues/667)) ([234542e](https://github.com/DarkSheepSoftware/eslint/commit/234542e0e5b6df46ba67247b238360c135367f12))
37
+ * **pkg:** update dependency eslint-plugin-n to v17.11.1 ([#669](https://github.com/DarkSheepSoftware/eslint/issues/669)) ([63ef4a8](https://github.com/DarkSheepSoftware/eslint/commit/63ef4a877e4715be62c6511ae7f3ce1628c0e4e2))
38
+ * **pkg:** update dependency eslint-plugin-perfectionist to v3.8.0 ([#656](https://github.com/DarkSheepSoftware/eslint/issues/656)) ([bfa5b29](https://github.com/DarkSheepSoftware/eslint/commit/bfa5b29a3c925d4aa1a89ff1d0bb4dde7a6b56cc))
39
+ * **pkg:** update dependency eslint-plugin-react to v7.37.1 ([#659](https://github.com/DarkSheepSoftware/eslint/issues/659)) ([ccc0c22](https://github.com/DarkSheepSoftware/eslint/commit/ccc0c22389bbebb0e4a1ac54c5402305a80839ce))
40
+ * **pkg:** update dependency eslint-plugin-unicorn to v56 ([#660](https://github.com/DarkSheepSoftware/eslint/issues/660)) ([98e84c6](https://github.com/DarkSheepSoftware/eslint/commit/98e84c6eacffb371ef82898e94a6ba352c9baccc))
41
+ * **pkg:** update eslint monorepo to v9.12.0 ([#661](https://github.com/DarkSheepSoftware/eslint/issues/661)) ([936ddbe](https://github.com/DarkSheepSoftware/eslint/commit/936ddbe85644c296b9edc0db0f4bc2de9297d263))
42
+ * **pkg:** update typescript-eslint monorepo to v8.8.0 ([#655](https://github.com/DarkSheepSoftware/eslint/issues/655)) ([ce22824](https://github.com/DarkSheepSoftware/eslint/commit/ce2282449ca77e228388d2f9b4e6bafbdf0cee18))
43
+ * **pkg:** update typescript-eslint monorepo to v8.8.1 ([#664](https://github.com/DarkSheepSoftware/eslint/issues/664)) ([abe4a28](https://github.com/DarkSheepSoftware/eslint/commit/abe4a285b988c6930c8295a5a230fd4af3a01bdc))
44
+
45
+
46
+ ### ๐Ÿงน Chores
47
+
48
+ * Fix comment spacing ([8af91a8](https://github.com/DarkSheepSoftware/eslint/commit/8af91a89747657944be9dadd2b865c86ba74500a))
49
+
3
50
  ## [6.4.3](https://github.com/DarkSheepSoftware/eslint/compare/v6.4.2...v6.4.3) (2024-09-30)
4
51
 
5
52
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@darksheep/eslint",
3
- "version": "6.4.3",
3
+ "version": "6.5.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/DarkSheepSoftware/eslint"
@@ -22,24 +22,23 @@
22
22
  "prepack": "tsc"
23
23
  },
24
24
  "dependencies": {
25
+ "@darksheep/environment": "3.0.9",
25
26
  "@eslint-community/eslint-plugin-eslint-comments": "4.4.0",
26
- "@eslint/js": "9.11.1",
27
- "@stylistic/eslint-plugin": "2.8.0",
28
- "@types/estree": "1.0.6",
29
- "@types/json-schema": "7.0.15",
30
- "@typescript-eslint/eslint-plugin": "8.7.0",
31
- "@typescript-eslint/parser": "8.7.0",
27
+ "@eslint/js": "9.12.0",
28
+ "@stylistic/eslint-plugin": "2.9.0",
29
+ "@typescript-eslint/eslint-plugin": "8.8.1",
30
+ "@typescript-eslint/parser": "8.8.1",
32
31
  "editorconfig": "2.0.0",
33
- "eslint-plugin-jsdoc": "50.3.0",
32
+ "eslint-plugin-jsdoc": "50.3.1",
34
33
  "eslint-plugin-jsonc": "2.16.0",
35
- "eslint-plugin-n": "17.10.3",
34
+ "eslint-plugin-n": "17.11.1",
36
35
  "eslint-plugin-package-json": "0.15.3",
37
- "eslint-plugin-perfectionist": "3.7.0",
36
+ "eslint-plugin-perfectionist": "3.8.0",
38
37
  "eslint-plugin-promise": "7.1.0",
39
- "eslint-plugin-react": "7.37.0",
38
+ "eslint-plugin-react": "7.37.1",
40
39
  "eslint-plugin-regexp": "2.6.0",
41
40
  "eslint-plugin-security": "3.0.1",
42
- "eslint-plugin-unicorn": "55.0.0",
41
+ "eslint-plugin-unicorn": "56.0.0",
43
42
  "eslint-plugin-unused-imports": "4.1.4",
44
43
  "eslint-plugin-yml": "1.14.0",
45
44
  "jsonc-eslint-parser": "2.4.0",
@@ -48,7 +47,7 @@
48
47
  "devDependencies": {
49
48
  "@darksheep/eslint-formatter-github": "2.0.1",
50
49
  "@types/node": "~20.16.0",
51
- "eslint": "~9.11.0",
50
+ "eslint": "~9.12.0",
52
51
  "type-fest": "~4.26.0",
53
52
  "typescript": "~5.6.0"
54
53
  },
@@ -91,7 +91,7 @@ const rules = {
91
91
  'consistent-this': [ 'error', 'that' ],
92
92
  'no-array-constructor': 'error',
93
93
  'no-lonely-if': 'error',
94
- 'no-negated-condition': 'error',
94
+ 'no-negated-condition': 'off', // unicorn/no-negated-condition
95
95
  'no-object-constructor': 'error',
96
96
  'no-nested-ternary': 'warn',
97
97
  'no-unneeded-ternary': 'warn',
@@ -108,8 +108,8 @@ const rules = {
108
108
  };
109
109
 
110
110
  /**
111
- * Get the ESLint base config
112
- * @returns {Promise<import('eslint').Linter.FlatConfig[]>}
111
+ * Get the ESLint base config.
112
+ * @returns {Promise<import('eslint').Linter.Config[]>}
113
113
  */
114
114
  export async function createEslintBaseConfig() {
115
115
  return [ {
@@ -1,6 +1,6 @@
1
1
  /**
2
- * Get the ESLint config for complexity checks
3
- * @returns {import('eslint').Linter.FlatConfig[]}
2
+ * Get the ESLint config for complexity checks.
3
+ * @returns {import('eslint').Linter.Config[]}
4
4
  */
5
5
  export function createEslintComplexityConfig() {
6
6
  return [ {
@@ -5,7 +5,7 @@ import { fileURLToPath } from 'node:url';
5
5
  import { findUp } from '../utilities/filesystem.js';
6
6
 
7
7
  /**
8
- * @param {import('node:url').URL} root root url
8
+ * @param {import('node:url').URL} root - Root url.
9
9
  * @returns {Promise<string[]>}
10
10
  */
11
11
  async function getGitignore(root) {
@@ -17,7 +17,7 @@ async function getGitignore(root) {
17
17
  const raw = await fs.readFile(path, 'utf8');
18
18
 
19
19
  return raw
20
- .split(/\r?\n|\r/)
20
+ .split(/\r?\n|\r/u)
21
21
  .filter(Boolean);
22
22
  } catch (error) {
23
23
  if (/** @type {NodeJS.ErrnoException} */ (error).code === 'ENOENT') {
@@ -29,9 +29,9 @@ async function getGitignore(root) {
29
29
  }
30
30
 
31
31
  /**
32
- * Get basic ESLint ignores config
33
- * @param {import('node:url').URL} root root url
34
- * @returns {Promise<import('eslint').Linter.FlatConfig[]>}
32
+ * Get basic ESLint ignores config.
33
+ * @param {import('node:url').URL} root - Root url.
34
+ * @returns {Promise<import('eslint').Linter.Config[]>}
35
35
  */
36
36
  export async function createEslintIgnoresConfig(root) {
37
37
  const ignores = await getGitignore(root);
@@ -1,8 +1,8 @@
1
1
  import js from '@eslint/js';
2
2
 
3
3
  /**
4
- * Get recommended ESLint config
5
- * @returns {Promise<import('eslint').Linter.FlatConfig[]>}
4
+ * Get recommended ESLint config.
5
+ * @returns {Promise<import('eslint').Linter.Config[]>}
6
6
  */
7
7
  export async function createEslintRecommendsConfig() {
8
8
  return [ {
@@ -11,9 +11,9 @@ const rules = {
11
11
  };
12
12
 
13
13
  /**
14
- * Get basic ESLint style config
15
- * @param {import('node:url').URL} root root url
16
- * @returns {Promise<import('eslint').Linter.FlatConfig[]>}
14
+ * Get basic ESLint style config.
15
+ * @param {import('node:url').URL} root - Root url.
16
+ * @returns {Promise<import('eslint').Linter.Config[]>}
17
17
  */
18
18
  export async function createStyleConfig(root) {
19
19
  return [
@@ -1,7 +1,9 @@
1
1
  import { relative } from 'node:path';
2
2
 
3
+ import { getEnvString } from '@darksheep/environment';
4
+
3
5
  /**
4
- * @param {import('eslint').Linter.LintMessage[][]} files some messages
6
+ * @param {import('eslint').Linter.LintMessage[][]} files - Some messages.
5
7
  * @returns {number}
6
8
  */
7
9
  function getSeverity(files) {
@@ -25,11 +27,15 @@ function getSeverity(files) {
25
27
  return severity;
26
28
  }
27
29
 
28
- /** @type {(key: string) => boolean} */
29
- const toBoolean = (key) => (
30
- // eslint-disable-next-line n/no-process-env
31
- process.env[key] == null ? false : process.env[key] !== 'false'
32
- );
30
+ /** @type {(name: string) => boolean} */
31
+ const toBoolean = (name) => {
32
+ const value = getEnvString(name);
33
+ if (value == null) {
34
+ return false;
35
+ }
36
+
37
+ return value !== 'false';
38
+ };
33
39
 
34
40
  function isInEditor() {
35
41
  return (
@@ -42,11 +48,12 @@ function isInEditor() {
42
48
  );
43
49
  }
44
50
 
51
+ const point = getEnvString('ESLINT_LOG_POINT') ?? ' #';
45
52
  const icons = [
46
- '\u001B[32mโบ\u001B[0m', // circle - green
47
- '\u001B[34mโบ\u001B[0m', // circle - blue
48
- '\u001B[33mโบ\u001B[0m', // circle - yellow
49
- '\u001B[31mโบ\u001B[0m', // circle - red
53
+ `\u001B[32m${point}\u001B[0m`, // circle - green
54
+ `\u001B[34m${point}\u001B[0m`, // circle - blue
55
+ `\u001B[33m${point}\u001B[0m`, // circle - yellow
56
+ `\u001B[31m${point}\u001B[0m`, // circle - red
50
57
  ];
51
58
 
52
59
  /** @type {Set<string>} */
@@ -65,7 +72,9 @@ export default {
65
72
  return messages.flat();
66
73
  }
67
74
 
68
- process.stdout.write(files.has(filename) ? '\r' : '\n');
75
+ if (files.size > 0) {
76
+ process.stdout.write(files.has(filename) ? '\r' : '\n');
77
+ }
69
78
  files.add(filename);
70
79
 
71
80
  const icon = icons[getSeverity(messages) + 1];
@@ -1,10 +1,10 @@
1
1
  /**
2
- * @param {import('eslint').Rule.RuleContext} context ESLint rule context
2
+ * @param {import('eslint').Rule.RuleContext} context - ESLint rule context.
3
3
  * @returns {import('eslint').Rule.RuleListener}
4
4
  */
5
5
  const preferInstance = (context) => ({
6
6
  /**
7
- * @param {import('eslint').Rule.Node} node The AST function node
7
+ * @param {import('eslint').Rule.Node} node - The AST function node.
8
8
  * @returns {void}
9
9
  */
10
10
  'CallExpression[callee.object.name = "Array"][callee.property.name = "isArray"]': (node) => {
@@ -27,12 +27,12 @@ const preferInstance = (context) => ({
27
27
  });
28
28
 
29
29
  /**
30
- * @param {import('eslint').Rule.RuleContext} context ESLint rule context
30
+ * @param {import('eslint').Rule.RuleContext} context - ESLint rule context.
31
31
  * @returns {import('eslint').Rule.RuleListener}
32
32
  */
33
33
  const preferIsArray = (context) => ({
34
34
  /**
35
- * @param {import('eslint').Rule.Node} node The AST function node
35
+ * @param {import('eslint').Rule.Node} node - The AST function node.
36
36
  * @returns {void}
37
37
  */
38
38
  'BinaryExpression[operator="instanceof"][right.type="Identifier"][right.name="Array"]': (node) => {
@@ -1,14 +1,14 @@
1
1
  /**
2
- * @param {string} optionName name of the property option
3
- * @param {import('eslint').Rule.RuleContext} context ESLint rule context
4
- * @param {string} message error message on report
2
+ * @param {string} optionName - Name of the property option.
3
+ * @param {import('eslint').Rule.RuleContext} context - ESLint rule context.
4
+ * @param {string} message - Error message on report.
5
5
  * @returns {(node: import('eslint').Rule.Node) => void}
6
6
  */
7
7
  function createReporter(optionName, context, message) {
8
8
  const [ options ] = context.options;
9
9
 
10
10
  /**
11
- * @param {import('eslint').Rule.Node} node The AST function node
11
+ * @param {import('eslint').Rule.Node} node - The AST function node.
12
12
  * @returns {void}
13
13
  */
14
14
  function validateNode(node) {
@@ -52,9 +52,9 @@ const rule = {
52
52
  create: function (context) {
53
53
  return {
54
54
  /*
55
- * var b = a ? 'hello' : 'there';
56
- * if (a) return 'hello';
57
- */
55
+ * var b = a ? 'hello' : 'there';
56
+ * if (a) return 'hello';
57
+ */
58
58
  'Identifier.test': createReporter(
59
59
  'allowConditionalExpressionIdentifier',
60
60
  context,
@@ -62,9 +62,9 @@ const rule = {
62
62
  ),
63
63
 
64
64
  /*
65
- * var b = object.key ? 'hello' : 'there';
66
- * if (object.key) return 'hello';
67
- */
65
+ * var b = object.key ? 'hello' : 'there';
66
+ * if (object.key) return 'hello';
67
+ */
68
68
  'MemberExpression.test': createReporter(
69
69
  'allowConditionalExpressionMemberExpression',
70
70
  context,
@@ -72,9 +72,9 @@ const rule = {
72
72
  ),
73
73
 
74
74
  /*
75
- * var b = object?.key ? 'hello' : 'there';
76
- * if (object?.key) return 'hello';
77
- */
75
+ * var b = object?.key ? 'hello' : 'there';
76
+ * if (object?.key) return 'hello';
77
+ */
78
78
  'ChainExpression.test': createReporter(
79
79
  'allowConditionalExpressionChainExpression',
80
80
  context,
@@ -82,12 +82,12 @@ const rule = {
82
82
  ),
83
83
 
84
84
  /*
85
- * var b = a() ? 'hello' : 'there';
86
- * if (a()) return 'hello';
87
- *
88
- * var b = object.key() ? 'hello' : 'there';
89
- * if (object.key()) return 'hello';
90
- */
85
+ * var b = a() ? 'hello' : 'there';
86
+ * if (a()) return 'hello';
87
+ *
88
+ * var b = object.key() ? 'hello' : 'there';
89
+ * if (object.key()) return 'hello';
90
+ */
91
91
  'CallExpression.test': createReporter(
92
92
  'allowConditionalExpressionCallExpression',
93
93
  context,
@@ -95,9 +95,9 @@ const rule = {
95
95
  ),
96
96
 
97
97
  /*
98
- * one === 1 && two
99
- * one === 1 || two
100
- */
98
+ * one === 1 && two
99
+ * one === 1 || two
100
+ */
101
101
  'LogicalExpression[operator="&&"] > Identifier.right, LogicalExpression[operator="||"] > Identifier.right': createReporter(
102
102
  'allowLogicalExpressionIdentifier',
103
103
  context,
@@ -105,12 +105,12 @@ const rule = {
105
105
  ),
106
106
 
107
107
  /*
108
- * one === 1 && two()
109
- * one === 1 || two()
110
- *
111
- * one === 1 && object.two()
112
- * one === 1 || object.two()
113
- */
108
+ * one === 1 && two()
109
+ * one === 1 || two()
110
+ *
111
+ * one === 1 && object.two()
112
+ * one === 1 || object.two()
113
+ */
114
114
  'LogicalExpression[operator="&&"] > CallExpression.right, LogicalExpression[operator="||"] > CallExpression.right': createReporter(
115
115
  'allowLogicalExpressionCallExpression',
116
116
  context,
@@ -118,9 +118,9 @@ const rule = {
118
118
  ),
119
119
 
120
120
  /*
121
- * one === 1 && object.two
122
- * one === 1 || object.two
123
- */
121
+ * one === 1 && object.two
122
+ * one === 1 || object.two
123
+ */
124
124
  'LogicalExpression[operator="&&"] > MemberExpression.right, LogicalExpression[operator="||"] > MemberExpression.right': createReporter(
125
125
  'allowLogicalExpressionMemberExpression',
126
126
  context,
@@ -128,9 +128,9 @@ const rule = {
128
128
  ),
129
129
 
130
130
  /*
131
- * one === 1 && object?.two
132
- * one === 1 || object?.two
133
- */
131
+ * one === 1 && object?.two
132
+ * one === 1 || object?.two
133
+ */
134
134
  'LogicalExpression[operator="&&"] > ChainExpression.right, LogicalExpression[operator="||"] > ChainExpression.right': createReporter(
135
135
  'allowLogicalExpressionChainExpression',
136
136
  context,
@@ -138,9 +138,9 @@ const rule = {
138
138
  ),
139
139
 
140
140
  /*
141
- * one && two === 2
142
- * one || two === 2
143
- */
141
+ * one && two === 2
142
+ * one || two === 2
143
+ */
144
144
  'LogicalExpression[operator="&&"] > Identifier.left, LogicalExpression[operator="||"] > Identifier.left': createReporter(
145
145
  'allowLogicalExpressionIdentifier',
146
146
  context,
@@ -148,15 +148,15 @@ const rule = {
148
148
  ),
149
149
 
150
150
  /*
151
- * one() && two === 2
152
- * one() || two === 2
153
- *
154
- * object.one() && two === 2
155
- * object.one() || two === 2
156
- *
157
- * object?.one() && two === 2
158
- * object?.one() || two === 2
159
- */
151
+ * one() && two === 2
152
+ * one() || two === 2
153
+ *
154
+ * object.one() && two === 2
155
+ * object.one() || two === 2
156
+ *
157
+ * object?.one() && two === 2
158
+ * object?.one() || two === 2
159
+ */
160
160
  'LogicalExpression[operator="&&"] > CallExpression.left, LogicalExpression[operator="||"] > CallExpression.left': createReporter(
161
161
  'allowLogicalExpressionCallExpression',
162
162
  context,
@@ -164,9 +164,9 @@ const rule = {
164
164
  ),
165
165
 
166
166
  /*
167
- * object.one && two === 2
168
- * object.one || two === 2
169
- */
167
+ * object.one && two === 2
168
+ * object.one || two === 2
169
+ */
170
170
  'LogicalExpression[operator="&&"] > MemberExpression.left, LogicalExpression[operator="||"] > MemberExpression.left': createReporter(
171
171
  'allowLogicalExpressionMemberExpression',
172
172
  context,
@@ -174,9 +174,9 @@ const rule = {
174
174
  ),
175
175
 
176
176
  /*
177
- * object?.one && two === 2
178
- * object?.one || two === 2
179
- */
177
+ * object?.one && two === 2
178
+ * object?.one || two === 2
179
+ */
180
180
  'LogicalExpression[operator="&&"] > ChainExpression.left, LogicalExpression[operator="||"] > ChainExpression.left': createReporter(
181
181
  'allowLogicalExpressionChainExpression',
182
182
  context,
@@ -12,7 +12,7 @@ const rule = {
12
12
  create: function (context) {
13
13
  return {
14
14
  /**
15
- * @param {import('eslint').Rule.Node} node The AST function node
15
+ * @param {import('eslint').Rule.Node} node - The AST function node.
16
16
  * @returns {void}
17
17
  */
18
18
  [selector]: (node) => {
@@ -5,7 +5,7 @@ const rule = {
5
5
  create: function (context) {
6
6
  return {
7
7
  /**
8
- * @param {import('eslint').Rule.Node} node The AST function node
8
+ * @param {import('eslint').Rule.Node} node - The AST function node.
9
9
  * @returns {void}
10
10
  */
11
11
  SequenceExpression: (node) => {
package/src/index.js CHANGED
@@ -47,8 +47,8 @@ const configBuilders = [
47
47
  ];
48
48
 
49
49
  /**
50
- * @param {import('node:url').URL} root The root url object for the project config
51
- * @returns {Promise<import('eslint').Linter.FlatConfig[]>}
50
+ * @param {import('node:url').URL} root - The root url object for the project config.
51
+ * @returns {Promise<import('eslint').Linter.Config[]>}
52
52
  */
53
53
  async function createConfigUrl(root) {
54
54
  const configs = await Promise.all(
@@ -59,8 +59,8 @@ async function createConfigUrl(root) {
59
59
  }
60
60
 
61
61
  /**
62
- * @param {string | import('node:url').URL} root root url
63
- * @returns {Promise<import('eslint').Linter.FlatConfig[]>}
62
+ * @param {string | import('node:url').URL} root - Root url.
63
+ * @returns {Promise<import('eslint').Linter.Config[]>}
64
64
  */
65
65
  export async function createConfig(root) {
66
66
  if (root instanceof URL) {
@@ -71,11 +71,15 @@ export async function createConfig(root) {
71
71
  throw new TypeError('Invalid file root');
72
72
  }
73
73
 
74
- root = root
75
- // This is to remove: file:/ or file:///
76
- .replace(/^file:\/*/, '/')
77
- // This is prevent ?time=<stamp>
78
- .replace(/\?.*$/, '');
74
+ const [ filepath ] = root
75
+ // This is to remove: file:/ or file:///
76
+ .replace(/^file:\/*/u, '/')
77
+ // This is prevent ?time=<stamp>
78
+ .split('?', 1);
79
79
 
80
- return createConfigUrl(pathToFileURL(root));
80
+ if (filepath == null) {
81
+ throw new Error('Cannot compute filepath');
82
+ }
83
+
84
+ return createConfigUrl(pathToFileURL(filepath));
81
85
  }
@@ -1,8 +1,8 @@
1
1
  import eslintComments from '@eslint-community/eslint-plugin-eslint-comments';
2
2
 
3
3
  /**
4
- * Get ESLint config for comments check
5
- * @returns {import('eslint').Linter.FlatConfig[]}
4
+ * Get ESLint config for comments check.
5
+ * @returns {import('eslint').Linter.Config[]}
6
6
  */
7
7
  export function createEslintCommentsConfig() {
8
8
  return [
@@ -19,8 +19,8 @@ export function createEslintCommentsConfig() {
19
19
  'eslint-comments/no-unused-disable': 'error',
20
20
  'eslint-comments/no-unused-enable': 'error',
21
21
 
22
- // 'line-comment-position': 'off',
23
- // 'multiline-comment-style': 'off',
22
+ 'line-comment-position': 'off',
23
+ 'multiline-comment-style': 'off',
24
24
  'no-inline-comments': 'off',
25
25
  },
26
26
  },
@@ -4,9 +4,9 @@ import { getTypescriptFiles } from '../utilities/eslint-files.js';
4
4
  import { getPackageJson } from '../utilities/package.js';
5
5
 
6
6
  /**
7
- * Get ESLint config for js docs
8
- * @param {URL} root The root of the package being linted
9
- * @returns {Promise<import('eslint').Linter.FlatConfig[]>}
7
+ * Get ESLint config for JSDoc.
8
+ * @param {URL} root - The root of the package being linted.
9
+ * @returns {Promise<import('eslint').Linter.Config[]>}
10
10
  */
11
11
  export async function createEslintJSDocConfig(root) {
12
12
  const tsPackage = await getPackageJson(root, 'typescript');
@@ -19,37 +19,65 @@ export async function createEslintJSDocConfig(root) {
19
19
  settings: {
20
20
  jsdoc: {
21
21
  mode: 'typescript',
22
- // Prefer 'Object' over 'object'
23
- preferredTypes: { object: 'Object' },
22
+ preferredTypes: { object: [ 'Object' ] },
24
23
  },
25
24
  },
26
25
  rules: {
27
26
  'jsdoc/check-access': 'warn',
28
27
  'jsdoc/check-alignment': 'warn',
28
+ 'jsdoc/check-examples': 'off',
29
+ 'jsdoc/check-indentation': 'off',
30
+ 'jsdoc/check-line-alignment': [ 'error', 'never', { customSpacings: { postDelimiter: 1, postTag: 1, postType: 1, postName: 1 } } ],
29
31
  'jsdoc/check-param-names': 'warn',
30
32
  'jsdoc/check-property-names': 'warn',
33
+ 'jsdoc/check-syntax': 'error',
31
34
  'jsdoc/check-tag-names': 'warn',
35
+ 'jsdoc/check-template-names': 'off',
36
+ 'jsdoc/check-types': typeChecks,
32
37
  'jsdoc/check-values': 'warn',
38
+ 'jsdoc/convert-to-jsdoc-comments': 'off',
33
39
  'jsdoc/empty-tags': 'warn',
34
40
  'jsdoc/implements-on-classes': 'error',
41
+ 'jsdoc/imports-as-dependencies': 'off',
35
42
  'jsdoc/informative-docs': 'warn',
43
+ 'jsdoc/lines-before-block': 'off',
44
+ 'jsdoc/match-description': 'off',
45
+ 'jsdoc/match-name': 'off',
46
+ 'jsdoc/multiline-blocks': 'off',
47
+ 'jsdoc/no-bad-blocks': 'warn',
48
+ 'jsdoc/no-blank-block-descriptions': 'error',
49
+ 'jsdoc/no-blank-blocks': 'error',
36
50
  'jsdoc/no-defaults': 'warn',
51
+ 'jsdoc/no-missing-syntax': 'off',
37
52
  'jsdoc/no-multi-asterisks': 'warn',
38
- 'jsdoc/require-jsdoc': [ 1, { publicOnly: true } ],
39
- 'jsdoc/require-param': 'warn',
53
+ 'jsdoc/no-restricted-syntax': 'off',
54
+ 'jsdoc/no-undefined-types': typeChecks,
55
+ 'jsdoc/require-asterisk-prefix': 'error',
56
+ 'jsdoc/require-description-complete-sentence': 'error',
57
+ 'jsdoc/require-description': 'off',
58
+ 'jsdoc/require-example': 'off',
59
+ 'jsdoc/require-file-overview': 'off', // Could automatically add a licence?
60
+ 'jsdoc/require-hyphen-before-param-description': [ 'error', 'always' ],
61
+ 'jsdoc/require-jsdoc': [ 'warn', { publicOnly: true } ],
40
62
  'jsdoc/require-param-description': 'warn',
41
63
  'jsdoc/require-param-name': 'warn',
42
64
  'jsdoc/require-param-type': 'warn',
43
- 'jsdoc/require-property': 'warn',
65
+ 'jsdoc/require-param': 'warn',
44
66
  'jsdoc/require-property-description': 'warn',
45
67
  'jsdoc/require-property-name': 'warn',
46
68
  'jsdoc/require-property-type': 'warn',
47
- 'jsdoc/require-returns': 'warn',
69
+ 'jsdoc/require-property': 'warn',
48
70
  'jsdoc/require-returns-check': 'warn',
71
+ 'jsdoc/require-returns-description': 'off',
49
72
  'jsdoc/require-returns-type': 'warn',
50
-
51
- 'jsdoc/check-types': typeChecks,
52
- 'jsdoc/no-undefined-types': typeChecks,
73
+ 'jsdoc/require-returns': 'warn',
74
+ 'jsdoc/require-template': 'off',
75
+ 'jsdoc/require-throws': 'off',
76
+ 'jsdoc/require-yields-check': 'off',
77
+ 'jsdoc/require-yields': 'off',
78
+ 'jsdoc/sort-tags': 'error',
79
+ 'jsdoc/tag-lines': 'off',
80
+ 'jsdoc/text-escaping': 'off',
53
81
  'jsdoc/valid-types': typeChecks,
54
82
  },
55
83
  },