linter-bundle 2.13.0 → 2.14.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
@@ -8,6 +8,21 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
8
8
 
9
9
  [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v2.13.0...HEAD)
10
10
 
11
+ ## [2.14.0] - 2022.05.05
12
+
13
+ ### Changed
14
+
15
+ - [general] Remove files from npm package which are only necessary for development
16
+ - [eslint] Updated `eslint-import-resolver-typescript` from `2.7.0` to `2.7.1`
17
+ - [eslint] Updated `@typescript-eslint` from `5.21.0` to `5.22.0`
18
+ - [eslint] Updated `eslint-plugin-jsdoc` from `39.2.8` to `39.2.9`
19
+ - [eslint] Updated `eslint-plugin-react-hooks` from `4.4.0` to `4.5.0`
20
+ - [stylelint] Updated `stylelint` from `14.7.1` to `14.8.2`
21
+ - [eslint] Make use of new [`@typescript-eslint/no-duplicate-enum-values`](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-duplicate-enum-values.md) rule
22
+ - [stylelint] Make use of new [`keyframe-block-no-duplicate-selectors`](https://github.com/stylelint/stylelint/blob/main/lib/rules/keyframe-block-no-duplicate-selectors/README.md) rule
23
+ - [stylelint] In the deployment process, ensure that the used Stylelint options are valid
24
+ - [stylelint] Fix invalid configuration of [`declaration-property-max-values`](https://github.com/stylelint/stylelint/blob/main/lib/rules/declaration-property-max-values/README.md) rule
25
+
11
26
  ## [2.13.0] - 2022.04.25
12
27
 
13
28
  ### Changed
@@ -26,11 +41,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
26
41
  - [eslint] Activate `allowExpressions` option of [`@typescript-eslint/explicit-function-return-type`](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/explicit-function-return-type.md) rule
27
42
  - [eslint/overrides-jsdoc] Set [`minLineCount` option to 2](https://github.com/gajus/eslint-plugin-jsdoc/issues/870) for `require-jsdoc` rule
28
43
  - [eslint] Reactivated the [`import/no-relative-packages`](https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-relative-packages.md) rule
29
- - [eslint] Make use of [`unicorn/no-useless-switch-case`](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-useless-switch-case.md) rule
30
- - [eslint] Make use of [`unicorn/prefer-modern-math-apis`](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-modern-math-apis.md) rule
31
- - [eslint] Make use of [`unicorn/no-unreadable-iife`](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-unreadable-iife.md) rule
44
+ - [eslint] Make use of new [`unicorn/no-useless-switch-case`](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-useless-switch-case.md) rule
45
+ - [eslint] Make use of new [`unicorn/prefer-modern-math-apis`](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-modern-math-apis.md) rule
46
+ - [eslint] Make use of new [`unicorn/no-unreadable-iife`](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-unreadable-iife.md) rule
32
47
  - [eslint] Add but disable [`unicorn/prefer-native-coercion-functions`](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-native-coercion-functions.md) rule, because this would produce inconsistency in the code and is harder to read
33
- - [stylelint] Set new [`selector-not-notation`](https://github.com/stylelint/stylelint/blob/main/lib/rules/selector-not-notation/README.md) rule to `"complex"`
48
+ - [stylelint] Set [`selector-not-notation`](https://github.com/stylelint/stylelint/blob/main/lib/rules/selector-not-notation/README.md) rule to `"complex"`
34
49
 
35
50
  [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v2.12.0...v2.13.0)
36
51
 
@@ -48,7 +63,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
48
63
  - [eslint] Updated `eslint-plugin-unicorn` from `41.0.0` to `41.0.1`
49
64
  - [stylelint] Updated `stylelint` from `14.5.3` to `14.6.1`
50
65
  - [stylelint] Updated `stylelint-scss` from `4.1.0` to `4.2.0`
51
- - Updated `micromatch` from `4.0.4` to `4.0.5`
66
+ - [general] Updated `micromatch` from `4.0.4` to `4.0.5`
52
67
  - [eslint] Make use of [`destructuredArrayIgnorePattern`](https://eslint.org/docs/rules/no-unused-vars#destructuredarrayignorepattern) of `@typescript-eslint/no-unused-vars` rule, to ignore variables with leading underscore.
53
68
  - [stylelint] Make use of [`declaration-property-max-values`](https://stylelint.io/user-guide/rules/list/declaration-property-max-values/) rule, and set `unprefixed-property-name` to `4`
54
69
  - [stylelint] Replace `function-no-unknown` by `scss/function-no-unknown`
@@ -68,7 +83,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
68
83
 
69
84
  ### Added
70
85
 
71
- - 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
86
+ - [general] 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
72
87
  linter rules or options.
73
88
 
74
89
  ### Changed
@@ -119,8 +134,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
119
134
 
120
135
  ### Added
121
136
 
122
- - `--timing` argument to show information how long each linting process was running.
123
- - Experimental `--git` argument to only lint (ESLint, Stylelint and Markdownlint) files which have been detected as changed (compared to the upstream branch) by Git
137
+ - [general] `--timing` argument to show information how long each linting process was running.
138
+ - [general] Experimental `--git` argument to only lint (ESLint, Stylelint and Markdownlint) files which have been detected as changed (compared to the upstream branch) by Git
124
139
 
125
140
  [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v2.8.4...v2.9.0)
126
141
 
@@ -358,7 +373,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
358
373
 
359
374
  ### Changed
360
375
 
361
- - The minimum required Node.js version is v14 now
376
+ - [general] The minimum required Node.js version is v14 now
362
377
  - [eslint] Updated `@typescript-eslint` from v4.31.0 to v4.31.1
363
378
  - [eslint] Updated `eslint-import-resolver-typescript` from v2.4.0 to v2.5.0
364
379
  - [eslint] Updated `eslint-plugin-jest` from v24.4.0 to v24.4.2
@@ -747,7 +762,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
747
762
 
748
763
  ### Changed
749
764
 
750
- - By default, the terminal output of the linters is printed only in case of failure to prevent unnecessary noise. Use `--verbose` to show their output even on success.
765
+ - [general] By default, the terminal output of the linters is printed only in case of failure to prevent unnecessary noise. Use `--verbose` to show their output even on success.
751
766
  - [stylelint] Disallow reserved ECMAScript keywords (`abstract`, `arguments`, `await`, `boolean`, `break`, `byte`, `case`, `catch`, `char`, `class`, `const`, `continue`, `debugger`, `default`, `delete`, `do`, `double`, `else`, `enum`, `eval`, `export`, `extends`, `false`, `final`, `finally`,
752
767
  `float`, `for`, `function`, `goto`, `if`, `implements`, `import`, `in`, `Infinity`, `instanceof`, `int`, `interface`, `let`, `long`, `NaN`, `native`, `new`, `null`, `package`, `private`, `protected`, `public`, `return`, `short`, `static`, `super`, `switch`, `synchronized`, `this`, `throw`,
753
768
  `throws`, `transient`, `true`, `try`, `typeof`, `undefined`, `var`, `void`, `volatile`, `while`, `with`, and `yield`) as class names
package/eslint/index.js CHANGED
@@ -628,6 +628,7 @@ module.exports = {
628
628
  '@typescript-eslint/no-confusing-non-null-assertion': 'error',
629
629
  '@typescript-eslint/no-confusing-void-expression': ['error', { ignoreArrowShorthand: true, ignoreVoidOperator: true }],
630
630
  '@typescript-eslint/no-dupe-class-members': 'error',
631
+ '@typescript-eslint/no-duplicate-enum-values': 'error',
631
632
  '@typescript-eslint/no-duplicate-imports': 'error',
632
633
  '@typescript-eslint/no-dynamic-delete': 'error',
633
634
  '@typescript-eslint/no-empty-function': 'error',
@@ -0,0 +1,47 @@
1
+ /**
2
+ * @file Executes a process asynchronously.
3
+ */
4
+
5
+ /** @typedef {{ code: number; stdout: string; stderr: string; runtime: number; }} ProcessResult */
6
+
7
+ const childProcess = require('child_process');
8
+
9
+ /**
10
+ * Executes a process asynchronously.
11
+ *
12
+ * @param {string} command - The process to execute.
13
+ * @param {childProcess.ExecOptions | undefined} [options] - The options of the `childProcess.exec()` method.
14
+ * @returns {Promise<ProcessResult>} An object containing the result of the process execution
15
+ */
16
+ async function runProcess (command, options) {
17
+ return new Promise((resolve) => {
18
+ const startTimestamp = performance.now();
19
+
20
+ /** @type {string[]} */
21
+ const stdout = [];
22
+
23
+ /** @type {string[]} */
24
+ const stderr = [];
25
+
26
+ const lintingProcess = childProcess.exec(command, options);
27
+
28
+ lintingProcess.stdout?.on('data', (/** @type {string} */data) => {
29
+ stdout.push(data);
30
+ });
31
+
32
+ lintingProcess.stderr?.on('data', (/** @type {string} */data) => {
33
+ stderr.push(data);
34
+ });
35
+
36
+ lintingProcess.on('exit', (code) => resolve({
37
+ code: code ?? 0,
38
+ stdout: stdout.join(''),
39
+ stderr: stderr.join(''),
40
+ runtime: performance.now() - startTimestamp
41
+ }));
42
+ });
43
+ }
44
+
45
+ module.exports = {
46
+ runProcess
47
+ };
package/lint.js CHANGED
@@ -4,18 +4,18 @@
4
4
  * @file Entry point of the linter-bundle.
5
5
  */
6
6
 
7
- const childProcess = require('child_process');
8
7
  const fs = require('fs');
9
8
  const path = require('path');
10
9
  const tty = require('tty');
11
10
 
12
11
  const micromatch = require('micromatch');
13
12
 
13
+ const { runProcess } = require('./helper/run-process.js');
14
14
  const { validatePackageOverrides } = require('./helper/validate-package-overrides.js');
15
15
 
16
+ /** @typedef {import('./helper/run-process').ProcessResult} ProcessResult */
16
17
  /** @typedef {{ taskName: string; config: Partial<Record<string, (string | true)[]>>; }} TaskNameAndConfig */
17
- /** @typedef {TaskNameAndConfig & { command: string; options?: childProcess.ExecOptions; }} TaskSetup */
18
- /** @typedef {{ code: number; stdout: string; stderr: string; runtime: number; }} ProcessResult */
18
+ /** @typedef {TaskNameAndConfig & { command: string; options?: import('child_process').ExecOptions; }} TaskSetup */
19
19
  /** @typedef {{ jobTitle: string; taskSetup: TaskSetup; job: Promise<ProcessResult>; }} Job */
20
20
 
21
21
  const isTerminal = tty.isatty(1);
@@ -378,42 +378,6 @@ function generateDummyJobOutput (taskName, config, output) {
378
378
  };
379
379
  }
380
380
 
381
- /**
382
- * Exectues a process asynchronously.
383
- *
384
- * @param {string} command - The process to execute.
385
- * @param {childProcess.ExecOptions | undefined} [options] - The options of the `childProcess.exec()` method.
386
- * @returns {Promise<ProcessResult>} An object containing the result of the process execution
387
- */
388
- async function runProcess (command, options) {
389
- return new Promise((resolve) => {
390
- const startTimestamp = performance.now();
391
-
392
- /** @type {string[]} */
393
- const stdout = [];
394
-
395
- /** @type {string[]} */
396
- const stderr = [];
397
-
398
- const lintingProcess = childProcess.exec(command, options);
399
-
400
- lintingProcess.stdout?.on('data', (/** @type {string} */data) => {
401
- stdout.push(data);
402
- });
403
-
404
- lintingProcess.stderr?.on('data', (/** @type {string} */data) => {
405
- stderr.push(data);
406
- });
407
-
408
- lintingProcess.on('exit', (code) => resolve({
409
- code: code ?? 0,
410
- stdout: stdout.join(''),
411
- stderr: stderr.join(''),
412
- runtime: performance.now() - startTimestamp
413
- }));
414
- });
415
- }
416
-
417
381
  /**
418
382
  * Returns the title (command line string) of a specific job.
419
383
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "linter-bundle",
3
- "version": "2.13.0",
3
+ "version": "2.14.0",
4
4
  "description": "Ready-to use bundle of linting tools, containing configurations for ESLint, stylelint and markdownlint.",
5
5
  "keywords": [
6
6
  "eslint",
@@ -32,15 +32,16 @@
32
32
  "publish:major": "npm version major",
33
33
  "publish:minor": "npm version minor",
34
34
  "publish:patch": "npm version patch",
35
- "lint": "node ./lint tsc ts md audit --min-severity=critical",
35
+ "lint": "npm run validate-stylelint-options && node ./lint tsc ts md audit --min-severity=critical",
36
36
  "preversion": "npm run check-outdated && npm run stylelint-find-rules && 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
40
  "check-outdated": "npx --yes -- check-outdated --ignore-pre-releases"
40
41
  },
41
42
  "dependencies": {
42
- "@typescript-eslint/eslint-plugin": "5.21.0",
43
- "@typescript-eslint/parser": "5.21.0",
43
+ "@typescript-eslint/eslint-plugin": "5.22.0",
44
+ "@typescript-eslint/parser": "5.22.0",
44
45
  "eslint": "8.14.0",
45
46
  "eslint-import-resolver-typescript": "2.7.1",
46
47
  "eslint-import-resolver-webpack": "0.13.2",
@@ -48,17 +49,17 @@
48
49
  "eslint-plugin-functional": "4.2.1",
49
50
  "eslint-plugin-import": "2.26.0",
50
51
  "eslint-plugin-jest": "26.1.5",
51
- "eslint-plugin-jsdoc": "39.2.8",
52
+ "eslint-plugin-jsdoc": "39.2.9",
52
53
  "eslint-plugin-jsx-a11y": "6.5.1",
53
54
  "eslint-plugin-node": "11.1.0",
54
55
  "eslint-plugin-promise": "6.0.0",
55
56
  "eslint-plugin-react": "7.29.4",
56
- "eslint-plugin-react-hooks": "4.4.0",
57
+ "eslint-plugin-react-hooks": "4.5.0",
57
58
  "eslint-plugin-unicorn": "42.0.0",
58
59
  "markdownlint-cli": "0.31.1",
59
60
  "micromatch": "4.0.5",
60
61
  "postcss-scss": "4.0.4",
61
- "stylelint": "14.7.1",
62
+ "stylelint": "14.8.2",
62
63
  "stylelint-declaration-block-no-ignored-properties": "2.5.0",
63
64
  "stylelint-order": "5.0.0",
64
65
  "stylelint-scss": "4.2.0",
@@ -70,10 +71,10 @@
70
71
  "typescript": "^4.0.0"
71
72
  },
72
73
  "devDependencies": {
73
- "@types/eslint": "8.4.1",
74
+ "@types/eslint": "8.4.2",
74
75
  "@types/micromatch": "4.0.2",
75
- "@types/node": "17.0.27",
76
+ "@types/node": "17.0.31",
76
77
  "stylelint-find-new-rules": "4.0.0",
77
- "typescript": "4.6.3"
78
+ "typescript": "4.6.4"
78
79
  }
79
80
  }
@@ -157,7 +157,7 @@ module.exports = {
157
157
  ]
158
158
  }
159
159
  ],
160
- 'declaration-property-max-values': [true, { 'unprefixed-property-name': 4 }],
160
+ 'declaration-property-max-values': { '/.*/': 4 },
161
161
  'declaration-no-important': [true, {
162
162
  severity: 'warning'
163
163
  }],
@@ -194,6 +194,7 @@ module.exports = {
194
194
  'function-whitespace-after': 'always',
195
195
  'hue-degree-notation': 'number', // @todo change that to 'angle'?
196
196
  'indentation': 'tab',
197
+ 'keyframe-block-no-duplicate-selectors': true,
197
198
  'keyframe-declaration-no-important': true,
198
199
  'keyframes-name-pattern': '^[a-z]+(-[a-z]+)*\\d*$',
199
200
  'length-zero-no-unit': true,
@@ -0,0 +1,52 @@
1
+ /**
2
+ * @file Ensures that stylelint options are valid by checking the `invalidOptionWarnings` property of the JSON response.
3
+ */
4
+
5
+ const fs = require('fs');
6
+ const os = require('os');
7
+ const path = require('path');
8
+
9
+ const { runProcess } = require('./helper/run-process.js');
10
+
11
+ void (async () => {
12
+ const temporaryPath = path.join(os.tmpdir(), 'linter-bundle-');
13
+
14
+ const folder = fs.mkdtempSync(temporaryPath);
15
+
16
+ const tempFilePath = path.join(folder, 'tmp.scss');
17
+
18
+ fs.writeFileSync(tempFilePath, '* {\n\tborder: 1px solid var(--color);\n\n\tcolor: var(--color);\n}\n', 'utf8');
19
+
20
+ const result = await runProcess(`stylelint -f json "${tempFilePath}"`);
21
+
22
+ fs.unlinkSync(tempFilePath);
23
+
24
+ if (result.stderr) {
25
+ process.stderr.write(result.stderr);
26
+
27
+ process.exitCode = 1;
28
+
29
+ return;
30
+ }
31
+
32
+ /**
33
+ * @type {import('stylelint').LintResult}
34
+ */
35
+ const { invalidOptionWarnings, warnings } = JSON.parse(result.stdout)[0];
36
+
37
+ if (warnings.length > 0) {
38
+ process.stderr.write(warnings.join('\n'));
39
+
40
+ process.exitCode = 1;
41
+
42
+ return;
43
+ }
44
+
45
+ if (invalidOptionWarnings.length > 0) {
46
+ process.stderr.write(`Invalid stylelint configuration:\n\n- ${invalidOptionWarnings.map(({ text }) => text).join('\n- ')}`);
47
+
48
+ process.exitCode = 1;
49
+
50
+ return;
51
+ }
52
+ })();
package/.eslintrc.js DELETED
@@ -1,12 +0,0 @@
1
- /**
2
- * @file Configuration used for linting the linter-bundle.
3
- */
4
-
5
- module.exports = {
6
- root: true,
7
- extends: [
8
- require.resolve('./eslint'),
9
- require.resolve('./eslint/overrides-javascript-lazy'),
10
- require.resolve('./eslint/overrides-jsdoc')
11
- ]
12
- };
@@ -1,3 +0,0 @@
1
- {
2
- "extends": "markdownlint/base.json"
3
- }
package/tsconfig.json DELETED
@@ -1,47 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- // General settings for code interpretation
4
- "target": "esnext",
5
- "module": "commonjs",
6
- "resolveJsonModule": true,
7
- "checkJs": true,
8
- "noEmit": true,
9
-
10
- "baseUrl": ".",
11
-
12
- // General settings for code generation
13
- "newLine": "LF",
14
-
15
- // Console output settings
16
- "pretty": true,
17
-
18
- // Code validation
19
- "allowUnreachableCode": false,
20
- "allowUnusedLabels": false,
21
- "alwaysStrict": true,
22
- "exactOptionalPropertyTypes": true,
23
- "forceConsistentCasingInFileNames": true,
24
- "keyofStringsOnly": false,
25
- "noFallthroughCasesInSwitch": true,
26
- "noImplicitAny": true,
27
- "noImplicitReturns": true,
28
- "noImplicitThis": true,
29
- "noImplicitUseStrict": false,
30
- "noPropertyAccessFromIndexSignature": true,
31
- "noUnusedLocals": true,
32
- "noUnusedParameters": true,
33
- "strict": true,
34
- "strictBindCallApply": true,
35
- "strictFunctionTypes": true,
36
- "strictNullChecks": true,
37
- "strictPropertyInitialization": true,
38
- "suppressExcessPropertyErrors": false,
39
- "suppressImplicitAnyIndexErrors": true,
40
- "useUnknownInCatchVariables": true
41
- },
42
- "include": [
43
- "./types.d.ts",
44
- "**/*.js",
45
- "./.eslintrc.js"
46
- ]
47
- }