Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump eslint-config-stylelint from 13.1.1 to 14.0.0 #5536

Merged

Conversation

dependabot[bot]
Copy link
Contributor

@dependabot dependabot bot commented on behalf of github Sep 14, 2021

Bumps eslint-config-stylelint from 13.1.1 to 14.0.0.

Release notes

Sourced from eslint-config-stylelint's releases.

14.0.0

  • Added: ESM support.
  • Added: eslint-plugin-regexp plugin.
  • Removed: eslint-plugin-sort-requires plugin.
Changelog

Sourced from eslint-config-stylelint's changelog.

14.0.0

  • Added: ESM support.
  • Added: eslint-plugin-regexp plugin.
  • Removed: eslint-plugin-sort-requires plugin.
Commits

Dependabot compatibility score

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


Dependabot commands and options

You can trigger Dependabot actions by commenting on this PR:

  • @dependabot rebase will rebase this PR
  • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
  • @dependabot merge will merge this PR after your CI passes on it
  • @dependabot squash and merge will squash and merge this PR after your CI passes on it
  • @dependabot cancel merge will cancel a previously requested merge and block automerging
  • @dependabot reopen will reopen this PR if it is closed
  • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
  • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)

@dependabot dependabot bot added the pr: dependencies relates to dependencies label Sep 14, 2021
@ybiquitous ybiquitous self-assigned this Sep 14, 2021
@ybiquitous
Copy link
Member

We need to avoid the problems of CommonJS. See stylelint/eslint-config-stylelint#143 (comment).

@ybiquitous
Copy link
Member

@dependabot rebase

