linter-bundle 4.0.2 → 5.0.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.
Files changed (39) hide show
  1. package/.linter-bundle.js +8 -8
  2. package/CHANGELOG.md +23 -1
  3. package/README.md +1 -1
  4. package/eslint/{index.js → index.cjs} +7 -7
  5. package/eslint/{overrides-javascript-lazy.js → overrides-javascript-lazy.cjs} +1 -1
  6. package/eslint/{overrides-javascript.js → overrides-javascript.cjs} +1 -0
  7. package/eslint/{overrides-react.js → overrides-react.cjs} +4 -4
  8. package/eslint/rules/no-unnecessary-typeof.js +12 -1
  9. package/eslint/rules/package.json +8 -0
  10. package/eslint/rules/restricted-filenames.js +4 -4
  11. package/eslint/rules/restricted-filenames.md +1 -1
  12. package/files/index.js +54 -24
  13. package/helper/{ensure-type.js → ensure-type.cjs} +2 -0
  14. package/helper/get-git-files.js +3 -7
  15. package/helper/get-outdated-dependencies.js +48 -0
  16. package/helper/{validate-package-overrides.js → get-outdated-overrides.js} +9 -10
  17. package/helper/get-stylelint-path.js +15 -12
  18. package/helper/is-npm-or-yarn.js +12 -12
  19. package/helper/linter-bundle-config.cjs +70 -0
  20. package/helper/linter-bundle-config.d.ts +46 -0
  21. package/helper/linter-bundle-config.js +36 -0
  22. package/helper/run-process.js +14 -10
  23. package/lint.js +33 -27
  24. package/package.json +8 -7
  25. package/stylelint/index.cjs +1007 -0
  26. package/stylelint/plugins/stylelint-high-performance-animation.js +4 -5
  27. package/stylelint/plugins/stylelint-selector-no-empty.js +2 -2
  28. package/stylelint/plugins/stylelint-selector-tag-no-without-class.js +6 -7
  29. package/stylelint/plugins/stylelint-stylistic.js +7 -6
  30. package/helper/config.js +0 -48
  31. package/helper/find-missing-overrides.js +0 -49
  32. package/stylelint/index.js +0 -1007
  33. package/types.d.ts +0 -43
  34. /package/eslint/{overrides-gatsby.js → overrides-gatsby.cjs} +0 -0
  35. /package/eslint/{overrides-jest.js → overrides-jest.cjs} +0 -0
  36. /package/eslint/{overrides-jsdoc.js → overrides-jsdoc.cjs} +0 -0
  37. /package/eslint/{overrides-storybook.js → overrides-storybook.cjs} +0 -0
  38. /package/eslint/{overrides-type-declarations.js → overrides-type-declarations.cjs} +0 -0
  39. /package/eslint/{overrides-worker.js → overrides-worker.cjs} +0 -0
@@ -6,12 +6,11 @@
6
6
  * @see https://github.com/kristerkari/stylelint-high-performance-animation
7
7
  */
8
8
 
9
- const valueParser = require('postcss-value-parser');
9
+ import valueParser from 'postcss-value-parser';
10
10
  /** @type {(declaration: import('postcss').Declaration) => number} */
11
+ import stylelint from 'stylelint';
11
12
  // @ts-expect-error -- No declaration file.
12
- const declarationValueIndex = require('stylelint/lib/utils/declarationValueIndex');
13
-
14
- const stylelint = require('stylelint');
13
+ import declarationValueIndex from 'stylelint/lib/utils/declarationValueIndex.js';
15
14
 
16
15
  const ruleName = 'plugin/no-low-performance-animation-properties';
17
16
 
