linter-bundle 3.1.0 → 3.3.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 +45 -3
- package/README.md +1 -1
- package/eslint/index.js +1 -2
- package/eslint/overrides-javascript.js +0 -2
- package/eslint/overrides-jsdoc.js +3 -2
- package/eslint/rules/no-unnecessary-typeof.js +1 -2
- package/lint.js +3 -3
- package/package.json +15 -16
- package/stylelint/index.js +3 -1
- package/stylelint/plugins/stylelint-selector-no-empty.js +114 -0
- package/.gitattributes +0 -16
- package/validate-stylelint-options.js +0 -52
package/CHANGELOG.md
CHANGED
|
@@ -6,17 +6,59 @@ 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.
|
|
9
|
+
[Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v3.3.0...HEAD)
|
|
10
|
+
|
|
11
|
+
## [3.3.0] - 2023-07-13
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
|
|
15
|
+
- [general] Drop support for Node.js version v17 (v16 is still supported), as `@typescript-eslint` v6.0.0 doesn't support it anymore
|
|
16
|
+
- [eslint] Updated `@typescript-eslint` from `5.59.9` to `6.0.0`
|
|
17
|
+
- [eslint] Updated `eslint` from `8.42.0` to `8.44.0`
|
|
18
|
+
- [eslint] Updated `eslint-plugin-jest` from `27.2.1` to `27.2.3`
|
|
19
|
+
- [eslint] Updated `eslint-plugin-n` from `16.0.0` to `16.0.1`
|
|
20
|
+
- [eslint/overrides-jsdoc] Updated `eslint-plugin-jsdoc` from `46.2.4` to `46.4.3`
|
|
21
|
+
- [markdownlint] Updated `markdownlint-cli` from `0.34.0` to `0.35.0`
|
|
22
|
+
- [stylelint] Updated `stylelint` from `15.7.0` to `15.10.1`
|
|
23
|
+
- [stylelint] Updated `stylelint-scss` from `5.0.0` to `5.0.1`
|
|
24
|
+
- [eslint/overrides-jsdoc] Don't enforce line-breaks before `@throws` by the [`jsdoc/tag-lines`](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-tag-lines) rule
|
|
25
|
+
- [stylelint] Forked [`stylelint-selector-no-empty`](https://github.com/ssivanatarajan/stylelint-selector-no-empty), because it seems not to be regularly maintained anymore
|
|
26
|
+
|
|
27
|
+
### Added
|
|
28
|
+
|
|
29
|
+
- [stylelint] Make use of new [`media-feature-name-value-no-unknown`](https://github.com/stylelint/stylelint/blob/main/lib/rules/media-feature-name-value-no-unknown/README.md) rule
|
|
30
|
+
- [stylelint] Make use of new [`media-query-no-invalid`](https://github.com/stylelint/stylelint/blob/main/lib/rules/media-query-no-invalid/README.md) rule
|
|
31
|
+
- [eslint/overrides-javascript] Activated `@typescript-eslint/prefer-nullish-coalescing` for JavaScript file, as it is now supported in Node.js for a while.
|
|
32
|
+
- [eslint/overrides-javascript] Activated `@typescript-eslint/prefer-optional-chain` for JavaScript file, as it is now supported in Node.js for a while.
|
|
33
|
+
|
|
34
|
+
### Removed
|
|
35
|
+
|
|
36
|
+
- [eslint] Remove silently removed `@typescript-eslint/no-parameter-properties` rule
|
|
37
|
+
- [eslint] Disabled `unicorn/no-empty-file`, because of [false-positives](https://github.com/sindresorhus/eslint-plugin-unicorn/issues/2175) with `@typescript-eslint v6.0.0`
|
|
38
|
+
|
|
39
|
+
[Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v3.2.0...v3.3.0)
|
|
40
|
+
|
|
41
|
+
## [3.2.0] - 2023-06-06
|
|
42
|
+
|
|
43
|
+
### Changed
|
|
44
|
+
|
|
45
|
+
- [eslint] Updated `@typescript-eslint` from `5.59.8` to `5.59.9`
|
|
46
|
+
- [stylelint] Updated `stylelint` from `15.6.3` to `15.7.0`
|
|
47
|
+
|
|
48
|
+
[Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v3.1.0...v3.2.0)
|
|
10
49
|
|
|
11
50
|
## [3.1.0] - 2023-06-05
|
|
12
51
|
|
|
13
52
|
### Changed
|
|
14
53
|
|
|
15
54
|
- [eslint] Disabled [`unicorn/prefer-blob-reading-methods`](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-blob-reading-methods.md) rule, as it's not widely supported yet
|
|
16
|
-
- [eslint] Updated `@typescript-eslint
|
|
55
|
+
- [eslint] Updated `@typescript-eslint` from `5.59.6` to `5.59.8`
|
|
17
56
|
- [eslint] Updated `eslint` from `8.40.0` to `8.42.0`
|
|
18
57
|
- [eslint] Updated `eslint-plugin-jsdoc` from `44.2.4` to `46.2.4`
|
|
19
58
|
- [stylelint] Updated `stylelint` from `15.6.1` to `15.6.3`
|
|
59
|
+
|
|
60
|
+
### Added
|
|
61
|
+
|
|
20
62
|
- [eslint/overrides-jsdoc] Added, but disabled new [`jsdoc/imports-as-dependencies`](https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/imports-as-dependencies.md) rule, as it doesn't cover `peerDependencies` and Node.js modules (like `child_process`)
|
|
21
63
|
|
|
22
64
|
[Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v3.0.0...v3.1.0)
|
|
@@ -47,7 +89,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
|
47
89
|
|
|
48
90
|
### Changed
|
|
49
91
|
|
|
50
|
-
- [eslint] Updated `@typescript-eslint
|
|
92
|
+
- [eslint] Updated `@typescript-eslint` from `5.59.0` to `5.59.2`
|
|
51
93
|
- [eslint] Updated `eslint-plugin-jsdoc` from `43.0.7` to `43.2.0`
|
|
52
94
|
- [markdownlint] Updated `markdownlint-cli` from `0.33.0` to `0.34.0`
|
|
53
95
|
- [stylelint] Updated `stylelint` from `15.5.0` to `15.6.1`
|
package/README.md
CHANGED
|
@@ -46,7 +46,7 @@ Beside that, the following additional rules are part of this bundle:
|
|
|
46
46
|
- [stylelint-high-performance-animation](https://www.npmjs.com/package/stylelint-high-performance-animation) (Forked version)
|
|
47
47
|
- [stylelint-order](https://www.npmjs.com/package/stylelint-order)
|
|
48
48
|
- [stylelint-scss](https://www.npmjs.com/package/stylelint-scss)
|
|
49
|
-
- [stylelint-selector-no-empty](https://www.npmjs.com/package/stylelint-selector-no-empty)
|
|
49
|
+
- [stylelint-selector-no-empty](https://www.npmjs.com/package/stylelint-selector-no-empty) (Forked version)
|
|
50
50
|
- [stylelint-selector-tag-no-without-class](https://www.npmjs.com/package/stylelint-selector-tag-no-without-class) (Forked version)
|
|
51
51
|
- [stylelint-use-logical-spec](https://www.npmjs.com/package/stylelint-use-logical-spec)
|
|
52
52
|
|
package/eslint/index.js
CHANGED
|
@@ -699,7 +699,6 @@ module.exports = {
|
|
|
699
699
|
'@typescript-eslint/no-namespace': ['error', { allowDeclarations: true }],
|
|
700
700
|
'@typescript-eslint/no-non-null-assertion': 'error',
|
|
701
701
|
'@typescript-eslint/no-non-null-asserted-optional-chain': 'error',
|
|
702
|
-
'@typescript-eslint/no-parameter-properties': 'error',
|
|
703
702
|
'@typescript-eslint/no-redeclare': ['error', { ignoreDeclarationMerge: true }],
|
|
704
703
|
'@typescript-eslint/no-redundant-type-constituents': 'off', // False positive with Promise<... | never>
|
|
705
704
|
'@typescript-eslint/no-require-imports': 'error',
|
|
@@ -953,7 +952,7 @@ module.exports = {
|
|
|
953
952
|
'unicorn/no-await-expression-member': 'error',
|
|
954
953
|
'unicorn/no-console-spaces': 'error',
|
|
955
954
|
'unicorn/no-document-cookie': 'error',
|
|
956
|
-
'unicorn/no-empty-file': '
|
|
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
|
|
957
956
|
'unicorn/no-for-loop': 'off', // @typescript-eslint/prefer-for-of
|
|
958
957
|
'unicorn/no-hex-escape': 'error',
|
|
959
958
|
'unicorn/no-instanceof-array': 'error',
|
|
@@ -32,8 +32,6 @@ module.exports = {
|
|
|
32
32
|
'@typescript-eslint/no-require-imports': 'off', // Requires type information
|
|
33
33
|
'@typescript-eslint/no-unsafe-assignment': 'off', // @todo Reactivate after bug in @typescript-eslint is fixed (@see https://github.com/typescript-eslint/typescript-eslint/issues/1943)
|
|
34
34
|
'@typescript-eslint/no-var-requires': 'off', // Requires type information
|
|
35
|
-
'@typescript-eslint/prefer-nullish-coalescing': 'off', // @todo `??` is not yet supported by NodeJS. Remove this like, as soon as it is supported.
|
|
36
|
-
'@typescript-eslint/prefer-optional-chain': 'off', // @todo `?.` is not yet supported by NodeJS. Remove this like, as soon as it is supported.
|
|
37
35
|
'@typescript-eslint/triple-slash-reference': 'off', // Required to make use of *.d.ts files
|
|
38
36
|
|
|
39
37
|
/**
|
|
@@ -34,7 +34,7 @@ module.exports = {
|
|
|
34
34
|
'jsdoc/check-values': 'error',
|
|
35
35
|
'jsdoc/empty-tags': 'error',
|
|
36
36
|
'jsdoc/implements-on-classes': 'error',
|
|
37
|
-
'jsdoc/imports-as-dependencies': 'off', // @todo Doesn't cover `peerDependencies`
|
|
37
|
+
'jsdoc/imports-as-dependencies': 'off', // @todo Doesn't cover `peerDependencies` yet. As of v46.2.5 it should cover Node.js modules (like `child_process`), which must be checked, before activation.
|
|
38
38
|
'jsdoc/match-description': 'error',
|
|
39
39
|
'jsdoc/match-name': 'off',
|
|
40
40
|
'jsdoc/multiline-blocks': ['error', { noSingleLineBlocks: true, singleLineTags: ['lends', 'type', 'typedef'], noFinalLineText: false }],
|
|
@@ -75,7 +75,8 @@ module.exports = {
|
|
|
75
75
|
param: { lines: 'never' },
|
|
76
76
|
private: { lines: 'never' },
|
|
77
77
|
protected: { lines: 'never' },
|
|
78
|
-
public: { lines: 'never' }
|
|
78
|
+
public: { lines: 'never' },
|
|
79
|
+
throws: { lines: 'never' }
|
|
79
80
|
},
|
|
80
81
|
startLines: null,
|
|
81
82
|
endLines: null,
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
const ts = require('typescript');
|
|
8
8
|
|
|
9
|
+
// @ts-expect-error -- TypeScript is not able to resolve the folder since @typescript-eslint v6.0.0
|
|
9
10
|
const { ESLintUtils } = require('@typescript-eslint/utils');
|
|
10
11
|
|
|
11
12
|
/**
|
|
@@ -28,11 +29,9 @@ module.exports = {
|
|
|
28
29
|
return;
|
|
29
30
|
}
|
|
30
31
|
|
|
31
|
-
// @ts-expect-error -- Different type definitions for `Rule.RuleContext` in ESLint and @typescript-eslint
|
|
32
32
|
const parserServices = ESLintUtils.getParserServices(context);
|
|
33
33
|
const checker = parserServices.program.getTypeChecker();
|
|
34
34
|
|
|
35
|
-
// @ts-expect-error -- ESLint `Identifier` is not recognized as `Node` by @typescript-eslint
|
|
36
35
|
const originalNode = parserServices.esTreeNodeToTSNodeMap.get(node.argument);
|
|
37
36
|
|
|
38
37
|
/** @type {Type} */
|
package/lint.js
CHANGED
|
@@ -118,7 +118,7 @@ void (async () => {
|
|
|
118
118
|
return runTask({
|
|
119
119
|
taskName,
|
|
120
120
|
config,
|
|
121
|
-
command: `node "${require.resolve('stylelint
|
|
121
|
+
command: `node "${path.join(path.dirname(require.resolve('stylelint')), '../bin/stylelint.js')}" ${includes} --formatter unix`
|
|
122
122
|
});
|
|
123
123
|
}
|
|
124
124
|
|
|
@@ -280,7 +280,7 @@ function validateEnvironment (npmOrYarn) {
|
|
|
280
280
|
propertyName = 'resolutions';
|
|
281
281
|
}
|
|
282
282
|
else {
|
|
283
|
-
installCommand = 'npm install';
|
|
283
|
+
installCommand = 'npm install --no-package-lock';
|
|
284
284
|
propertyName = 'overrides';
|
|
285
285
|
}
|
|
286
286
|
|
|
@@ -288,7 +288,7 @@ function validateEnvironment (npmOrYarn) {
|
|
|
288
288
|
process.stderr.write(`- ${missingOverrides.map((dependency) => `${dependency.name}: ${dependency.configuredVersion} is installed, but ${dependency.expectedVersion} is expected`).join('\n- ')}\n\n`);
|
|
289
289
|
process.stderr.write(`This could be caused by forgetting to execute \`${installCommand}\` after changing a version number in the package.json, or by some other package shipping outdated versions of the ${missingOverrides.length === 1 ? 'dependency' : 'dependencies'}.\n`);
|
|
290
290
|
process.stderr.write('If another package is causing this problem, you can fix it by adding the following entry to your package.json:\n');
|
|
291
|
-
process.stderr.write(`{\n "${propertyName}: {\n ${missingOverrides.map((dependency) => `"${dependency.name}": "${dependency.expectedVersion}"`).join(',\n ')}\n }\n}\n\n`);
|
|
291
|
+
process.stderr.write(`{\n "${propertyName}": {\n ${missingOverrides.map((dependency) => `"${dependency.name}": "${dependency.expectedVersion}"`).join(',\n ')}\n }\n}\n\n`);
|
|
292
292
|
|
|
293
293
|
process.exitCode = 1;
|
|
294
294
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "linter-bundle",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0",
|
|
4
4
|
"description": "Ready-to use bundle of linting tools, containing configurations for ESLint, stylelint and markdownlint.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"lint": "lint.js"
|
|
23
23
|
},
|
|
24
24
|
"engines": {
|
|
25
|
-
"node": "
|
|
25
|
+
"node": "^16.0.0 || >=18.0.0"
|
|
26
26
|
},
|
|
27
27
|
"repository": {
|
|
28
28
|
"type": "git",
|
|
@@ -40,31 +40,30 @@
|
|
|
40
40
|
"check-outdated": "npx --yes -- check-outdated --ignore-pre-releases"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@typescript-eslint/eslint-plugin": "
|
|
44
|
-
"@typescript-eslint/parser": "
|
|
45
|
-
"@typescript-eslint/utils": "
|
|
46
|
-
"eslint": "8.
|
|
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",
|
|
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
51
|
"eslint-plugin-import": "2.27.5",
|
|
52
|
-
"eslint-plugin-jest": "27.2.
|
|
53
|
-
"eslint-plugin-jsdoc": "46.
|
|
52
|
+
"eslint-plugin-jest": "27.2.3",
|
|
53
|
+
"eslint-plugin-jsdoc": "46.4.3",
|
|
54
54
|
"eslint-plugin-jsx-a11y": "6.7.1",
|
|
55
|
-
"eslint-plugin-n": "16.0.
|
|
55
|
+
"eslint-plugin-n": "16.0.1",
|
|
56
56
|
"eslint-plugin-promise": "6.1.1",
|
|
57
57
|
"eslint-plugin-react": "7.32.2",
|
|
58
58
|
"eslint-plugin-react-hooks": "4.6.0",
|
|
59
59
|
"eslint-plugin-unicorn": "47.0.0",
|
|
60
|
-
"markdownlint-cli": "0.
|
|
60
|
+
"markdownlint-cli": "0.35.0",
|
|
61
61
|
"micromatch": "4.0.5",
|
|
62
62
|
"postcss-scss": "4.0.6",
|
|
63
|
-
"stylelint": "15.
|
|
63
|
+
"stylelint": "15.10.1",
|
|
64
64
|
"stylelint-declaration-block-no-ignored-properties": "2.7.0",
|
|
65
65
|
"stylelint-order": "6.0.3",
|
|
66
|
-
"stylelint-scss": "5.0.
|
|
67
|
-
"stylelint-selector-no-empty": "1.0.9",
|
|
66
|
+
"stylelint-scss": "5.0.1",
|
|
68
67
|
"stylelint-use-logical-spec": "5.0.0"
|
|
69
68
|
},
|
|
70
69
|
"peerDependencies": {
|
|
@@ -72,10 +71,10 @@
|
|
|
72
71
|
"typescript": "^4.0.0"
|
|
73
72
|
},
|
|
74
73
|
"devDependencies": {
|
|
75
|
-
"@types/eslint": "8.
|
|
74
|
+
"@types/eslint": "8.44.0",
|
|
76
75
|
"@types/micromatch": "4.0.2",
|
|
77
|
-
"@types/node": "20.2
|
|
76
|
+
"@types/node": "20.4.2",
|
|
78
77
|
"stylelint-find-new-rules": "4.1.0",
|
|
79
|
-
"typescript": "5.1.
|
|
78
|
+
"typescript": "5.1.6"
|
|
80
79
|
}
|
|
81
80
|
}
|
package/stylelint/index.js
CHANGED
|
@@ -15,9 +15,9 @@ module.exports = {
|
|
|
15
15
|
'stylelint-declaration-block-no-ignored-properties',
|
|
16
16
|
'stylelint-order',
|
|
17
17
|
'stylelint-scss',
|
|
18
|
-
'stylelint-selector-no-empty',
|
|
19
18
|
'stylelint-use-logical-spec',
|
|
20
19
|
path.join(__dirname, '/plugins/stylelint-high-performance-animation.js'),
|
|
20
|
+
path.join(__dirname, '/plugins/stylelint-selector-no-empty.js'),
|
|
21
21
|
path.join(__dirname, '/plugins/stylelint-selector-tag-no-without-class.js'),
|
|
22
22
|
path.join(__dirname, '/plugins/stylelint-stylistic.js')
|
|
23
23
|
],
|
|
@@ -187,7 +187,9 @@ module.exports = {
|
|
|
187
187
|
'media-feature-name-no-vendor-prefix': null, // For Safari, we still need "-webkit-min-device-pixel-ratio": https://caniuse.com/css-media-resolution
|
|
188
188
|
'media-feature-name-unit-allowed-list': null,
|
|
189
189
|
'media-feature-name-value-allowed-list': null,
|
|
190
|
+
'media-feature-name-value-no-unknown': true,
|
|
190
191
|
'media-feature-range-notation': 'prefix',
|
|
192
|
+
'media-query-no-invalid': true,
|
|
191
193
|
'named-grid-areas-no-invalid': true,
|
|
192
194
|
'no-descending-specificity': null, // doesn't work in many cases (e.g. while using the SCSS :global()-pseudo-class)
|
|
193
195
|
'no-duplicate-at-import-rules': true,
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Fork of `stylelint-selector-no-empty` rule.
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
*
|
|
6
|
+
* @see https://www.npmjs.com/package/stylelint-selector-no-empty
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const stylelint = require('stylelint');
|
|
10
|
+
|
|
11
|
+
const ruleName = 'plugin/stylelint-selector-no-empty';
|
|
12
|
+
|
|
13
|
+
let nearestSelector = '';
|
|
14
|
+
|
|
15
|
+
const messages = stylelint.utils.ruleMessages(ruleName, {
|
|
16
|
+
expected (selector) {
|
|
17
|
+
if (typeof selector === 'string' && selector.length > 0) {
|
|
18
|
+
return `Unexpected empty selector near '${selector}'`;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return 'Unexpected empty selector';
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
// @ts-expect-error -- Parameter 'enabled' implicitly has an 'any' type.
|
|
26
|
+
module.exports = stylelint.createPlugin(ruleName, (enabled) => {
|
|
27
|
+
if (!enabled) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return (root, result) => {
|
|
32
|
+
root.walkRules((rule) => {
|
|
33
|
+
try {
|
|
34
|
+
nearestSelector = '';
|
|
35
|
+
|
|
36
|
+
for (const selector of rule.selector.split(',')) {
|
|
37
|
+
if (selector.length === 0) {
|
|
38
|
+
reportError(rule, result);
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
nearestSelector = selector;
|
|
42
|
+
|
|
43
|
+
const tabSplittedSelectors = getSplittedSelectors(selector.split('\n'), '\t');
|
|
44
|
+
const spaceSplittedSelectors = getSplittedSelectors(tabSplittedSelectors, ' ');
|
|
45
|
+
checkEmptySelector(spaceSplittedSelectors, result, rule);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
catch { /* Do nothing */ }
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Splits the selectors based on a specified delimiter and filters out empty selectors.
|
|
55
|
+
*
|
|
56
|
+
* @param {string[]} splittedSelectors - The selectors to be split.
|
|
57
|
+
* @param {string} splitBy - The delimiter to split the selectors.
|
|
58
|
+
* @returns {string[]} The split and filtered selectors.
|
|
59
|
+
*/
|
|
60
|
+
function getSplittedSelectors (splittedSelectors, splitBy) {
|
|
61
|
+
const res = [];
|
|
62
|
+
|
|
63
|
+
for (const splittedSelector of splittedSelectors) {
|
|
64
|
+
try {
|
|
65
|
+
for (const selector of splittedSelector.split(splitBy)) {
|
|
66
|
+
if (selector.trim().length > 0) {
|
|
67
|
+
res.push(selector);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
catch { /* Do nothing */ }
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return res;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Checks for empty selectors within the space-split selectors.
|
|
79
|
+
*
|
|
80
|
+
* @param {string[]} spaceSplittedSelectors - The space-split selectors.
|
|
81
|
+
* @param {stylelint.PostcssResult} result - The result object.
|
|
82
|
+
* @param {import('postcss').Rule} rule - The current rule.
|
|
83
|
+
*/
|
|
84
|
+
function checkEmptySelector (spaceSplittedSelectors, result, rule) {
|
|
85
|
+
for (let sp of spaceSplittedSelectors) {
|
|
86
|
+
if ((sp.startsWith('.') || sp.startsWith('#')) && sp.trim().length > 1) {
|
|
87
|
+
sp = sp.slice(1);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
for (const classSelectorsWithoutDot of sp.split('.')) {
|
|
91
|
+
for (const selector of classSelectorsWithoutDot.split('#')) {
|
|
92
|
+
if (selector.trim().length === 0) {
|
|
93
|
+
reportError(rule, result);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Reports an error for an empty selector.
|
|
103
|
+
*
|
|
104
|
+
* @param {import('postcss').Rule} rule - The current rule.
|
|
105
|
+
* @param {stylelint.PostcssResult} result - The result object.
|
|
106
|
+
*/
|
|
107
|
+
function reportError (rule, result) {
|
|
108
|
+
stylelint.utils.report({
|
|
109
|
+
result,
|
|
110
|
+
ruleName,
|
|
111
|
+
message: messages.expected(nearestSelector),
|
|
112
|
+
node: rule
|
|
113
|
+
});
|
|
114
|
+
}
|
package/.gitattributes
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
* text=auto
|
|
2
|
-
|
|
3
|
-
*.css text eol=lf
|
|
4
|
-
*.html text eol=lf
|
|
5
|
-
*.js text eol=lf
|
|
6
|
-
*.json text eol=lf
|
|
7
|
-
*.log text eol=lf
|
|
8
|
-
*.md text eol=lf
|
|
9
|
-
*.scss text eol=lf
|
|
10
|
-
*.svg text eol=lf
|
|
11
|
-
*.ts text eol=lf
|
|
12
|
-
*.tsx text eol=lf
|
|
13
|
-
*.txt text eol=lf
|
|
14
|
-
*.xml text eol=lf
|
|
15
|
-
*.yaml text eol=lf
|
|
16
|
-
*.yml text eol=lf
|
|
@@ -1,52 +0,0 @@
|
|
|
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, '@property --color {\n\tsyntax: "<color>";\n\tinherits: false;\n\tinitial-value: #f00; // stylelint-disable-line color-no-hex -- The initial value must be a hex-color\n}\n\n* {\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:\n\n- ${warnings.map(({ text }) => text).join('\n- ')}\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- ')}\n`);
|
|
47
|
-
|
|
48
|
-
process.exitCode = 1;
|
|
49
|
-
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
})();
|