Skip to content

Commit

Permalink
Bump eslint-config-stylelint from 13.1.1 to 14.0.0 (#5536)
Browse files Browse the repository at this point in the history
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>

In addition, this change fixes new ESLint problems about regexp.

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Masafumi Koba <473530+ybiquitous@users.noreply.github.com>
  • Loading branch information
dependabot[bot] and ybiquitous committed Sep 15, 2021
1 parent ee69d22 commit 3233c82
Show file tree
Hide file tree
Showing 24 changed files with 322 additions and 132 deletions.
2 changes: 1 addition & 1 deletion lib/__tests__/standalone-syntax.test.js
Expand Up @@ -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;

results
.filter((result) => !safeParserExtensionsTest.test(result.source))
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/color-hex-alpha/index.js
Expand Up @@ -13,7 +13,7 @@ const messages = ruleMessages(ruleName, {
unexpected: (hex) => `Unexpected alpha channel in "${hex}"`,
});

const HEX = /^#([\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})$/i;
const HEX = /^#(?:[\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})$/i;

/** @type {import('stylelint').StylelintRule} */
const rule = (primary) => {
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/declaration-colon-newline-after/index.js
Expand Up @@ -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)) {
decl.raws.between = betweenBefore + betweenAfter.replace(/^[^\S\r\n]*/, '');
} else {
decl.raws.between = betweenBefore + context.newline + betweenAfter;
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/font-family-name-quotes/index.js
Expand Up @@ -52,7 +52,7 @@ function quotesRecommended(family) {
*/
function quotesRequired(family) {
return family.split(/\s+/).some((word) => {
return /^(-?\d|--)/.test(word) || !/^[-_a-zA-Z0-9\u{00A0}-\u{10FFFF}]+$/u.test(word);
return /^(?:-?\d|--)/.test(word) || !/^[-\w\u{00A0}-\u{10FFFF}]+$/u.test(word);
});
}

Expand Down
2 changes: 1 addition & 1 deletion lib/rules/function-calc-no-unspaced-operator/index.js
Expand Up @@ -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');
}

/**
Expand Down
10 changes: 6 additions & 4 deletions lib/rules/indentation/index.js
Expand Up @@ -303,13 +303,13 @@ const rule = (primary, secondaryOptions = {}, context) => {
parentheticalDepth += 1;
}

const followsOpeningBrace = /{[ \t]*$/.test(source.slice(0, newlineIndex));
const followsOpeningBrace = /\{[ \t]*$/.test(source.slice(0, newlineIndex));

if (followsOpeningBrace) {
parentheticalDepth += 1;
}

const startingClosingBrace = /^[ \t]*}/.test(source.slice(match.startIndex + 1));
const startingClosingBrace = /^[ \t]*\}/.test(source.slice(match.startIndex + 1));

if (startingClosingBrace) {
parentheticalDepth -= 1;
Expand Down Expand Up @@ -607,8 +607,10 @@ function inferRootIndentLevel(root, baseIndentLevel, indentSize) {
let source = root.source.input.css;

source = source.replace(/^[^\r\n]+/, (firstLine) => {
if (/(?:^|\n)([ \t]*)$/.test(root.raws.beforeStart)) {
return RegExp.$1 + firstLine;
const match = /(?:^|\n)([ \t]*)$/.exec(root.raws.beforeStart);

if (match) {
return match[1] + firstLine;
}

return '';
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/max-empty-lines/index.js
Expand Up @@ -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)
? str.replace(/(\r\n)+/g, ($1) => {
if ($1.length / 2 > repeatTimes) {
return emptyCRLFLines;
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/media-query-list-comma-newline-after/index.js
Expand Up @@ -65,7 +65,7 @@ const rule = (primary, _secondaryOptions, context) => {
const afterComma = params.slice(index + 1);

if (primary.startsWith('always')) {
params = /^\s*\r?\n/.test(afterComma)
params = /^\s*\n/.test(afterComma)
? beforeComma + afterComma.replace(/^[^\S\r\n]*/, '')
: beforeComma + context.newline + afterComma;
} else if (primary.startsWith('never')) {
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/mediaQueryListCommaWhitespaceChecker.js
Expand Up @@ -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)))) {
index += execResult[1].length;
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/number-no-trailing-zeros/index.js
Expand Up @@ -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);

// match[1] is any numbers between the decimal and our trailing zero, could be empty
// match[2] is our trailing zero(s)
Expand Down
4 changes: 2 additions & 2 deletions lib/rules/selector-disallowed-list/__tests__/index.js
Expand Up @@ -4,7 +4,7 @@ const { messages, ruleName } = require('..');

