linter-bundle 2.9.0 → 2.11.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,52 @@ 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/v2.9.0...HEAD)
9
+ [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v2.11.0...HEAD)
10
+
11
+ ## [2.11.0] - 2020.03.12
12
+
13
+ ### Added
14
+
15
+ - Ensures that the ["overrides"](https://docs.npmjs.com/cli/v8/configuring-npm/package-json#overrides) and ["resolutions"](https://classic.yarnpkg.com/en/docs/selective-version-resolutions/) configuration in the `package.json` is up-to-date for linter dependencies, to prevent errors with unknown
16
+ linter rules or options.
17
+
18
+ ### Changed
19
+
20
+ - [eslint] Updated `eslint` from `8.10.0` to `8.11.0`
21
+ - [eslint] Update `eslint-plugin-jsdoc` from `37.9.7` to `38.0.2`
22
+ - [eslint] Disabled [`unicorn/prefer-json-parse-buffer`](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-json-parse-buffer.md) rule, as [TypeScript states](https://github.com/microsoft/TypeScript/issues/11842) that string needs to be used as of the ES specification.
23
+
24
+ [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v2.10.1...v2.11.0)
25
+
26
+ ## [2.10.1] - 2020.03.11
27
+
28
+ ### Fixed
29
+
30
+ - [eslint/override-react] Fix naming `warnOnDuplicates` option of [`react/jsx-key`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-key.md) rule
31
+
32
+ [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v2.10.0...v2.10.1)
33
+
34
+ ## [2.10.0] - 2022.03.10
35
+
36
+ ### Changed
37
+
38
+ - [stylelint] Remove `"before-comment"` exception in `scss/dollar-variable-empty-line-after` rule
39
+ - [eslint] Updated `@typescript-eslint/eslint-plugin` from `5.12.1` to `5.14.0`
40
+ - [eslint] Updated `@typescript-eslint/parser` from `5.12.1` to `5.14.0`
41
+ - [eslint] Updated `eslint` from `8.9.0` to `8.10.0`
42
+ - [eslint] Updated `eslint-plugin-jsdoc` from `37.9.4` to `37.9.7`
43
+ - [eslint] Updated `eslint-plugin-react` from `7.28.0` to `7.29.3`
44
+ - [stylelint] Updated `stylelint` from `14.5.2` to `14.5.3`
45
+
46
+ ### Added
47
+
48
+ - [eslint] Make use of new [`@typescript-eslint/no-redundant-type-constituents`](https://typescript-eslint.io/rules/no-redundant-type-constituents/) rule
49
+ - [eslint/override-react] Make use of new [`react/hook-use-state`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/hook-use-state.md) rule
50
+ - [eslint/override-react] Set new `propElementValues` option to "always" for [`react/jsx-curly-brace-presence`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-curly-brace-presence.md) rule
51
+ - [eslint/override-react] Make use of new [`react/iframe-missing-sandbox`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/iframe-missing-sandbox.md) rule
52
+ - [eslint/override-react] Make use of new `warnDuplicates` option of [`react/jsx-key`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-key.md) rule
53
+
54
+ [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v2.9.0...v2.10.0)
10
55
 
11
56
  ## [2.9.0] - 2022.02.23
12
57
 
package/TODO.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # @todo
2
2
 
3
+ - Make git diff-branch configurable
4
+ on GitHub Actions this could be used:
5
+ - run: git diff --name-only -z origin/${GITHUB_BASE_REF}
6
+ Is there a variable with includes origin/ already?
7
+
3
8
  Some tools like Gatsby ship deprecated dependencies of eslint and @typescript-eslint.
4
9
  Since npm installs packages alphabetically, the outdated `gatsby` dependencies are installed in the `node_modules` root, instead of the newer `linter-bundle` dependencies. Since the old versions often do not support new rules or new options, this may cause linting to fail with errors like this:
5
10
 
package/eslint/index.js CHANGED
@@ -641,6 +641,7 @@ module.exports = {
641
641
  '@typescript-eslint/no-non-null-asserted-optional-chain': 'error',
642
642
  '@typescript-eslint/no-parameter-properties': 'error',
643
643
  '@typescript-eslint/no-redeclare': ['error', { ignoreDeclarationMerge: true }],
644
+ '@typescript-eslint/no-redundant-type-constituents': 'error',
644
645
  '@typescript-eslint/no-require-imports': 'error',
645
646
  '@typescript-eslint/no-shadow': 'error',
646
647
  '@typescript-eslint/no-this-alias': 'error',
@@ -968,7 +969,7 @@ module.exports = {
968
969
  'unicorn/prefer-dom-node-text-content': 'error',
969
970
  'unicorn/prefer-export-from': ['error', { ignoreUsedVariables: true }],
970
971
  'unicorn/prefer-includes': 'error',
971
- 'unicorn/prefer-json-parse-buffer': 'error',
972
+ 'unicorn/prefer-json-parse-buffer': 'off', // TypeScript states that string needs to be used as of the ES specification. @see https://github.com/microsoft/TypeScript/issues/11842
972
973
  'unicorn/prefer-keyboard-event-key': 'error',
973
974
  'unicorn/prefer-math-trunc': 'error',
974
975
  'unicorn/prefer-modern-dom-apis': 'error',
@@ -66,6 +66,7 @@ module.exports = {
66
66
  namedComponents: 'arrow-function',
67
67
  unnamedComponents: 'arrow-function'
68
68
  }],
69
+ 'react/hook-use-state': 'error',
69
70
  'react/no-access-state-in-setstate': 'error',
70
71
  'react/no-array-index-key': 'error',
71
72
  'react/no-arrow-function-lifecycle': 'error',
@@ -140,7 +141,7 @@ module.exports = {
140
141
  'react/jsx-handler-names': 'off', // @todo There should be an option which checks if the function is used multiple times in a class (like this.closeTooltip()) - in that case, the 'handle' prefix should not be mandatory
141
142
  'react/jsx-indent': ['error', 'tab', { checkAttributes: true, indentLogicalExpressions: true }],
142
143
  'react/jsx-indent-props': ['error', 'tab'],
143
- 'react/jsx-key': ['error', { checkKeyMustBeforeSpread: true }],
144
+ 'react/jsx-key': ['error', { checkKeyMustBeforeSpread: true, warnOnDuplicates: true }],
144
145
  'react/jsx-max-depth': ['error', { max: 8 }],
145
146
  'react/jsx-max-props-per-line': ['error', { maximum: { single: 5, multi: 1 } }],
146
147
  'react/no-adjacent-inline-elements': 'off', // @todo There is an issue if inline and block elements are mixed. Simple example: `<span>Text</span><br />` here, the space between the SPAN and BR should not be forced, because a space at the end of a line does not make sense.
@@ -155,7 +156,7 @@ module.exports = {
155
156
  'react/jsx-no-undef': 'error',
156
157
  'react/jsx-no-useless-fragment': 'error',
157
158
  'react/jsx-one-expression-per-line': ['off', { allow: 'single-child' }], // @todo Doesn't work with something like "Text <a href="...">Link</a> More Text", which should be valid
158
- 'react/jsx-curly-brace-presence': 'error',
159
+ 'react/jsx-curly-brace-presence': ['error', { propElementValues: 'always' }],
159
160
  'react/jsx-fragments': ['error', 'element'],
160
161
  'react/jsx-pascal-case': ['error', { allowAllCaps: true }],
161
162
  'react/jsx-props-no-multi-spaces': 'error',
@@ -0,0 +1,62 @@
1
+ /**
2
+ * @file Ensures that the "overrides" and "resolutions" of the project where linter-bundle is used, match to the versions used in the linter-bundle itself.
3
+ *
4
+ * @see https://docs.npmjs.com/cli/v8/configuring-npm/package-json#overrides
5
+ * @see https://classic.yarnpkg.com/en/docs/selective-version-resolutions/
6
+ */
7
+
8
+ const fs = require('fs');
9
+ const path = require('path');
10
+
11
+ /** @typedef {{ name: string; configuredVersion: string; expectedVersion: string; }} Dependency */
12
+
13
+ /**
14
+ * Detects outdated "overrides"/"resolutions" dependencies.
15
+ *
16
+ * @returns {{ overrides: Dependency[]; resolutions: Dependency[]; }} Either the input array, or an empty array, if the input array is not an array.
17
+ */
18
+ function validatePackageOverrides () {
19
+ const linterBundleDependencies = JSON.parse(fs.readFileSync(path.resolve(__dirname, '../package.json'), 'utf8')).dependencies;
20
+ const projectPackageJson = JSON.parse(fs.readFileSync(path.join(process.cwd(), 'package.json'), 'utf8'));
21
+
22
+ const overrides = [];
23
+ const resolutions = [];
24
+
25
+ if (typeof projectPackageJson.overrides === 'object' && projectPackageJson.overrides !== null) {
26
+ for (const [name, version] of Object.entries(projectPackageJson.overrides)) {
27
+ if (!(name in linterBundleDependencies)) {
28
+ continue;
29
+ }
30
+
31
+ if (version !== linterBundleDependencies[name]) {
32
+ overrides.push({
33
+ name,
34
+ configuredVersion: version,
35
+ expectedVersion: linterBundleDependencies[name]
36
+ });
37
+ }
38
+ }
39
+ }
40
+
41
+ if (typeof projectPackageJson.resolutions === 'object' && projectPackageJson.resolutions !== null) {
42
+ for (const [name, version] of Object.entries(projectPackageJson.resolutions)) {
43
+ if (!(name in linterBundleDependencies)) {
44
+ continue;
45
+ }
46
+
47
+ if (version !== linterBundleDependencies[name]) {
48
+ resolutions.push({
49
+ name,
50
+ configuredVersion: version,
51
+ expectedVersion: linterBundleDependencies[name]
52
+ });
53
+ }
54
+ }
55
+ }
56
+
57
+ return { overrides, resolutions };
58
+ }
59
+
60
+ module.exports = {
61
+ validatePackageOverrides
62
+ };
package/lint.js CHANGED
@@ -11,6 +11,8 @@ const tty = require('tty');
11
11
 
12
12
  const micromatch = require('micromatch');
13
13
 
14
+ const { validatePackageOverrides } = require('./helper/validate-package-overrides.js');
15
+
14
16
  /** @typedef {{ taskName: string; config: Partial<Record<string, (string | true)[]>>; }} TaskNameAndConfig */
15
17
  /** @typedef {TaskNameAndConfig & { command: string; options?: childProcess.ExecOptions; }} TaskSetup */
16
18
  /** @typedef {{ code: number; stdout: string; stderr: string; runtime: number; }} ProcessResult */
@@ -19,6 +21,22 @@ const micromatch = require('micromatch');
19
21
  const isTerminal = tty.isatty(1);
20
22
 
21
23
  void (async () => {
24
+ const outdatedOverrides = validatePackageOverrides();
25
+
26
+ if (outdatedOverrides.overrides.length > 0 || outdatedOverrides.resolutions.length > 0) {
27
+ if (outdatedOverrides.overrides.length > 0) {
28
+ process.stderr.write(`Outdated "overrides" in package.json detected:\n- ${outdatedOverrides.overrides.map((dependency) => `${dependency.name}: ${dependency.configuredVersion} is configured, but ${dependency.expectedVersion} is expected`).join('\n- ')}\n\n`);
29
+ }
30
+
31
+ if (outdatedOverrides.resolutions.length > 0) {
32
+ process.stderr.write(`Outdated "resolutions" in package.json detected:\n- ${outdatedOverrides.overrides.map((dependency) => `${dependency.name}: ${dependency.configuredVersion} is configured, but ${dependency.expectedVersion} is expected`).join('\n- ')}\n\n`);
33
+ }
34
+
35
+ process.exitCode = 1;
36
+
37
+ return;
38
+ }
39
+
22
40
  /** @type {{ diff: Promise<ProcessResult>; modified: Promise<ProcessResult>; deleted: Promise<ProcessResult>; } | undefined} */
23
41
  let gitFilesProcessPromise;
24
42
  /** @type {string[] | undefined} */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "linter-bundle",
3
- "version": "2.9.0",
3
+ "version": "2.11.0",
4
4
  "description": "Ready-to use bundle of linting tools, containing configurations for ESLint, stylelint and markdownlint.",
5
5
  "keywords": [
6
6
  "eslint",
@@ -39,26 +39,26 @@
39
39
  "check-outdated": "npx --yes -- check-outdated --ignore-pre-releases"
40
40
  },
41
41
  "dependencies": {
42
- "@typescript-eslint/eslint-plugin": "5.12.1",
43
- "@typescript-eslint/parser": "5.12.1",
44
- "eslint": "8.9.0",
42
+ "@typescript-eslint/eslint-plugin": "5.14.0",
43
+ "@typescript-eslint/parser": "5.14.0",
44
+ "eslint": "8.11.0",
45
45
  "eslint-import-resolver-typescript": "2.5.0",
46
46
  "eslint-import-resolver-webpack": "0.13.2",
47
47
  "eslint-plugin-eslint-comments": "3.2.0",
48
48
  "eslint-plugin-functional": "4.2.0",
49
49
  "eslint-plugin-import": "2.25.4",
50
50
  "eslint-plugin-jest": "26.1.1",
51
- "eslint-plugin-jsdoc": "37.9.4",
51
+ "eslint-plugin-jsdoc": "38.0.2",
52
52
  "eslint-plugin-jsx-a11y": "6.5.1",
53
53
  "eslint-plugin-node": "11.1.0",
54
54
  "eslint-plugin-promise": "6.0.0",
55
- "eslint-plugin-react": "7.28.0",
55
+ "eslint-plugin-react": "7.29.3",
56
56
  "eslint-plugin-react-hooks": "4.3.0",
57
57
  "eslint-plugin-unicorn": "41.0.0",
58
58
  "markdownlint-cli": "0.31.1",
59
59
  "micromatch": "4.0.4",
60
60
  "postcss-scss": "4.0.3",
61
- "stylelint": "14.5.2",
61
+ "stylelint": "14.5.3",
62
62
  "stylelint-declaration-block-no-ignored-properties": "2.5.0",
63
63
  "stylelint-order": "5.0.0",
64
64
  "stylelint-scss": "4.1.0",
@@ -72,8 +72,8 @@
72
72
  "devDependencies": {
73
73
  "@types/eslint": "8.4.1",
74
74
  "@types/micromatch": "4.0.2",
75
- "@types/node": "17.0.19",
75
+ "@types/node": "17.0.21",
76
76
  "stylelint-find-new-rules": "3.0.4",
77
- "typescript": "4.5.5"
77
+ "typescript": "4.6.2"
78
78
  }
79
79
  }
@@ -873,7 +873,7 @@ module.exports = {
873
873
  'scss/dollar-variable-empty-line-after': [
874
874
  'always',
875
875
  {
876
- except: ['last-nested', 'before-comment', 'before-dollar-variable']
876
+ except: ['last-nested', 'before-dollar-variable']
877
877
  }
878
878
  ],
879
879
  'scss/dollar-variable-first-in-block': [true, { ignore: ['comments', 'imports'] }],
package/types.d.ts CHANGED
@@ -10,6 +10,8 @@
10
10
  * @see https://stackoverflow.com/a/68452689/4449804
11
11
  */
12
12
 
13
+ /* eslint-disable @typescript-eslint/naming-convention -- We have to follow the naming conventions of the Linter rules here. */
14
+
13
15
  // @ts-expect-error -- False-positive
14
16
  declare namespace globalThis {
15
17
  // eslint-disable-next-line no-inner-declarations, vars-on-top, no-var -- False-positives