@@ -274,4 +273,4 @@ const ruleFunction = (actual, options) => (cssRoot, result) => {
274
273
  ruleFunction.ruleName = ruleName;
275
274
  ruleFunction.messages = messages;
276
275
 
277
- module.exports = stylelint.createPlugin(ruleName, ruleFunction);
276
+ export default stylelint.createPlugin(ruleName, ruleFunction);
@@ -6,7 +6,7 @@
6
6
  * @see https://www.npmjs.com/package/stylelint-selector-no-empty
7
7
  */
8
8
 
9
- const stylelint = require('stylelint');
9
+ import stylelint from 'stylelint';
10
10
 
11
11
  const ruleName = 'plugin/stylelint-selector-no-empty';
12
12
 
@@ -23,7 +23,7 @@ const messages = stylelint.utils.ruleMessages(ruleName, {
23
23
  });
24
24
 
25
25
  // @ts-expect-error -- Parameter 'enabled' implicitly has an 'any' type.
26
- module.exports = stylelint.createPlugin(ruleName, (enabled) => {
26
+ export default stylelint.createPlugin(ruleName, (enabled) => {
27
27
  if (!enabled) {
28
28
  return;
29
29
  }
@@ -8,16 +8,15 @@
8
8
 
9
9
  /* eslint-disable jsdoc/require-jsdoc -- Unfortunately, this is not given in the original code. */
10
10
 
11
+ import stylelint from 'stylelint';
11
12
  // @ts-expect-error -- No declaration file.
12
- const isStandardSyntaxRule = require('stylelint/lib/utils/isStandardSyntaxRule');
13
+ import isStandardSyntaxRule from 'stylelint/lib/utils/isStandardSyntaxRule.js';
13
14
  // @ts-expect-error -- No declaration file.
14
- const isStandardSyntaxSelector = require('stylelint/lib/utils/isStandardSyntaxSelector');
15
+ import isStandardSyntaxSelector from 'stylelint/lib/utils/isStandardSyntaxSelector.js';
15
16
  // @ts-expect-error -- No declaration file.
16
- const matchesStringOrRegExp = require('stylelint/lib/utils/matchesStringOrRegExp');
17
+ import matchesStringOrRegExp from 'stylelint/lib/utils/matchesStringOrRegExp.js';
17
18
  // @ts-expect-error -- No declaration file.
18
- const parseSelector = require('stylelint/lib/utils/parseSelector');
19
-
20
- const stylelint = require('stylelint');
19
+ import parseSelector from 'stylelint/lib/utils/parseSelector.js';
21
20
 
22
21
  const ruleName = 'plugin/selector-tag-no-without-class';
23
22
  const messages = stylelint.utils.ruleMessages(ruleName, {
@@ -109,4 +108,4 @@ rule.primaryOptionArray = true;
109
108
  rule.ruleName = ruleName;
110
109
  rule.messages = messages;
111
110
 
112
- module.exports = stylelint.createPlugin(ruleName, rule);
111
+ export default stylelint.createPlugin(ruleName, rule);
@@ -86,9 +86,11 @@
86
86
  * @see https://stylelint.io/user-guide/rules/value-list-max-empty-lines
87
87
  */
88
88
 
89
- const stylelint = require('stylelint');
89
+ import stylelint from 'stylelint';
90
+ // @ts-expect-error -- There's no type definition for this file.
91
+ import rules from 'stylelint/lib/rules/index.js';
90
92
 
91
- module.exports = [
93
+ export default await Promise.all([
92
94
  'at-rule-name-case',
93
95
  'at-rule-name-space-after',
94
96
  'at-rule-semicolon-newline-after',
@@ -162,9 +164,8 @@ module.exports = [
162
164
  'value-list-comma-space-after',
163
165
  'value-list-comma-space-before',
164
166
  'value-list-max-empty-lines'
165
- ].map((ruleName) => {
166
- // eslint-disable-next-line import/no-dynamic-require -- Dynamic require reduces code complexity
167
- const rule = require(`stylelint/lib/rules/${ruleName}`);
167
+ ].map(async (ruleName) => {
168
+ const rule = rules[ruleName];
168
169
 
169
170
  const forkedRule = Object.assign(
170
171
  /**
@@ -184,4 +185,4 @@ module.exports = [
184
185
  };
185
186
 
186
187
  return stylelint.createPlugin(`plugin/${ruleName}`, forkedRule);
187
- });
188
+ }));
package/helper/config.js DELETED
@@ -1,48 +0,0 @@
1
- /**
2
- * @file Returns the `.linter-bundle.js` configuration result.
3
- */
4
-
5
- const fs = require('node:fs');
6
- const path = require('node:path');
7
-
8
- /**
9
- * @typedef linterBundleConfig
10
- * @property {boolean} [verbose]
11
- * @property {boolean} [timing]
12
- * @property {boolean} [git]
13
- * @property {{ tsconfig?: string; }} [tsc]
14
- * @property {{ tsconfig?: string; include?: string[]; exclude?: string[]; overrides?: {
15
- * general?: {
16
- * 'no-restricted-globals'?: { additionalRestrictions?: { name: string; message: string; }[]; },
17
- * 'no-restricted-properties'?: { additionalRestrictions?: { object: string; property: string; message: string; }[]; },
18
- * 'no-restricted-syntax'?: { additionalRestrictions?: { selector: string; message: string; }[]; },
19
- * 'import/order'?: { additionalExternalPatterns?: string[]; }
20
- * },
21
- * react?: {
22
- * 'react/forbid-component-props'?: { allowClassNameFor?: string[]; allowStyleFor?: string[]; }
23
- * }
24
- * }; }} [ts]
25
- * @property {{ patternPrefix?: string; }} [sass]
26
- * @property {{ minSeverity?: 'info' | 'low' | 'moderate' | 'high' | 'critical'; exclude?: string[]; }} [audit]
27
- * @property {{ restrictions: { basePath: string; allowed?: string[]; disallowed?: string[]; }[]; }} [files]
28
- */
29
-
30
- module.exports = (
31
- loadConfig('.linter-bundle.json') ??
32
- loadConfig('.linter-bundle.cjs') ??
33
- loadConfig('.linter-bundle.js') ??
34
- {}
35
- );
36
-
37
- /**
38
- * Load a config file if it exist.
39
- *
40
- * @param {string} fileName - The name of the config file
41
- * @returns {linterBundleConfig | undefined} - Either the file content for `undefined` if the file does not exist.
42
- * */
43
- function loadConfig (fileName) {
44
- const filePath = path.join(process.cwd(), fileName);
45
-
46
- // eslint-disable-next-line import/no-dynamic-require -- Required here to load the configuration file.
47
- return (fs.existsSync(filePath) ? require(filePath) : undefined);
48
- }
@@ -1,49 +0,0 @@
1
- /**
2
- * @file Ensures that the installed dependencies of the project matches to the versions used by the linter-bundle.
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('node:fs');
9
- const path = require('node:path');
10
-
11
- /** @typedef {{ name: string; configuredVersion: string; expectedVersion: string; }} Dependency */
12
-
13
- /**
14
- * Detects if installed versions of dependencies don't match to the required dependencies.
15
- *
16
- * @public
17
- * @returns {Dependency[]} An array of missing overrides (=wrong versions).
18
- */
19
- function findMissingOverrides () {
20
- const linterBundleDependencies = JSON.parse(fs.readFileSync(path.resolve(__dirname, '../package.json'), 'utf8')).dependencies;
21
-
22
- const result = [];
23
-
24
- for (const [name, expectedVersion] of Object.entries(linterBundleDependencies)) {
25
- let dependencyPackageJson;
26
-
27
- try {
28
- dependencyPackageJson = JSON.parse(fs.readFileSync(path.join(process.cwd(), 'node_modules', name, 'package.json'), 'utf8'));
29
- }
30
- catch {
31
- // If the file does not exist, we ignore it, because in this case it's most likely a linter-bundle-only dependency.
32
- continue;
33
- }
34
-
35
- if (dependencyPackageJson.version !== expectedVersion) {
36
- result.push({
37
- name,
38
- configuredVersion: dependencyPackageJson.version,
39
- expectedVersion
40
- });
41
- }
42
- }
43
-
44
- return result;
45
- }
46
-
47
- module.exports = {
48
- findMissingOverrides
49
- };