testRule({
ruleName,
config: ['a > .foo', /\[data-.+]/],
config: ['a > .foo', /\[data-.+\]/],

accept: [
{
Expand Down Expand Up @@ -60,7 +60,7 @@ testRule({

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

accept: [
{
Expand Down
18 changes: 13 additions & 5 deletions lib/rules/string-no-newline/index.js
Expand Up @@ -12,7 +12,7 @@ const validateOptions = require('../../utils/validateOptions');
const valueParser = require('postcss-value-parser');

const ruleName = 'string-no-newline';
const reNewLine = /(\r?\n)/;
const reNewLine = /\r?\n/;

const messages = ruleMessages(ruleName, {
rejected: 'Unexpected newline in string',
Expand Down Expand Up @@ -52,7 +52,9 @@ function rule(actual) {

parseSelector(ruleNode.selector, result, ruleNode, (selectorTree) => {
selectorTree.walkAttributes((attributeNode) => {
if (!reNewLine.test(attributeNode.value)) {
const match = reNewLine.exec(attributeNode.value);

if (!match) {
return;
}

Expand All @@ -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),
].reduce(
(index, str) => index + str.length,
// index of the start of our attribute node in our source
Expand All @@ -88,15 +90,21 @@ function rule(actual) {
}

valueParser(value).walk((valueNode) => {
if (valueNode.type !== 'string' || !reNewLine.test(valueNode.value)) {
if (valueNode.type !== 'string') {
return;
}

const match = reNewLine.exec(valueNode.value);

if (!match) {
return;
}

const openIndex = [
// length of the quote
valueNode.quote,
// length of the contents before newline
RegExp.leftContext,
match.input.slice(0, match.index),
].reduce((index, str) => index + str.length, valueNode.sourceIndex);

report({
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/unit-disallowed-list/index.js
Expand Up @@ -25,7 +25,7 @@ const messages = ruleMessages(ruleName, {
const getMediaFeatureName = (mediaFeatureNode) => {
const value = mediaFeatureNode.value.toLowerCase();

return /((-?\w*)*)/i.exec(value)[1];
return /((?:-?\w*)*)/.exec(value)[1];
};

function rule(listInput, options) {
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/hasLessInterpolation.js
Expand Up @@ -7,5 +7,5 @@
* @return {boolean} If `true`, a string has less interpolation
*/
module.exports = function (string) {
return /@{.+?}/.test(string);
return /@\{.+?\}/.test(string);
};
2 changes: 1 addition & 1 deletion lib/utils/hasScssInterpolation.js
Expand Up @@ -6,5 +6,5 @@
* @param {string} string
*/
module.exports = function (string) {
return /#{.+?}/.test(string);
return /#\{.+?\}/.test(string);
};
2 changes: 1 addition & 1 deletion lib/utils/hasTplInterpolation.js
Expand Up @@ -7,5 +7,5 @@
* @return {boolean} If `true`, a string has template literal interpolation
*/
module.exports = function (string) {
return /{.+?}/.test(string);
return /\{.+?\}/.test(string);
};
2 changes: 1 addition & 1 deletion lib/utils/isKeyframeSelector.js
Expand Up @@ -14,7 +14,7 @@ module.exports = function (selector) {
}

// Percentages
if (/^(?:\d+\.?\d*|\d*\.?\d+)%$/.test(selector)) {
if (/^(?:\d+|\d*\.\d+)%$/.test(selector)) {
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/utils/isStandardSyntaxMediaFeatureName.js
Expand Up @@ -8,7 +8,7 @@
*/
module.exports = function (mediaFeatureName) {
// SCSS interpolation
if (/#{.+?}|\$.+?/.test(mediaFeatureName)) {
if (/#\{.+?\}|\$.+/.test(mediaFeatureName)) {
return false;
}

Expand Down
4 changes: 2 additions & 2 deletions lib/utils/isStandardSyntaxSelector.js
Expand Up @@ -25,12 +25,12 @@ module.exports = function (selector) {
}

// Less :extend()
if (/:extend(\(.*?\))?/.test(selector)) {
if (/:extend(?:\(.*?\))?/.test(selector)) {
return false;
}

// Less mixin with resolved nested selectors (e.g. .foo().bar or .foo(@a, @b)[bar])
if (/\.[\w-]+\(.*\).+/i.test(selector)) {
if (/\.[\w-]+\(.*\).+/.test(selector)) {
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/utils/isStandardSyntaxUrl.js
Expand Up @@ -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('/')) {
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/utils/removeEmptyLinesAfter.js
Expand Up @@ -9,7 +9,7 @@
* @returns {T}
*/
module.exports = function removeEmptyLinesAfter(node, newline) {
node.raws.after = node.raws.after ? node.raws.after.replace(/(\r?\n\s*\r?\n)+/g, newline) : '';
node.raws.after = node.raws.after ? node.raws.after.replace(/(\r?\n\s*\n)+/g, newline) : '';

return node;
};
2 changes: 1 addition & 1 deletion lib/utils/removeEmptyLinesBefore.js
Expand Up @@ -9,7 +9,7 @@
* @returns {T}
*/
module.exports = function removeEmptyLinesBefore(node, newline) {
node.raws.before = node.raws.before ? node.raws.before.replace(/(\r?\n\s*\r?\n)+/g, newline) : '';
node.raws.before = node.raws.before ? node.raws.before.replace(/(\r?\n\s*\n)+/g, newline) : '';

return node;
};

0 comments on commit 3233c82

Please sign in to comment.