linter-bundle 3.3.0 → 3.5.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
@@ -6,7 +6,46 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
- [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v3.3.0...HEAD)
9
+ [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v3.5.0...HEAD)
10
+
11
+ ## [3.5.0] - 2023-07-28
12
+
13
+ ### Changed
14
+
15
+ - [eslint] Updated `@typescript-eslint/eslint-plugin` from `6.1.0` to `6.2.0`
16
+ - [eslint] Updated `eslint-plugin-import` from `2.27.5` to `2.28.0`
17
+ - [eslint] Updated `eslint-plugin-jsdoc` from `46.4.4` to `46.4.5`
18
+ - [eslint] Updated `eslint-plugin-react` from `7.32.2` to `7.33.0`
19
+ - [eslint] Updated `eslint-plugin-unicorn` from `48.0.0` to `48.0.1`
20
+ - [eslint] Reactivated `unicorn/no-empty-file`
21
+ - [eslint] Activated `ignoreConditionalTests` and `ignoreMixedLogicalExpressions` options of [@typescript-eslint/prefer-nullish-coalescing](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/prefer-nullish-coalescing.md) rule
22
+ - [styleint] Set `ignoreFunctions` option to `/^custom-/u` of [`scss/function-no-unknown`](https://github.com/stylelint-scss/stylelint-scss/blob/master/src/rules/function-no-unknown/README.md) rule
23
+ - [stylelint] Ignore SCSS variables in [`declaration-property-value-no-unknown`](https://stylelint.io/user-guide/rules/declaration-property-value-no-unknown/) rule
24
+ - [stylelint] Ignore wrapping parentheses for `grid-template-areas` values in [`declaration-property-value-no-unknown`](https://stylelint.io/user-guide/rules/declaration-property-value-no-unknown/) rule
25
+
26
+ ### Added
27
+
28
+ - Replace the ESLint rule `class-methods-use-this` by the new [`@typescript-eslint/class-methods-use-this`](https://typescript-eslint.io/rules/class-methods-use-this/) rule
29
+
30
+ [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v3.4.0...v3.5.0)
31
+
32
+ ## [3.4.0] - 2023-07-20
33
+
34
+ ### Changed
35
+
36
+ - [eslint] Updated `@typescript-eslint` from `6.0.0` to `6.1.0`
37
+ - [eslint] Updated `eslint` from `8.44.0` to `8.45.0`
38
+ - [eslint] Updated `eslint-plugin-jsdoc` from `46.4.3` to `46.4.4`
39
+ - [eslint] Updated `eslint-plugin-unicorn` from `47.0.0` to `48.0.0`
40
+ - [stylelint] Updated `stylelint` from `15.10.1` to `15.10.2`
41
+ - [eslint] Moved `unicorn/import-style` configuration for `path` (unassigned: false, default: false, namespace: true, named: true) from `overrides-storybook` into the main configuration.
42
+ - [eslint/overrides-javascript] Activated [`unicorn/prefer-top-level-await`](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-top-level-await.md) rule for `*.mjs` files.
43
+
44
+ ### Fixed
45
+
46
+ - [stylelint] Fixed `Cannot find module 'node_modules/stylelint/bin/stylelint.js'` issue, if the file is called `stylelint.mjs`
47
+
48
+ [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v3.3.0...v3.4.0)
10
49
 
11
50
  ## [3.3.0] - 2023-07-13
12
51
 
package/eslint/index.js CHANGED
@@ -125,7 +125,7 @@ module.exports = {
125
125
  'brace-style': 'off', // Covered by @typescript-eslint/brace-style
126
126
  'camelcase': 'off', // Covered by @typescript-eslint/naming-convention
127
127
  'capitalized-comments': 'off',
128
- 'class-methods-use-this': ['error', { exceptMethods: ['componentDidMount', 'componentDidUpdate', 'componentWillUnmount', 'shouldComponentUpdate'] }],
128
+ 'class-methods-use-this': 'off', // Covered by @typescript-eslint/class-methods-use-this
129
129
  'comma-dangle': 'off', // Covered by @typescript-eslint/comma-dangle
130
130
  'comma-spacing': 'off', // Covered by @typescript-eslint/comma-spacing
131
131
  'comma-style': 'error',
@@ -423,9 +423,8 @@ module.exports = {
423
423
  }],
424
424
  '@typescript-eslint/brace-style': ['error', 'stroustrup', { allowSingleLine: true }],
425
425
  '@typescript-eslint/class-literal-property-style': 'error',
426
- '@typescript-eslint/comma-dangle': ['error', {
427
- generics: 'ignore'
428
- }],
426
+ '@typescript-eslint/class-methods-use-this': ['error', { exceptMethods: ['componentDidMount', 'componentDidUpdate', 'componentWillUnmount', 'shouldComponentUpdate'] }],
427
+ '@typescript-eslint/comma-dangle': ['error', { generics: 'ignore' }],
429
428
  '@typescript-eslint/comma-spacing': 'error',
430
429
  '@typescript-eslint/consistent-generic-constructors': 'error',
431
430
  '@typescript-eslint/consistent-indexed-object-style': 'error',
@@ -745,7 +744,7 @@ module.exports = {
745
744
  '@typescript-eslint/prefer-includes': 'error',
746
745
  '@typescript-eslint/prefer-literal-enum-member': 'error',
747
746
  '@typescript-eslint/prefer-namespace-keyword': 'error',
748
- '@typescript-eslint/prefer-nullish-coalescing': 'error',
747
+ '@typescript-eslint/prefer-nullish-coalescing': ['error', { ignoreConditionalTests: true, ignoreMixedLogicalExpressions: true }],
749
748
  '@typescript-eslint/prefer-optional-chain': 'error',
750
749
  '@typescript-eslint/prefer-readonly': 'error',
751
750
  '@typescript-eslint/prefer-readonly-parameter-types': ['off', { ignoreInferredTypes: true }], // @todo An interface should ensure that it's properties are readonly, not every usage of it
@@ -941,7 +940,16 @@ module.exports = {
941
940
  /([A-Za-z0-9]?[a-z0-9]+)*[A-Z]{2,4}([A-Za-z0-9]?[a-z0-9]+)*/u // Up to 4 Characters can be upper-case in a row (e.g. in `prepareDOM` or `SVGIcon`)
942
941
  ]
943
942
  }],
944
- 'unicorn/import-style': 'error',
943
+ 'unicorn/import-style': ['error', {
944
+ styles: {
945
+ path: {
946
+ unassigned: false,
947
+ default: false,
948
+ namespace: true,
949
+ named: true
950
+ }
951
+ }
952
+ }],
945
953
  'unicorn/new-for-builtins': 'error',
946
954
  'unicorn/no-abusive-eslint-disable': 'error',
947
955
  'unicorn/no-array-callback-reference': 'off', // If I use functions, they are the best option for this use-case
@@ -952,7 +960,7 @@ module.exports = {
952
960
  'unicorn/no-await-expression-member': 'error',
953
961
  'unicorn/no-console-spaces': 'error',
954
962
  'unicorn/no-document-cookie': 'error',
955
- 'unicorn/no-empty-file': 'off', // @todo False-positives since @typescript-eslint v6.0.0. @see https://github.com/sindresorhus/eslint-plugin-unicorn/issues/2175
963
+ 'unicorn/no-empty-file': 'error',
956
964
  'unicorn/no-for-loop': 'off', // @typescript-eslint/prefer-for-of
957
965
  'unicorn/no-hex-escape': 'error',
958
966
  'unicorn/no-instanceof-array': 'error',
@@ -972,7 +980,6 @@ module.exports = {
972
980
  'unicorn/no-unnecessary-await': 'error',
973
981
  'unicorn/no-unreadable-array-destructuring': 'error',
974
982
  'unicorn/no-unreadable-iife': 'error',
975
- 'unicorn/no-unsafe-regex': 'off',
976
983
  'unicorn/no-unused-properties': 'error',
977
984
  'unicorn/no-useless-fallback-in-spread': 'error',
978
985
  'unicorn/no-useless-promise-resolve-reject': 'error',
@@ -1021,13 +1028,13 @@ module.exports = {
1021
1028
  'unicorn/prefer-set-has': 'error',
1022
1029
  'unicorn/prefer-set-size': 'error',
1023
1030
  'unicorn/prefer-spread': 'off', // @todo Disabled till there a solution for the warning, that `slice()` on Typed-Arrays should be replaced (which is not possible). @see https://github.com/sindresorhus/eslint-plugin-unicorn/issues/1064
1024
- 'unicorn/prefer-string-replace-all': 'off', // @todo Available since 2020 in browsers. SHould this be preferred?
1031
+ 'unicorn/prefer-string-replace-all': 'off', // @todo Available since 2020 in browsers. Should this be preferred?
1025
1032
  'unicorn/prefer-string-slice': 'off', // @todo As of today (2020.08.24) and since the last 9 years, substr() is three times faster than slice() in Firefox.
1026
1033
  'unicorn/prefer-string-starts-ends-with': 'error',
1027
1034
  'unicorn/prefer-string-trim-start-end': 'error',
1028
1035
  'unicorn/prefer-switch': 'error',
1029
1036
  'unicorn/prefer-ternary': 'off', // We prefer readability over saving a few chars
1030
- 'unicorn/prefer-top-level-await': 'off', // @todo There should be a detection that this option is only activated on Node.js v14.8 environments and above (Check for "engine" property in package.json, and "node -v")
1037
+ 'unicorn/prefer-top-level-await': 'off', // @todo Available since 2021. Activate in 2024
1031
1038
  'unicorn/prefer-regexp-test': 'error',
1032
1039
  'unicorn/prefer-type-error': 'error',
1033
1040
  'unicorn/prevent-abbreviations': ['error', { ignore: ['args', 'i', 'j', 'i18n', 'ref', 'Ref', 'params', 'props', 'Props'] }],
@@ -7,11 +7,10 @@ const overridesJavaScript = require('./overrides-javascript');
7
7
  module.exports = {
8
8
  ...overridesJavaScript,
9
9
  overrides: [
10
+ ...overridesJavaScript.overrides,
10
11
  {
11
- ...overridesJavaScript.overrides[0],
12
+ files: ['*.js', '*.cjs', '*.mjs'],
12
13
  rules: {
13
- ...overridesJavaScript.overrides[0].rules,
14
-
15
14
  /**
16
15
  * typescript-eslint
17
16
  *
@@ -103,6 +103,12 @@ module.exports = {
103
103
  'unicorn/prevent-abbreviations': ['error', { ignore: ['args', 'dev', 'env', 'i', 'j', 'i18n', 'pkg', 'ref', 'Ref', 'req', 'res', 'setupDevServerMiddleware'] }],
104
104
  'unicorn/text-encoding-identifier-case': 'off'
105
105
  }
106
+ },
107
+ {
108
+ files: ['*.mjs'],
109
+ rules: {
110
+ 'unicorn/prefer-top-level-await': 'error'
111
+ }
106
112
  }
107
113
  ]
108
114
  };
@@ -23,23 +23,7 @@ module.exports = {
23
23
  *
24
24
  * @see https://github.com/import-js/eslint-plugin-import
25
25
  */
26
- 'import/no-nodejs-modules': 'off',
27
-
28
- /**
29
- * eslint-plugin-unicorn
30
- *
31
- * @see https://github.com/sindresorhus/eslint-plugin-unicorn
32
- */
33
- 'unicorn/import-style': ['error', {
34
- styles: {
35
- path: {
36
- unassigned: false,
37
- default: false,
38
- namespace: true,
39
- named: true
40
- }
41
- }
42
- }]
26
+ 'import/no-nodejs-modules': 'off'
43
27
  }
44
28
  },
45
29
  {
@@ -5,6 +5,7 @@
5
5
  /**
6
6
  * Ensures that the input `value` is an array, otherwise an empty array is returned.
7
7
  *
8
+ * @public
8
9
  * @template T
9
10
  * @param {T} value - The value which should be checked.
10
11
  * @returns {T extends Array<any> ? T : []} Either the input array, or an empty array, if the input array is not an array.
@@ -13,6 +13,7 @@ const path = require('path');
13
13
  /**
14
14
  * Detects if installed versions of dependencies don't match to the required dependencies.
15
15
  *
16
+ * @public
16
17
  * @returns {Dependency[]} An array of missing overrides (=wrong versions).
17
18
  */
18
19
  function findMissingOverrides () {
@@ -0,0 +1,32 @@
1
+ /**
2
+ * @file Returns the path to the Stylelint CLI script.
3
+ */
4
+
5
+ const fs = require('fs');
6
+ const path = require('path');
7
+
8
+ /**
9
+ * Returns if the project is using npm or yarn.
10
+ *
11
+ * @public
12
+ * @returns {string | null} Return the path to the Stylelint CLI script, or `null` if it can't be found.
13
+ */
14
+ function getStylelintPath () {
15
+ const stylelintLibPath = path.dirname(require.resolve('stylelint'));
16
+
17
+ for (const stylelintBinPath of [
18
+ path.join(stylelintLibPath, '../bin/stylelint.mjs'),
19
+ path.join(stylelintLibPath, '../bin/stylelint.js')
20
+ ]) {
21
+ if (fs.existsSync(stylelintBinPath)) {
22
+ return stylelintBinPath;
23
+ }
24
+ }
25
+
26
+ return null;
27
+ }
28
+
29
+ module.exports = {
30
+ getStylelintPath
31
+ };
32
+
@@ -8,6 +8,7 @@ const path = require('path');
8
8
  /**
9
9
  * Returns if the project is using npm or yarn.
10
10
  *
11
+ * @public
11
12
  * @returns {'none' | 'npm' | 'yarn' | 'both'} Returns which package manager name.
12
13
  */
13
14
  function isNpmOrYarn () {
@@ -9,6 +9,7 @@ const childProcess = require('child_process');
9
9
  /**
10
10
  * Executes a process asynchronously.
11
11
  *
12
+ * @public
12
13
  * @param {string} command - The process to execute.
13
14
  * @param {childProcess.ExecOptions | undefined} [options] - The options of the `childProcess.exec()` method.
14
15
  * @returns {Promise<ProcessResult>} An object containing the result of the process execution
@@ -13,6 +13,7 @@ const path = require('path');
13
13
  /**
14
14
  * Detects outdated "overrides"/"resolutions" dependencies.
15
15
  *
16
+ * @public
16
17
  * @returns {{ overrides: Dependency[]; resolutions: Dependency[]; }} Either the input array, or an empty array, if the input array is not an array.
17
18
  */
18
19
  function validatePackageOverrides () {
package/lint.js CHANGED
@@ -10,6 +10,7 @@ const tty = require('tty');
10
10
  const micromatch = require('micromatch');
11
11
 
12
12
  const { findMissingOverrides } = require('./helper/find-missing-overrides.js');
13
+ const { getStylelintPath } = require('./helper/get-stylelint-path.js');
13
14
  const { isNpmOrYarn } = require('./helper/is-npm-or-yarn.js');
14
15
  const { runProcess } = require('./helper/run-process.js');
15
16
  const { validatePackageOverrides } = require('./helper/validate-package-overrides.js');
@@ -115,10 +116,18 @@ void (async () => {
115
116
  });
116
117
  }
117
118
 
119
+ const stylelintBinPath = getStylelintPath();
120
+
121
+ if (stylelintBinPath === null) {
122
+ return generateDummyJobOutput(taskName, config, {
123
+ stderr: 'Stylelint CLI script not found.'
124
+ });
125
+ }
126
+
118
127
  return runTask({
119
128
  taskName,
120
129
  config,
121
- command: `node "${path.join(path.dirname(require.resolve('stylelint')), '../bin/stylelint.js')}" ${includes} --formatter unix`
130
+ command: `node "${stylelintBinPath}" ${includes} --formatter unix`
122
131
  });
123
132
  }
124
133
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "linter-bundle",
3
- "version": "3.3.0",
3
+ "version": "3.5.0",
4
4
  "description": "Ready-to use bundle of linting tools, containing configurations for ESLint, stylelint and markdownlint.",
5
5
  "keywords": [
6
6
  "eslint",
@@ -36,31 +36,31 @@
36
36
  "preversion": "npm run check-outdated && npm run lint",
37
37
  "postversion": "git push && git push --tags && npm publish",
38
38
  "stylelint-find-rules": "stylelint-find-new-rules ./stylelint/index.js",
39
- "validate-stylelint-options": "node ./validate-stylelint-options",
39
+ "validate-stylelint-options": "node ./validate-stylelint-options.mjs",
40
40
  "check-outdated": "npx --yes -- check-outdated --ignore-pre-releases"
41
41
  },
42
42
  "dependencies": {
43
- "@typescript-eslint/eslint-plugin": "6.0.0",
44
- "@typescript-eslint/parser": "6.0.0",
45
- "@typescript-eslint/utils": "6.0.0",
46
- "eslint": "8.44.0",
43
+ "@typescript-eslint/eslint-plugin": "6.2.0",
44
+ "@typescript-eslint/parser": "6.2.0",
45
+ "@typescript-eslint/utils": "6.2.0",
46
+ "eslint": "8.45.0",
47
47
  "eslint-import-resolver-typescript": "3.5.5",
48
48
  "eslint-import-resolver-webpack": "0.13.2",
49
49
  "eslint-plugin-eslint-comments": "3.2.0",
50
50
  "eslint-plugin-functional": "5.0.8",
51
- "eslint-plugin-import": "2.27.5",
51
+ "eslint-plugin-import": "2.28.0",
52
52
  "eslint-plugin-jest": "27.2.3",
53
- "eslint-plugin-jsdoc": "46.4.3",
53
+ "eslint-plugin-jsdoc": "46.4.5",
54
54
  "eslint-plugin-jsx-a11y": "6.7.1",
55
55
  "eslint-plugin-n": "16.0.1",
56
56
  "eslint-plugin-promise": "6.1.1",
57
- "eslint-plugin-react": "7.32.2",
57
+ "eslint-plugin-react": "7.33.0",
58
58
  "eslint-plugin-react-hooks": "4.6.0",
59
- "eslint-plugin-unicorn": "47.0.0",
59
+ "eslint-plugin-unicorn": "48.0.1",
60
60
  "markdownlint-cli": "0.35.0",
61
61
  "micromatch": "4.0.5",
62
62
  "postcss-scss": "4.0.6",
63
- "stylelint": "15.10.1",
63
+ "stylelint": "15.10.2",
64
64
  "stylelint-declaration-block-no-ignored-properties": "2.7.0",
65
65
  "stylelint-order": "6.0.3",
66
66
  "stylelint-scss": "5.0.1",
@@ -71,9 +71,9 @@
71
71
  "typescript": "^4.0.0"
72
72
  },
73
73
  "devDependencies": {
74
- "@types/eslint": "8.44.0",
74
+ "@types/eslint": "8.44.1",
75
75
  "@types/micromatch": "4.0.2",
76
- "@types/node": "20.4.2",
76
+ "@types/node": "20.4.5",
77
77
  "stylelint-find-new-rules": "4.1.0",
78
78
  "typescript": "5.1.6"
79
79
  }
@@ -155,7 +155,9 @@ module.exports = {
155
155
  true,
156
156
  {
157
157
  ignoreProperties: {
158
- 'initial-value': '/.+/'
158
+ 'initial-value': /.+/u,
159
+ 'grid-template-areas': /^\([^\u0000]+\)$/u, // Whole block wrapped in parentheses.
160
+ '/.+/': /((^|\s)\$[a-z])|/ui // SCSS variables
159
161
  }
160
162
  }
161
163
  ],
@@ -901,7 +903,8 @@ module.exports = {
901
903
  'scss/dollar-variable-empty-line-after': [
902
904
  'always',
903
905
  {
904
- except: ['last-nested', 'before-dollar-variable']
906
+ except: ['last-nested', 'before-dollar-variable'],
907
+ ignore: ['before-comment', 'inside-single-line-block']
905
908
  }
906
909
  ],
907
910
  'scss/dollar-variable-first-in-block': [true, { ignore: ['comments', 'imports'] }],
@@ -918,7 +921,7 @@ module.exports = {
918
921
  'scss/double-slash-comment-inline': null,
919
922
  'scss/double-slash-comment-whitespace-inside': 'always',
920
923
  'scss/function-color-relative': true,
921
- 'scss/function-no-unknown': true,
924
+ 'scss/function-no-unknown': [true, { ignoreFunctions: [/^custom-/u] }],
922
925
  'scss/function-quote-no-quoted-strings-inside': true,
923
926
  'scss/function-unquote-no-unquoted-strings-inside': true,
924
927
  'scss/map-keys-quotes': 'always',