linter-bundle 2.10.0 → 2.11.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.
package/CHANGELOG.md CHANGED
@@ -6,7 +6,39 @@ 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.10.0...HEAD)
9
+ [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v2.11.1...HEAD)
10
+
11
+ ## [2.11.1] - 2022.03.13
12
+
13
+ ### Changed
14
+
15
+ - [eslint] Disabled `@typescript-eslint/no-redundant-type-constituents`, because of false positives with `Promise<... | never>`
16
+ - [eslint] Weaken `@typescript-eslint/naming-convention` rule to allow names with special characters for `objectLiteralProperty`.
17
+
18
+ [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v2.11.0...v2.11.1)
19
+
20
+ ## [2.11.0] - 2022.03.12
21
+
22
+ ### Added
23
+
24
+ - 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
25
+ linter rules or options.
26
+
27
+ ### Changed
28
+
29
+ - [eslint] Updated `eslint` from `8.10.0` to `8.11.0`
30
+ - [eslint] Updated `eslint-plugin-jsdoc` from `37.9.7` to `38.0.2`
31
+ - [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.
32
+
33
+ [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v2.10.1...v2.11.0)
34
+
35
+ ## [2.10.1] - 2022.03.11
36
+
37
+ ### Fixed
38
+
39
+ - [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
40
+
41
+ [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v2.10.0...v2.10.1)
10
42
 
11
43
  ## [2.10.0] - 2022.03.10
12
44
 
@@ -15,7 +47,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
15
47
  - [stylelint] Remove `"before-comment"` exception in `scss/dollar-variable-empty-line-after` rule
16
48
  - [eslint] Updated `@typescript-eslint/eslint-plugin` from `5.12.1` to `5.14.0`
17
49
  - [eslint] Updated `@typescript-eslint/parser` from `5.12.1` to `5.14.0`
18
- - [eslint] Updated `eslint` from `8.9.0` to `8.10.0`jsx-key:
50
+ - [eslint] Updated `eslint` from `8.9.0` to `8.10.0`
19
51
  - [eslint] Updated `eslint-plugin-jsdoc` from `37.9.4` to `37.9.7`
20
52
  - [eslint] Updated `eslint-plugin-react` from `7.28.0` to `7.29.3`
21
53
  - [stylelint] Updated `stylelint` from `14.5.2` to `14.5.3`
package/eslint/index.js CHANGED
@@ -561,10 +561,29 @@ module.exports = {
561
561
  },
562
562
  {
563
563
  selector: 'objectLiteralProperty',
564
+ // `__html` is a property of React's `dangerouslySetInnerHTML` object
564
565
  filter: '^__html$',
565
566
  types: ['string'],
566
567
  format: null
567
568
  },
569
+ {
570
+ // Allow properties which only contain digits
571
+ selector: 'objectLiteralProperty',
572
+ filter: '^\\d+$',
573
+ format: null
574
+ },
575
+ {
576
+ // Allow empty or one-character properties
577
+ selector: 'objectLiteralProperty',
578
+ filter: '^.?$',
579
+ format: null
580
+ },
581
+ {
582
+ // Allow properties which which don't contain an underscore (to prevent usage of "UPPER_CASE") and contain atleast 4 characters
583
+ selector: 'objectLiteralProperty',
584
+ filter: '^[^_]{4,}$',
585
+ format: null
586
+ },
568
587
  { selector: 'typeProperty', format: ['camelCase', 'PascalCase'] },
569
588
  {
570
589
  selector: 'typeProperty',
@@ -641,7 +660,7 @@ module.exports = {
641
660
  '@typescript-eslint/no-non-null-asserted-optional-chain': 'error',
642
661
  '@typescript-eslint/no-parameter-properties': 'error',
643
662
  '@typescript-eslint/no-redeclare': ['error', { ignoreDeclarationMerge: true }],
644
- '@typescript-eslint/no-redundant-type-constituents': 'error',
663
+ '@typescript-eslint/no-redundant-type-constituents': 'off', // False positive with Promise<... | never>
645
664
  '@typescript-eslint/no-require-imports': 'error',
646
665
  '@typescript-eslint/no-shadow': 'error',
647
666
  '@typescript-eslint/no-this-alias': 'error',
@@ -969,7 +988,7 @@ module.exports = {
969
988
  'unicorn/prefer-dom-node-text-content': 'error',
970
989
  'unicorn/prefer-export-from': ['error', { ignoreUsedVariables: true }],
971
990
  'unicorn/prefer-includes': 'error',
972
- 'unicorn/prefer-json-parse-buffer': 'error',
991
+ '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
973
992
  'unicorn/prefer-keyboard-event-key': 'error',
974
993
  'unicorn/prefer-math-trunc': 'error',
975
994
  'unicorn/prefer-modern-dom-apis': 'error',
@@ -141,7 +141,7 @@ module.exports = {
141
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
142
142
  'react/jsx-indent': ['error', 'tab', { checkAttributes: true, indentLogicalExpressions: true }],
143
143
  'react/jsx-indent-props': ['error', 'tab'],
144
- 'react/jsx-key': ['error', { checkKeyMustBeforeSpread: true, warnDuplicates: true }],
144
+ 'react/jsx-key': ['error', { checkKeyMustBeforeSpread: true, warnOnDuplicates: true }],
145
145
  'react/jsx-max-depth': ['error', { max: 8 }],
146
146
  'react/jsx-max-props-per-line': ['error', { maximum: { single: 5, multi: 1 } }],
147
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.
@@ -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.10.0",
3
+ "version": "2.11.1",
4
4
  "description": "Ready-to use bundle of linting tools, containing configurations for ESLint, stylelint and markdownlint.",
5
5
  "keywords": [
6
6
  "eslint",
@@ -41,14 +41,14 @@
41
41
  "dependencies": {
42
42
  "@typescript-eslint/eslint-plugin": "5.14.0",
43
43
  "@typescript-eslint/parser": "5.14.0",
44
- "eslint": "8.10.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.7",
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",
@@ -73,7 +73,7 @@
73
73
  "@types/eslint": "8.4.1",
74
74
  "@types/micromatch": "4.0.2",
75
75
  "@types/node": "17.0.21",
76
- "stylelint-find-new-rules": "3.0.4",
76
+ "stylelint-find-new-rules": "4.0.0",
77
77
  "typescript": "4.6.2"
78
78
  }
79
79
  }