Bumps [eslint-config-stylelint](https://github.com/stylelint/eslint-config-stylelint) from 13.1.1 to 14.0.0.
- [Release notes](https://github.com/stylelint/eslint-config-stylelint/releases)
- [Changelog](https://github.com/stylelint/eslint-config-stylelint/blob/master/CHANGELOG.md)
- [Commits](stylelint/eslint-config-stylelint@13.1.1...14.0.0)

---
updated-dependencies:
- dependency-name: eslint-config-stylelint
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
@dependabot dependabot bot force-pushed the dependabot/npm_and_yarn/v14/eslint-config-stylelint-14.0.0 branch from 2c22ccc to 8d90796 Compare September 14, 2021 18:43
@ybiquitous ybiquitous mentioned this pull request Sep 14, 2021
30 tasks
@jeddy3
Copy link
Member

jeddy3 commented Sep 14, 2021

Let's update the globals, run npm run lint:js -- --fix and see what we're left with.

@ybiquitous
Copy link
Member

16 problems left after --fix applied:

$ npm run lint:js -- -f codeframe
...

error: Capturing group number 1 is defined but never used (regexp/no-unused-capturing-group) at lib/__tests__/standalone-syntax.test.js:23:39:
  21 | 		expect(results).toHaveLength(6);
  22 | 
> 23 | 		const safeParserExtensionsTest = /\.(css|pcss|postcss)$/i;
     | 		                                    ^
  24 | 
  25 | 		results
  26 | 			.filter((result) => !safeParserExtensionsTest.test(result.source))


error: Capturing group number 1 is defined but never used (regexp/no-unused-capturing-group) at lib/rules/color-hex-alpha/index.js:16:16:
  14 | });
  15 | 
> 16 | const HEX = /^#([\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})$/i;
     |                ^
  17 | 
  18 | /** @type {import('stylelint').StylelintRule} */
  19 | const rule = (primary) => {


error: Capturing group number 1 is defined but never used (regexp/no-unused-capturing-group) at lib/rules/font-family-name-quotes/index.js:55:12:
  53 | function quotesRequired(family) {
  54 | 	return family.split(/\s+/).some((word) => {
> 55 | 		return /^(-?\d|--)/.test(word) || !/^[-\w\u{00A0}-\u{10FFFF}]+$/u.test(word);
     | 		         ^
  56 | 	});
  57 | }
  58 | 


error: Capturing group number 1 is defined but never used (regexp/no-unused-capturing-group) at lib/rules/indentation/index.js:610:17:
  608 | 
  609 | 		source = source.replace(/^[^\r\n]+/, (firstLine) => {
> 610 | 			if (/(?:^|\n)([ \t]*)$/.test(root.raws.beforeStart)) {
      | 			             ^
  611 | 				return RegExp.$1 + firstLine;
  612 | 			}
  613 | 


error: 'RegExp.$1' static property is forbidden (regexp/no-legacy-features) at lib/rules/indentation/index.js:611:12:
  609 | 		source = source.replace(/^[^\r\n]+/, (firstLine) => {
  610 | 			if (/(?:^|\n)([ \t]*)$/.test(root.raws.beforeStart)) {
> 611 | 				return RegExp.$1 + firstLine;
      | 				       ^
  612 | 			}
  613 | 
  614 | 			return '';


error: Capturing group number 1 is defined but never used (regexp/no-unused-capturing-group) at lib/rules/max-empty-lines/index.js:164:12:
  162 | 			const emptyCRLFLines = '\r\n'.repeat(repeatTimes);
  163 | 
> 164 | 			return /(\r\n)+/.test(str)
      | 			        ^
  165 | 				? str.replace(/(\r\n)+/g, ($1) => {
  166 | 						if ($1.length / 2 > repeatTimes) {
  167 | 							return emptyCRLFLines;


error: Capturing group number 2 is defined but never used (regexp/no-unused-capturing-group) at lib/rules/mediaQueryListCommaWhitespaceChecker.js:32:40:
  30 | 				}
  31 | 
> 32 | 				if ((execResult = /^([^\S\r\n]*\/\/([\s\S]*?))\r?\n/.exec(params.slice(index + 1)))) {
     | 				                                   ^
  33 | 					index += execResult[1].length;
  34 | 				}
  35 | 			}


error: The quantifier '\d*?' can exchange characters with '0+'. Using any string accepted by /0+/, this can be exploited to cause at least polynomial backtracking (regexp/no-super-linear-backtracking) at lib/rules/number-no-trailing-zeros/index.js:55:23:
  53 | 				}
  54 | 
> 55 | 				const match = /\.(\d*?)(0+)(?:\D|$)/.exec(valueNode.value);
     | 				                  ^
  56 | 
  57 | 				// match[1] is any numbers between the decimal and our trailing zero, could be empty
  58 | 				// match[2] is our trailing zero(s)


error: Capturing group number 1 is defined but never used (regexp/no-unused-capturing-group) at lib/rules/string-no-newline/index.js:15:20:
  13 | 
  14 | const ruleName = 'string-no-newline';
> 15 | const reNewLine = /(\r?\n)/;
     |                    ^
  16 | 
  17 | const messages = ruleMessages(ruleName, {
  18 | 	rejected: 'Unexpected newline in string',


error: 'RegExp.leftContext' static property is forbidden (regexp/no-legacy-features) at lib/rules/string-no-newline/index.js:65:7:
  63 | 						attributeNode.operator,
  64 | 						// length of the contents before newline
> 65 | 						RegExp.leftContext,
     | 						^
  66 | 					].reduce(
  67 | 						(index, str) => index + str.length,
  68 | 						// index of the start of our attribute node in our source


error: 'RegExp.leftContext' static property is forbidden (regexp/no-legacy-features) at lib/rules/string-no-newline/index.js:99:6:
   97 | 					valueNode.quote,
   98 | 					// length of the contents before newline
>  99 | 					RegExp.leftContext,
      | 					^
  100 | 				].reduce((index, str) => index + str.length, valueNode.sourceIndex);
  101 | 
  102 | 				report({


error: Capturing group number 2 is defined but never used (regexp/no-unused-capturing-group) at lib/rules/unit-disallowed-list/index.js:28:11:
  26 | 	const value = mediaFeatureNode.value.toLowerCase();
  27 | 
> 28 | 	return /((-?\w*)*)/.exec(value)[1];
     | 	         ^
  29 | };
  30 | 
  31 | function rule(listInput, options) {


error: Unexpected useless alternative. This alternative is a strict subset of '\d+(?:\.\d*)?' and can be removed (regexp/no-dupe-disjunctions) at lib/utils/isKeyframeSelector.js:17:25:
  15 | 
  16 | 	// Percentages
> 17 | 	if (/^(?:\d+(?:\.\d*)?|\d+(?:\.\d+)?|\.\d+)%$/.test(selector)) {
     | 	                       ^
  18 | 		return true;
  19 | 	}
  20 | 


warning: The quantifier can be removed because the quantifier is lazy and has a minimum of 1 (regexp/no-lazy-ends) at lib/utils/isStandardSyntaxMediaFeatureName.js:11:18:
   9 | module.exports = function (mediaFeatureName) {
  10 | 	// SCSS interpolation
> 11 | 	if (/#\{.+?\}|\$.+?/.test(mediaFeatureName)) {
     | 	                ^
  12 | 		return false;
  13 | 	}
  14 | 


error: Capturing group number 1 is defined but never used (regexp/no-unused-capturing-group) at lib/utils/isStandardSyntaxSelector.js:28:14:
  26 | 
  27 | 	// Less :extend()
> 28 | 	if (/:extend(\(.*?\))?/.test(selector)) {
     | 	            ^
  29 | 		return false;
  30 | 	}
  31 | 


error: Unexpected obscure character range. The characters of '+-/' (U+002b - U+002f) are not obvious (regexp/no-obscure-range) at lib/utils/isStandardSyntaxUrl.js:43:35:
  41 | 	// But in this case it is allowed to use only specific characters
  42 | 	// Also forbidden "/" at the end of url
> 43 | 	if (url.includes('$') && /^[$\s\w+-/*'"]+$/.test(url) && !url.endsWith('/')) {
     | 	                                 ^
  44 | 		return false;
  45 | 	}
  46 | 


15 errors and 1 warning found.

@ybiquitous
Copy link
Member

ybiquitous commented Sep 14, 2021

Fixed regexp/no-unused-capturing-group problems via a08087b. The following addition is necessary for auto-fix:

       "require": true,
       "testRule": true
     },
+    "rules": {
+      "regexp/no-unused-capturing-group": ["error", {"fixable": true}]
+    },
     "root": true
   },
   "remarkConfig": {

EDIT: 7 problems left. We need to fix them manually.

@ybiquitous
Copy link
Member

It seems the ESLint plugin doesn't resolve the CodeQL warning of the indentation rule. 🤔 (see #5128)

@jeddy3
Copy link
Member

jeddy3 commented Sep 15, 2021

It seems the ESLint plugin doesn't resolve the CodeQL warning of the indentation rule. 🤔 (see #5128)

That's a shame as I'll now need to unpick that regex ourselves.

It's a good thing that the CodeQL is there to catch these things, though.

@@ -20,7 +20,7 @@ it('standalone with postcss-safe-parser', () => {

expect(results).toHaveLength(6);

const safeParserExtensionsTest = /\.(css|pcss|postcss)$/i;
const safeParserExtensionsTest = /\.(?:css|pcss|postcss)$/i;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See regexp/no-unused-capturing-group - ?: creates a non-capturing group.

@@ -64,7 +64,7 @@ const rule = (primary, _secondaryOptions, context) => {
const betweenBefore = between.slice(0, sliceIndex);
const betweenAfter = between.slice(sliceIndex);

if (/^\s*\r?\n/.test(betweenAfter)) {
if (/^\s*\n/.test(betweenAfter)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See regexp/optimal-quantifier-concatenation - \s* includes \r? already.

@@ -241,7 +241,7 @@ function insertCharAtIndex(str, index, char) {
* @param {string} source
*/
function blurVariables(source) {
return source.replace(/[$@][^)\s]+|#{.+?}/g, '0');
return source.replace(/[$@][^)\s]+|#\{.+?\}/g, '0');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const matched = /(?:^|\n)([ \t]*)$/.exec(root.raws.beforeStart);

if (matched) {
return matched[1] + firstLine;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See regexp/no-legacy-features - RegExp.$1 -> matched[1]

@@ -161,7 +161,7 @@ const rule = (primary, secondaryOptions, context) => {
const emptyLFLines = '\n'.repeat(repeatTimes);
const emptyCRLFLines = '\r\n'.repeat(repeatTimes);

return /(\r\n)+/g.test(str)
return /(?:\r\n)+/.test(str)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See regexp/no-useless-flag - g flag is useless for .test()

@@ -29,7 +29,7 @@ module.exports = function mediaQueryListCommaWhitespaceChecker(opts) {
index += execResult[0].length;
}

if ((execResult = /^([^\S\r\n]*\/\/([\s\S]*?))\r?\n/.exec(params.slice(index + 1)))) {
if ((execResult = /^([^\S\r\n]*\/\/[\s\S]*?)\r?\n/.exec(params.slice(index + 1)))) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -52,7 +52,7 @@ function rule(actual, secondary, context) {
return;
}

const match = /\.(\d*?)(0+)(?:\D|$)/.exec(valueNode.value);
const match = /\.(\d{0,100}?)(0+)(?:\D|$)/.exec(valueNode.value);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See regexp/no-super-linear-backtracking - * can be potential ReDoS, so it changes to {0,100}

@@ -60,7 +60,7 @@ testRule({

testRule({
ruleName,
config: [/\.foo.*>.*\.bar/],
config: [/\.foo[^>]*>.*\.bar/],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -62,7 +64,7 @@ function rule(actual) {
// length of our operator , ie '='
attributeNode.operator,
// length of the contents before newline
RegExp.leftContext,
match.input.slice(0, match.index),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -8,7 +8,7 @@
*/
module.exports = function (mediaFeatureName) {
// SCSS interpolation
if (/#{.+?}|\$.+?/.test(mediaFeatureName)) {
if (/#\{.+?\}|\$.+/.test(mediaFeatureName)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -40,7 +40,7 @@ module.exports = function (url) {
// In url without quotes scss variable can be everywhere
// But in this case it is allowed to use only specific characters
// Also forbidden "/" at the end of url
if (url.includes('$') && /^[$\s\w+-/*'"/]+$/.test(url) && !url.endsWith('/')) {
if (url.includes('$') && /^[$\s\w+\-,./*'"]+$/.test(url) && !url.endsWith('/')) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See regexp/no-obscure-range and regexp/no-dupe-characters-character-class - [+-/] means a range between between + (index 43) and / (index 47). It is the same as [+,-./].

@ybiquitous
Copy link
Member

I've fixed all regex violations! 🙌🏼

Copy link
Member

@jeddy3 jeddy3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing, thank you!

@ybiquitous ybiquitous merged commit 3233c82 into v14 Sep 15, 2021
@ybiquitous ybiquitous deleted the dependabot/npm_and_yarn/v14/eslint-config-stylelint-14.0.0 branch September 15, 2021 15:39
@ybiquitous ybiquitous mentioned this pull request Sep 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: dependencies relates to dependencies
Development

Successfully merging this pull request may close these issues.

None yet

3 participants