diff --git a/.changeset/rare-squids-tell.md b/.changeset/rare-squids-tell.md
new file mode 100644
index 0000000000..caafeede7a
--- /dev/null
+++ b/.changeset/rare-squids-tell.md
@@ -0,0 +1,5 @@
+---
+"stylelint": major
+---
+
+Removed: 76 rules deprecated in 15.0.0
diff --git a/docs/migration-guide/to-15.md b/docs/migration-guide/to-15.md
index 0c5d432e0a..7462e893be 100644
--- a/docs/migration-guide/to-15.md
+++ b/docs/migration-guide/to-15.md
@@ -11,7 +11,84 @@ Two significant changes may affect you:
### Deprecated stylistic rules
-We've deprecated [76 of the rules that enforce stylistic conventions](../user-guide/rules.md#deprecated), e.g. `indentation`.
+We've deprecated 76 of the rules that enforce stylistic conventions:
+
+- `at-rule-name-case`
+- `at-rule-name-newline-after`
+- `at-rule-name-space-after`
+- `at-rule-semicolon-newline-after`
+- `at-rule-semicolon-space-before`
+- `block-closing-brace-empty-line-before`
+- `block-closing-brace-newline-after`
+- `block-closing-brace-newline-before`
+- `block-closing-brace-space-after`
+- `block-closing-brace-space-before`
+- `block-opening-brace-newline-after`
+- `block-opening-brace-newline-before`
+- `block-opening-brace-space-after`
+- `block-opening-brace-space-before`
+- `color-hex-case`
+- `declaration-bang-space-after`
+- `declaration-bang-space-before`
+- `declaration-block-semicolon-newline-after`
+- `declaration-block-semicolon-newline-before`
+- `declaration-block-semicolon-space-after`
+- `declaration-block-semicolon-space-before`
+- `declaration-block-trailing-semicolon`
+- `declaration-colon-newline-after`
+- `declaration-colon-space-after`
+- `declaration-colon-space-before`
+- `function-comma-newline-after`
+- `function-comma-newline-before`
+- `function-comma-space-after`
+- `function-comma-space-before`
+- `function-max-empty-lines`
+- `function-parentheses-newline-inside`
+- `function-parentheses-space-inside`
+- `function-whitespace-after`
+- `indentation`
+- `linebreaks`
+- `max-empty-lines`
+- `max-line-length`
+- `media-feature-colon-space-after`
+- `media-feature-colon-space-before`
+- `media-feature-name-case`
+- `media-feature-parentheses-space-inside`
+- `media-feature-range-operator-space-after`
+- `media-feature-range-operator-space-before`
+- `media-query-list-comma-newline-after`
+- `media-query-list-comma-newline-before`
+- `media-query-list-comma-space-after`
+- `media-query-list-comma-space-before`
+- `no-empty-first-line`
+- `no-eol-whitespace`
+- `no-extra-semicolons`
+- `no-missing-end-of-source-newline`
+- `number-leading-zero`
+- `number-no-trailing-zeros`
+- `property-case`
+- `selector-attribute-brackets-space-inside`
+- `selector-attribute-operator-space-after`
+- `selector-attribute-operator-space-before`
+- `selector-combinator-space-after`
+- `selector-combinator-space-before`
+- `selector-descendant-combinator-no-non-space`
+- `selector-list-comma-newline-after`
+- `selector-list-comma-newline-before`
+- `selector-list-comma-space-after`
+- `selector-list-comma-space-before`
+- `selector-max-empty-lines`
+- `selector-pseudo-class-case`
+- `selector-pseudo-class-parentheses-space-inside`
+- `selector-pseudo-element-case`
+- `string-quotes`
+- `unicode-bom`
+- `unit-case`
+- `value-list-comma-newline-after`
+- `value-list-comma-newline-before`
+- `value-list-comma-space-after`
+- `value-list-comma-space-before`
+- `value-list-max-empty-lines`
When we created these rules, pretty printers (like [Prettier](https://prettier.io/)) didn't exist. They now offer a better way to consistently format code, especially whitespace. Linters and pretty printers are complementary tools that work together to help you write consistent and error-free code.
@@ -20,7 +97,7 @@ By deprecating these rules, we can:
- focus on writing and maintaining rules that help you [avoid errors](../user-guide/rules.md#avoid-errors) and [enforce (non-stylistic) conventions](../user-guide/rules.md#enforce-conventions), both of which are unique to Stylelint
- modernize our codebase, e.g. move to ESM so that we can update our dependencies and keep Stylelint secure for you
-The [deprecated rules](../user-guide/rules.md#deprecated) will still work in this release (with a deprecation warning). In preparation for the next major release, when we'll remove the rules from Stylelint, we suggest:
+The deprecated rules will still work in this release (with a deprecation warning). In preparation for the next major release, when we'll remove the rules from Stylelint, we suggest:
- extending the [standard config](https://www.npmjs.com/package/stylelint-config-standard) in your configuration object, if you don't already
- removing the deprecated rules from your configuration object
@@ -43,7 +120,7 @@ Additionally, you may no longer need to extend [Prettier's Stylelint config](htt
}
```
-We've removed the [deprecated rules](../user-guide/rules.md#deprecated) from the latest version of the [standard config](https://www.npmjs.com/package/stylelint-config-standard). It still helps you write consistent CSS by turning on many of the [other rules that enforce conventions](../user-guide/rules.md#enforce-conventions), e.g. most of the [`*-notation`](../user-guide/rules.md#notation), [`*-pattern`](../user-guide/rules.md#pattern) and [`*-quotes`](../user-guide/rules.md#quotes) rules.
+We've removed the deprecated rules from the latest version of the [standard config](https://www.npmjs.com/package/stylelint-config-standard). It still helps you write consistent CSS by turning on many of the [other rules that enforce conventions](../user-guide/rules.md#enforce-conventions), e.g. most of the [`*-notation`](../user-guide/rules.md#notation), [`*-pattern`](../user-guide/rules.md#pattern) and [`*-quotes`](../user-guide/rules.md#quotes) rules.
There are lots of other rules we don't turn on in the [standard config](https://www.npmjs.com/package/stylelint-config-standard) and you can learn more about using them to customize Stylelint to your exact needs in our [new guide](../user-guide/customize.md).
diff --git a/docs/migration-guide/to-16.md b/docs/migration-guide/to-16.md
new file mode 100644
index 0000000000..d566609977
--- /dev/null
+++ b/docs/migration-guide/to-16.md
@@ -0,0 +1,7 @@
+# Migrating to 16.0.0
+
+This release contains breaking changes.
+
+## Removed deprecated stylistic rules
+
+We've removed the stylistic rules we deprecated in 15.0.0. See the [15.0.0 migration guide](./to-15.md) for details on how to migrate.
diff --git a/docs/user-guide/options.md b/docs/user-guide/options.md
index ea3ced9cb3..ba8cd77129 100644
--- a/docs/user-guide/options.md
+++ b/docs/user-guide/options.md
@@ -42,7 +42,7 @@ When using the Node.js API, the autofixed code is available as the value of the
If a source contains a:
-- scoped disable comment, e.g. `/* stylelint-disable indentation */`, any problems reported by the scoped rules will not be automatically fixed anywhere in the source
+- scoped disable comment, e.g. `/* stylelint-disable color-named */`, any problems reported by the scoped rules will not be automatically fixed anywhere in the source
- unscoped disable comment, i.e. `/* stylelint-disable */`, the entirety of source will not be automatically fixed
This limitation in being tracked in [issue #2643](https://github.com/stylelint/stylelint/issues/2643).
diff --git a/docs/user-guide/rules.md b/docs/user-guide/rules.md
index 575b1b12d8..c75ce43ed5 100644
--- a/docs/user-guide/rules.md
+++ b/docs/user-guide/rules.md
@@ -388,196 +388,4 @@ Require or disallow whitespace on the inside with this `whitespace-inside` rule.
| | | |
| :-- | :-: | :-: |
| [`comment-whitespace-inside`](../../lib/rules/comment-whitespace-inside/README.md)
Require or disallow whitespace on the inside of comment markers. | ✅ | 🔧 |
-
-## Deprecated
-
-These rules are deprecated — we won't fix bugs nor add options, and we will remove them in the next major release. We recommend you use a pretty printer (like Prettier) alongside Stylelint rather than these rules.
-
-
-### Color
-
-
-| | | |
-| :-- | :-: | :-: |
-| [`color-hex-case`](../../lib/rules/color-hex-case/README.md)
Specify lowercase or uppercase for hex colors. | | 🔧 |
-
-
-### Function
-
-
-| | | |
-| :-- | :-: | :-: |
-| [`function-comma-newline-after`](../../lib/rules/function-comma-newline-after/README.md)
Require a newline or disallow whitespace after the commas of functions. | | 🔧 |
-| [`function-comma-newline-before`](../../lib/rules/function-comma-newline-before/README.md)
Require a newline or disallow whitespace before the commas of functions. | | 🔧 |
-| [`function-comma-space-after`](../../lib/rules/function-comma-space-after/README.md)
Require a single space or disallow whitespace after the commas of functions. | | 🔧 |
-| [`function-comma-space-before`](../../lib/rules/function-comma-space-before/README.md)
Require a single space or disallow whitespace before the commas of functions. | | 🔧 |
-| [`function-max-empty-lines`](../../lib/rules/function-max-empty-lines/README.md)
Limit the number of adjacent empty lines within functions. | | 🔧 |
-| [`function-parentheses-newline-inside`](../../lib/rules/function-parentheses-newline-inside/README.md)
Require a newline or disallow whitespace on the inside of the parentheses of functions. | | 🔧 |
-| [`function-parentheses-space-inside`](../../lib/rules/function-parentheses-space-inside/README.md)
Require a single space or disallow whitespace on the inside of the parentheses of functions. | | 🔧 |
-| [`function-whitespace-after`](../../lib/rules/function-whitespace-after/README.md)
Require or disallow whitespace after functions. | | 🔧 |
-
-
-### Number
-
-
-| | | |
-| :-- | :-: | :-: |
-| [`number-leading-zero`](../../lib/rules/number-leading-zero/README.md)
Require or disallow a leading zero for fractional numbers less than 1. | | 🔧 |
-| [`number-no-trailing-zeros`](../../lib/rules/number-no-trailing-zeros/README.md)
Disallow trailing zeros in numbers. | | 🔧 |
-
-
-### String
-
-
-| | | |
-| :-- | :-: | :-: |
-| [`string-quotes`](../../lib/rules/string-quotes/README.md)
Specify single or double quotes around strings. | | 🔧 |
-
-
-### Unit
-
-
-| | | |
-| :-- | :-: | :-: |
-| [`unit-case`](../../lib/rules/unit-case/README.md)
Specify lowercase or uppercase for units. | | 🔧 |
-
-
-### Value list
-
-
-| | | |
-| :-- | :-: | :-: |
-| [`value-list-comma-newline-after`](../../lib/rules/value-list-comma-newline-after/README.md)
Require a newline or disallow whitespace after the commas of value lists. | | 🔧 |
-| [`value-list-comma-newline-before`](../../lib/rules/value-list-comma-newline-before/README.md)
Require a newline or disallow whitespace before the commas of value lists. | | |
-| [`value-list-comma-space-after`](../../lib/rules/value-list-comma-space-after/README.md)
Require a single space or disallow whitespace after the commas of value lists. | | 🔧 |
-| [`value-list-comma-space-before`](../../lib/rules/value-list-comma-space-before/README.md)
Require a single space or disallow whitespace before the commas of value lists. | | 🔧 |
-| [`value-list-max-empty-lines`](../../lib/rules/value-list-max-empty-lines/README.md)
Limit the number of adjacent empty lines within value lists. | | 🔧 |
-
-
-### Property
-
-
-| | | |
-| :-- | :-: | :-: |
-| [`property-case`](../../lib/rules/property-case/README.md)
Specify lowercase or uppercase for properties. | | 🔧 |
-
-
-### Declaration
-
-
-| | | |
-| :-- | :-: | :-: |
-| [`declaration-bang-space-after`](../../lib/rules/declaration-bang-space-after/README.md)
Require a single space or disallow whitespace after the bang of declarations. | | 🔧 |
-| [`declaration-bang-space-before`](../../lib/rules/declaration-bang-space-before/README.md)
Require a single space or disallow whitespace before the bang of declarations. | | 🔧 |
-| [`declaration-colon-newline-after`](../../lib/rules/declaration-colon-newline-after/README.md)
Require a newline or disallow whitespace after the colon of declarations. | | 🔧 |
-| [`declaration-colon-space-after`](../../lib/rules/declaration-colon-space-after/README.md)
Require a single space or disallow whitespace after the colon of declarations. | | 🔧 |
-| [`declaration-colon-space-before`](../../lib/rules/declaration-colon-space-before/README.md)
Require a single space or disallow whitespace before the colon of declarations. | | 🔧 |
-
-
-### Declaration block
-
-
-| | | |
-| :-- | :-: | :-: |
-| [`declaration-block-semicolon-newline-after`](../../lib/rules/declaration-block-semicolon-newline-after/README.md)
Require a newline or disallow whitespace after the semicolons of declaration blocks. | | 🔧 |
-| [`declaration-block-semicolon-newline-before`](../../lib/rules/declaration-block-semicolon-newline-before/README.md)
Require a newline or disallow whitespace before the semicolons of declaration blocks. | | |
-| [`declaration-block-semicolon-space-after`](../../lib/rules/declaration-block-semicolon-space-after/README.md)
Require a single space or disallow whitespace after the semicolons of declaration blocks. | | 🔧 |
-| [`declaration-block-semicolon-space-before`](../../lib/rules/declaration-block-semicolon-space-before/README.md)
Require a single space or disallow whitespace before the semicolons of declaration blocks. | | 🔧 |
-| [`declaration-block-trailing-semicolon`](../../lib/rules/declaration-block-trailing-semicolon/README.md)
Require or disallow a trailing semicolon within declaration blocks. | | 🔧 |
-
-
-### Block
-
-
-| | | |
-| :-- | :-: | :-: |
-| [`block-closing-brace-empty-line-before`](../../lib/rules/block-closing-brace-empty-line-before/README.md)
Require or disallow an empty line before the closing brace of blocks. | | 🔧 |
-| [`block-closing-brace-newline-after`](../../lib/rules/block-closing-brace-newline-after/README.md)
Require a newline or disallow whitespace after the closing brace of blocks. | | 🔧 |
-| [`block-closing-brace-newline-before`](../../lib/rules/block-closing-brace-newline-before/README.md)
Require a newline or disallow whitespace before the closing brace of blocks. | | 🔧 |
-| [`block-closing-brace-space-after`](../../lib/rules/block-closing-brace-space-after/README.md)
Require a single space or disallow whitespace after the closing brace of blocks. | | |
-| [`block-closing-brace-space-before`](../../lib/rules/block-closing-brace-space-before/README.md)
Require a single space or disallow whitespace before the closing brace of blocks. | | 🔧 |
-| [`block-opening-brace-newline-after`](../../lib/rules/block-opening-brace-newline-after/README.md)
Require a newline after the opening brace of blocks. | | 🔧 |
-| [`block-opening-brace-newline-before`](../../lib/rules/block-opening-brace-newline-before/README.md)
Require a newline or disallow whitespace before the opening brace of blocks. | | 🔧 |
-| [`block-opening-brace-space-after`](../../lib/rules/block-opening-brace-space-after/README.md)
Require a single space or disallow whitespace after the opening brace of blocks. | | 🔧 |
-| [`block-opening-brace-space-before`](../../lib/rules/block-opening-brace-space-before/README.md)
Require a single space or disallow whitespace before the opening brace of blocks. | | 🔧 |
-
-
-### Selector
-
-
-| | | |
-| :-- | :-: | :-: |
-| [`selector-attribute-brackets-space-inside`](../../lib/rules/selector-attribute-brackets-space-inside/README.md)
Require a single space or disallow whitespace on the inside of the brackets within attribute selectors. | | 🔧 |
-| [`selector-attribute-operator-space-after`](../../lib/rules/selector-attribute-operator-space-after/README.md)
Require a single space or disallow whitespace after operators within attribute selectors. | | 🔧 |
-| [`selector-attribute-operator-space-before`](../../lib/rules/selector-attribute-operator-space-before/README.md)
Require a single space or disallow whitespace before operators within attribute selectors. | | 🔧 |
-| [`selector-combinator-space-after`](../../lib/rules/selector-combinator-space-after/README.md)
Require a single space or disallow whitespace after the combinators of selectors. | | 🔧 |
-| [`selector-combinator-space-before`](../../lib/rules/selector-combinator-space-before/README.md)
Require a single space or disallow whitespace before the combinators of selectors. | | 🔧 |
-| [`selector-descendant-combinator-no-non-space`](../../lib/rules/selector-descendant-combinator-no-non-space/README.md)
Disallow non-space characters for descendant combinators of selectors. | | 🔧 |
-| [`selector-max-empty-lines`](../../lib/rules/selector-max-empty-lines/README.md)
Limit the number of adjacent empty lines within selectors. | | 🔧 |
-| [`selector-pseudo-class-case`](../../lib/rules/selector-pseudo-class-case/README.md)
Specify lowercase or uppercase for pseudo-class selectors. | | 🔧 |
-| [`selector-pseudo-class-parentheses-space-inside`](../../lib/rules/selector-pseudo-class-parentheses-space-inside/README.md)
Require a single space or disallow whitespace on the inside of the parentheses within pseudo-class selectors. | | 🔧 |
-| [`selector-pseudo-element-case`](../../lib/rules/selector-pseudo-element-case/README.md)
Specify lowercase or uppercase for pseudo-element selectors. | | 🔧 |
-
-
-### Selector list
-
-
-| | | |
-| :-- | :-: | :-: |
-| [`selector-list-comma-newline-after`](../../lib/rules/selector-list-comma-newline-after/README.md)
Require a newline or disallow whitespace after the commas of selector lists. | | 🔧 |
-| [`selector-list-comma-newline-before`](../../lib/rules/selector-list-comma-newline-before/README.md)
Require a newline or disallow whitespace before the commas of selector lists. | | 🔧 |
-| [`selector-list-comma-space-after`](../../lib/rules/selector-list-comma-space-after/README.md)
Require a single space or disallow whitespace after the commas of selector lists. | | 🔧 |
-| [`selector-list-comma-space-before`](../../lib/rules/selector-list-comma-space-before/README.md)
Require a single space or disallow whitespace before the commas of selector lists. | | 🔧 |
-
-
-### Media feature
-
-
-| | | |
-| :-- | :-: | :-: |
-| [`media-feature-colon-space-after`](../../lib/rules/media-feature-colon-space-after/README.md)
Require a single space or disallow whitespace after the colon in media features. | | 🔧 |
-| [`media-feature-colon-space-before`](../../lib/rules/media-feature-colon-space-before/README.md)
Require a single space or disallow whitespace before the colon in media features. | | 🔧 |
-| [`media-feature-name-case`](../../lib/rules/media-feature-name-case/README.md)
Specify lowercase or uppercase for media feature names. | | 🔧 |
-| [`media-feature-parentheses-space-inside`](../../lib/rules/media-feature-parentheses-space-inside/README.md)
Require a single space or disallow whitespace on the inside of the parentheses within media features. | | 🔧 |
-| [`media-feature-range-operator-space-after`](../../lib/rules/media-feature-range-operator-space-after/README.md)
Require a single space or disallow whitespace after the range operator in media features. | | 🔧 |
-| [`media-feature-range-operator-space-before`](../../lib/rules/media-feature-range-operator-space-before/README.md)
Require a single space or disallow whitespace before the range operator in media features. | | 🔧 |
-
-
-### Media query list
-
-
-| | | |
-| :-- | :-: | :-: |
-| [`media-query-list-comma-newline-after`](../../lib/rules/media-query-list-comma-newline-after/README.md)
Require a newline or disallow whitespace after the commas of media query lists. | | 🔧 |
-| [`media-query-list-comma-newline-before`](../../lib/rules/media-query-list-comma-newline-before/README.md)
Require a newline or disallow whitespace before the commas of media query lists. | | |
-| [`media-query-list-comma-space-after`](../../lib/rules/media-query-list-comma-space-after/README.md)
Require a single space or disallow whitespace after the commas of media query lists. | | 🔧 |
-| [`media-query-list-comma-space-before`](../../lib/rules/media-query-list-comma-space-before/README.md)
Require a single space or disallow whitespace before the commas of media query lists. | | 🔧 |
-
-
-### At-rule
-
-
-| | | |
-| :-- | :-: | :-: |
-| [`at-rule-name-case`](../../lib/rules/at-rule-name-case/README.md)
Specify lowercase or uppercase for at-rules names. | | 🔧 |
-| [`at-rule-name-newline-after`](../../lib/rules/at-rule-name-newline-after/README.md)
Require a newline after at-rule names. | | |
-| [`at-rule-name-space-after`](../../lib/rules/at-rule-name-space-after/README.md)
Require a single space after at-rule names. | | 🔧 |
-| [`at-rule-semicolon-newline-after`](../../lib/rules/at-rule-semicolon-newline-after/README.md)
Require a newline after the semicolon of at-rules. | | 🔧 |
-| [`at-rule-semicolon-space-before`](../../lib/rules/at-rule-semicolon-space-before/README.md)
Require a single space or disallow whitespace before the semicolons of at-rules. | | |
-
-
-### General / Sheet
-
-
-| | | |
-| :-- | :-: | :-: |
-| [`indentation`](../../lib/rules/indentation/README.md)
Specify indentation. | | 🔧 |
-| [`linebreaks`](../../lib/rules/linebreaks/README.md)
Specify unix or windows linebreaks. | | 🔧 |
-| [`max-empty-lines`](../../lib/rules/max-empty-lines/README.md)
Limit the number of adjacent empty lines. | | 🔧 |
-| [`max-line-length`](../../lib/rules/max-line-length/README.md)
Limit the length of a line. | | |
-| [`no-empty-first-line`](../../lib/rules/no-empty-first-line/README.md)
Disallow empty first lines. | | 🔧 |
-| [`no-eol-whitespace`](../../lib/rules/no-eol-whitespace/README.md)
Disallow end-of-line whitespace. | | 🔧 |
-| [`no-extra-semicolons`](../../lib/rules/no-extra-semicolons/README.md)
Disallow extra semicolons. | | 🔧 |
-| [`no-missing-end-of-source-newline`](../../lib/rules/no-missing-end-of-source-newline/README.md)
Disallow missing end-of-source newlines. | | 🔧 |
-| [`unicode-bom`](../../lib/rules/unicode-bom/README.md)
Require or disallow Unicode BOM. | | |
diff --git a/lib/__tests__/disableRanges-integration.test.mjs b/lib/__tests__/disableRanges-integration.test.mjs
index 51ee6ccaec..e263f47015 100644
--- a/lib/__tests__/disableRanges-integration.test.mjs
+++ b/lib/__tests__/disableRanges-integration.test.mjs
@@ -1,7 +1,7 @@
import blockNoEmpty from '../rules/block-no-empty/index.js';
-import maxLineLength from '../rules/max-line-length/index.js';
-import selectorCombinatorSpaceBefore from '../rules/selector-combinator-space-before/index.js';
-import stringQuotes from '../rules/string-quotes/index.js';
+import noDuplicateSelectors from '../rules/no-duplicate-selectors/index.js';
+import numberMaxPrecision from '../rules/number-max-precision/index.js';
+import stringNoNewline from '../rules/string-no-newline/index.js';
// disabling all rules
testRule({
@@ -92,13 +92,13 @@ testRule({
});
testRule({
- ruleName: selectorCombinatorSpaceBefore.ruleName,
- config: ['always'],
+ ruleName: noDuplicateSelectors.ruleName,
+ config: true,
reject: [
{
- code: 'a> b {}',
- message: selectorCombinatorSpaceBefore.messages.expectedBefore('>'),
+ code: 'a, a {}',
+ message: noDuplicateSelectors.messages.rejected('a', 1),
},
],
});
@@ -141,29 +141,29 @@ testRule({
});
testRule({
- ruleName: selectorCombinatorSpaceBefore.ruleName,
- config: ['always'],
+ ruleName: noDuplicateSelectors.ruleName,
+ config: true,
accept: [
{
- code: '/* stylelint-disable declaration-no-important, selector-combinator-space-before */ a> b {}',
+ code: '/* stylelint-disable declaration-no-important, no-duplicate-selectors */ a, a {}',
},
{
- code: '/* stylelint-disable-line declaration-no-important, selector-combinator-space-before */ a> b {}',
+ code: '/* stylelint-disable-line declaration-no-important, no-duplicate-selectors */ a, a {}',
},
{
- code: 'a> b {} /* stylelint-disable-line declaration-no-important, selector-combinator-space-before */',
+ code: 'a, a {} /* stylelint-disable-line declaration-no-important, no-duplicate-selectors */',
},
],
reject: [
{
- code: '/* stylelint-disable declaration-no-important */ a> b {}',
- message: selectorCombinatorSpaceBefore.messages.expectedBefore('>'),
+ code: '/* stylelint-disable declaration-no-important */ a, a {}',
+ message: noDuplicateSelectors.messages.rejected('a', 1),
},
{
- code: '/* stylelint-disable-line declaration-no-important */\na> b {}',
- message: selectorCombinatorSpaceBefore.messages.expectedBefore('>'),
+ code: '/* stylelint-disable-line declaration-no-important */\na, a {}',
+ message: noDuplicateSelectors.messages.rejected('a', 2),
},
],
});
@@ -199,38 +199,38 @@ testRule({
});
testRule({
- ruleName: maxLineLength.ruleName,
- config: [80],
+ ruleName: numberMaxPrecision.ruleName,
+ config: [2],
accept: [
{
code: `
/* stylelint-disable */
- .abracadabracadabra { background: linear-gradient(to top, rgba(255, 255, 255, 0.1), rgba (255, 255, 255, 1)); }
+ a { top: 0.123px; }
/* stylelint-enable */
`,
},
{
code: `
- /* stylelint-disable-line */ .abracadabracadabra { background: linear-gradient(to top, rgba(255, 255, 255, 0.1), rgba (255, 255, 255, 1)); }
+ /* stylelint-disable-line */ a { top: 0.123px; }
`,
},
{
code: `
- /* stylelint-disable max-line-length */
- .abracadabracadabra { background: linear-gradient(to top, rgba(255, 255, 255, 0.1), rgba (255, 255, 255, 1)); }
- /* stylelint-enable max-line-length */
+ /* stylelint-disable number-max-precision */
+ a { top: 0.123px; }
+ /* stylelint-enable number-max-precision */
`,
},
{
code: `
- .abracadabracadabra { background: linear-gradient(to top, rgba(255, 255, 255, 0.1), rgba (255, 255, 255, 1)); } /* stylelint-disable-line max-line-length */
+ a { top: 0.123px; } /* stylelint-disable-line number-max-precision */
`,
},
{
code: `
- /* stylelint-disable-next-line max-line-length */
- .abracadabracadabra { background: linear-gradient(to top, rgba(255, 255, 255, 0.1), rgba (255, 255, 255, 1)); }
+ /* stylelint-disable-next-line number-max-precision */
+ a { top: 0.123px; }
`,
},
],
@@ -239,67 +239,67 @@ testRule({
{
code: `
/* stylelint-disable block-no-empty */
- .abracadabracadabra { background: linear-gradient(to top, rgba(255, 255, 255, 0.1), rgba (255, 255, 255, 1)); }
+ a { top: 0.123px; }
/* stylelint-enable block-no-empty */
`,
- message: maxLineLength.messages.expected(80),
+ message: numberMaxPrecision.messages.expected('0.123', '0.12'),
},
{
code: `
/* stylelint-disable-line */
- .abracadabracadabra { background: linear-gradient(to top, rgba(255, 255, 255, 0.1), rgba (255, 255, 255, 1)); }
+ a { top: 0.123px; }
`,
- message: maxLineLength.messages.expected(80),
+ message: numberMaxPrecision.messages.expected('0.123', '0.12'),
},
{
code: `
- .abracadabracadabra { background: linear-gradient(to top, rgba(255, 255, 255, 0.1), rgba (255, 255, 255, 1)); }
+ a { top: 0.123px; }
/* stylelint-disable-line */
`,
- message: maxLineLength.messages.expected(80),
+ message: numberMaxPrecision.messages.expected('0.123', '0.12'),
},
{
code: `
- /* stylelint-disable max-line-length */
- .abracadabracadabra { background: linear-gradient(to top, rgba(255, 255, 255, 0.1), rgba (255, 255, 255, 1)); }
- /* stylelint-enable max-line-length */
- .abracadabracadabra { background: linear-gradient(to top, rgba(255, 255, 255, 0.1), rgba (255, 255, 255, 1)); }
+ /* stylelint-disable number-max-precision */
+ a { top: 0.123px; }
+ /* stylelint-enable number-max-precision */
+ a { top: 0.123px; }
`,
- message: maxLineLength.messages.expected(80),
+ message: numberMaxPrecision.messages.expected('0.123', '0.12'),
},
{
code: `
- /* stylelint-disable-next-line max-line-length */
- .abracadabracadabra { background: linear-gradient(to top, rgba(255, 255, 255, 0.1), rgba (255, 255, 255, 1)); }
- .abracadabracadabra { background: linear-gradient(to top, rgba(255, 255, 255, 0.1), rgba (255, 255, 255, 1)); }
+ /* stylelint-disable-next-line number-max-precision */
+ a { top: 0.123px; }
+ a { top: 0.123px; }
`,
- message: maxLineLength.messages.expected(80),
+ message: numberMaxPrecision.messages.expected('0.123', '0.12'),
},
],
});
testRule({
- ruleName: stringQuotes.ruleName,
- config: ['single'],
+ ruleName: stringNoNewline.ruleName,
+ config: true,
accept: [
{
code: `
/* stylelint-disable */
- .foo { content: "horse"; }
+ .foo { content: "horse \n"; }
/* stylelint-enable */
`,
},
{
code: `
- /* stylelint-disable string-quotes */
- .foo { content: "horse"; }
- /* stylelint-enable string-quotes */
+ /* stylelint-disable string-no-newline */
+ .foo { content: "horse \n"; }
+ /* stylelint-enable string-no-newline */
`,
},
],
@@ -308,21 +308,21 @@ testRule({
{
code: `
/* stylelint-disable block-no-empty */
- .foo { content: "horse"; }
+ .foo { content: "horse \n"; }
/* stylelint-enable block-no-empty */
`,
- message: stringQuotes.messages.expected('single'),
+ message: stringNoNewline.messages.rejected,
},
{
code: `
- /* stylelint-disable string-quotes */
- .foo { content: "horse"; }
- /* stylelint-enable string-quotes */
- .foo { content: "horse"; }
+ /* stylelint-disable string-no-newline */
+ .foo { content: "horse \n"; }
+ /* stylelint-enable string-no-newline */
+ .foo { content: "horse \n"; }
`,
- message: stringQuotes.messages.expected('single'),
+ message: stringNoNewline.messages.rejected,
},
],
});
diff --git a/lib/__tests__/extends.test.mjs b/lib/__tests__/extends.test.mjs
index 8a57823769..f471bc1025 100644
--- a/lib/__tests__/extends.test.mjs
+++ b/lib/__tests__/extends.test.mjs
@@ -77,10 +77,10 @@ it('extending configuration and no configBasedir', () => {
it('extending a config that is overridden', async () => {
const linted = await standalone({
- code: 'a { b: "c" }',
+ code: 'a { top: 0px; }',
config: {
- extends: [`${fixturesPath}/config-string-quotes-single`],
- rules: { 'string-quotes': 'double' },
+ extends: [`${fixturesPath}/config-length-zero-no-unit-true`],
+ rules: { 'length-zero-no-unit': false },
},
});
@@ -92,9 +92,9 @@ describe('extending a config from process.cwd', () => {
it('works', async () => {
const linted = await standalone({
- code: 'a { b: "c" }',
+ code: 'a { top: 0px; }',
config: {
- extends: ['./fixtures/config-string-quotes-single'],
+ extends: ['./fixtures/config-length-zero-no-unit-true'],
},
});
@@ -105,9 +105,9 @@ describe('extending a config from process.cwd', () => {
describe('extending a config from options.cwd', () => {
it('works', async () => {
const linted = await standalone({
- code: 'a { b: "c" }',
+ code: 'a { top: 0px; }',
config: {
- extends: ['./fixtures/config-string-quotes-single'],
+ extends: ['./fixtures/config-length-zero-no-unit-true'],
},
cwd: fileURLToPath(new URL('.', import.meta.url)),
});
diff --git a/lib/__tests__/fixtures/config-length-zero-no-unit-true.json b/lib/__tests__/fixtures/config-length-zero-no-unit-true.json
new file mode 100644
index 0000000000..95574487ec
--- /dev/null
+++ b/lib/__tests__/fixtures/config-length-zero-no-unit-true.json
@@ -0,0 +1,5 @@
+{
+ "rules": {
+ "length-zero-no-unit": true
+ }
+}
diff --git a/lib/__tests__/fixtures/config-overrides/indent4.json b/lib/__tests__/fixtures/config-overrides/indent4.json
deleted file mode 100644
index 9c99262695..0000000000
--- a/lib/__tests__/fixtures/config-overrides/indent4.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "rules": {
- "indentation": 4
- }
-}
diff --git a/lib/__tests__/fixtures/config-overrides/indent8.json b/lib/__tests__/fixtures/config-overrides/indent8.json
deleted file mode 100644
index 9f42107a1f..0000000000
--- a/lib/__tests__/fixtures/config-overrides/indent8.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "rules": {
- "indentation": 8
- }
-}
diff --git a/lib/__tests__/fixtures/config-overrides/number-max-precision-4.json b/lib/__tests__/fixtures/config-overrides/number-max-precision-4.json
new file mode 100644
index 0000000000..0d417f6da1
--- /dev/null
+++ b/lib/__tests__/fixtures/config-overrides/number-max-precision-4.json
@@ -0,0 +1,5 @@
+{
+ "rules": {
+ "number-max-precision": 4
+ }
+}
diff --git a/lib/__tests__/fixtures/config-overrides/number-max-precision-8.json b/lib/__tests__/fixtures/config-overrides/number-max-precision-8.json
new file mode 100644
index 0000000000..d68b33e7e7
--- /dev/null
+++ b/lib/__tests__/fixtures/config-overrides/number-max-precision-8.json
@@ -0,0 +1,5 @@
+{
+ "rules": {
+ "number-max-precision": 8
+ }
+}
diff --git a/lib/__tests__/fixtures/config-overrides/precision.css b/lib/__tests__/fixtures/config-overrides/precision.css
new file mode 100644
index 0000000000..adccacdbd8
--- /dev/null
+++ b/lib/__tests__/fixtures/config-overrides/precision.css
@@ -0,0 +1 @@
+a { top: 0.123456789px; }
diff --git a/lib/__tests__/fixtures/config-string-quotes-single.json b/lib/__tests__/fixtures/config-string-quotes-single.json
deleted file mode 100644
index 68195ea878..0000000000
--- a/lib/__tests__/fixtures/config-string-quotes-single.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "rules": {
- "string-quotes": "single"
- }
-}
diff --git a/lib/__tests__/fixtures/plugin-array.js b/lib/__tests__/fixtures/plugin-array.js
index 3f73cb9d30..17b07c3758 100644
--- a/lib/__tests__/fixtures/plugin-array.js
+++ b/lib/__tests__/fixtures/plugin-array.js
@@ -1,6 +1,6 @@
'use strict';
-const conditionallyCheckColorHexCase = require('./plugin-conditionally-check-color-hex-case');
+const conditionallyCheckColorNamed = require('./plugin-conditionally-check-color-named');
const warnAboutFoo = require('./plugin-warn-about-foo');
-module.exports = [conditionallyCheckColorHexCase, warnAboutFoo];
+module.exports = [conditionallyCheckColorNamed, warnAboutFoo];
diff --git a/lib/__tests__/fixtures/plugin-conditionally-check-color-hex-case.js b/lib/__tests__/fixtures/plugin-conditionally-check-color-hex-case.js
deleted file mode 100644
index 13ac58df39..0000000000
--- a/lib/__tests__/fixtures/plugin-conditionally-check-color-hex-case.js
+++ /dev/null
@@ -1,15 +0,0 @@
-'use strict';
-
-const stylelint = require('../..');
-
-const ruleName = 'plugin/conditionally-check-color-hex-case';
-
-module.exports = stylelint.createPlugin(ruleName, (expectation, options, context) => {
- const colorHexCaseRule = stylelint.rules['color-hex-case'](expectation, options, context);
-
- return (root, result) => {
- if (!root.toString().includes('@@check-color-hex-case')) return;
-
- colorHexCaseRule(root, result);
- };
-});
diff --git a/lib/__tests__/fixtures/plugin-conditionally-check-color-named.js b/lib/__tests__/fixtures/plugin-conditionally-check-color-named.js
new file mode 100644
index 0000000000..86969ac4d0
--- /dev/null
+++ b/lib/__tests__/fixtures/plugin-conditionally-check-color-named.js
@@ -0,0 +1,15 @@
+'use strict';
+
+const stylelint = require('../..');
+
+const ruleName = 'plugin/conditionally-check-color-named';
+
+module.exports = stylelint.createPlugin(ruleName, (expectation, options, context) => {
+ const colorNamedRule = stylelint.rules['color-named'](expectation, options, context);
+
+ return (root, result) => {
+ if (!root.toString().includes('@@check-color-named')) return;
+
+ colorNamedRule(root, result);
+ };
+});
diff --git a/lib/__tests__/integration.test.mjs b/lib/__tests__/integration.test.mjs
index fb414f6cb4..0ec6077380 100644
--- a/lib/__tests__/integration.test.mjs
+++ b/lib/__tests__/integration.test.mjs
@@ -14,7 +14,7 @@ const fixtures = (...elem) =>
const config = {
rules: {
- 'block-opening-brace-newline-after': 'always',
+ 'color-named': 'always-where-possible',
'declaration-property-unit-disallowed-list': {
width: ['px', 'em'],
},
@@ -32,7 +32,9 @@ const config = {
};
const css = stripIndent`
- a { background: pink; }
+ a {
+ color: #000;
+ }
b {
height: 1rem;
@@ -61,16 +63,16 @@ describe('integration test expecting warnings', () => {
});
it('number and type', () => {
- expect(result.messages).toHaveLength(6);
+ expect(result.messages).toHaveLength(5);
expect(result.messages.every((m) => m.type === 'warning')).toBeTruthy();
expect(result.messages.every((m) => m.plugin === 'stylelint')).toBeTruthy();
});
- it('block-opening-brace-newline-after - string primary option', () => {
- const error = result.messages.find((msg) => msg.rule === 'block-opening-brace-newline-after');
+ it('color-named - string primary option', () => {
+ const error = result.messages.find((msg) => msg.rule === 'color-named');
expect(error).toBeTruthy();
- expect(error.text).toBe('Expected newline after "{" (block-opening-brace-newline-after)');
+ expect(error.text).toBe('Expected "#000" to be "black" (color-named)');
expect(error.severity).toBe('error');
});
diff --git a/lib/__tests__/needlessDisables.test.mjs b/lib/__tests__/needlessDisables.test.mjs
index 20858d76eb..67f7ceb73d 100644
--- a/lib/__tests__/needlessDisables.test.mjs
+++ b/lib/__tests__/needlessDisables.test.mjs
@@ -262,7 +262,7 @@ it('needlessDisables ignored case', async () => {
it('needlessDisables true except', async () => {
const config = {
- rules: { 'color-hex-case': true },
+ rules: { 'color-named': 'always-where-possible' },
};
const css = stripIndent`
@@ -276,7 +276,7 @@ it('needlessDisables true except', async () => {
a { color: pink; }
/* stylelint-enable */
a {
- b { color: pink; } /* stylelint-disable-line color-hex-case */
+ b { color: pink; } /* stylelint-disable-line color-named */
}
`;
@@ -310,8 +310,8 @@ it('needlessDisables true except', async () => {
line: 11,
column: 21,
endLine: 11,
- endColumn: 63,
- text: 'Needless disable for "color-hex-case"',
+ endColumn: 60,
+ text: 'Needless disable for "color-named"',
rule: '--report-needless-disables',
severity: 'error',
},
@@ -320,7 +320,7 @@ it('needlessDisables true except', async () => {
it('needlessDisables false except', async () => {
const config = {
- rules: { 'color-hex-case': true },
+ rules: { 'color-named': 'always-where-possible' },
};
const css = stripIndent`
@@ -334,14 +334,14 @@ it('needlessDisables false except', async () => {
a { color: pink; }
/* stylelint-enable */
a {
- b { color: pink; } /* stylelint-disable-line color-hex-case */
+ b { color: pink; } /* stylelint-disable-line color-named */
}
`;
const { results } = await standalone({
config,
code: css,
- reportNeedlessDisables: [false, { except: 'color-hex-case' }],
+ reportNeedlessDisables: [false, { except: 'color-named' }],
});
expect(results).toHaveLength(1);
@@ -350,8 +350,8 @@ it('needlessDisables false except', async () => {
line: 11,
column: 21,
endLine: 11,
- endColumn: 63,
- text: 'Needless disable for "color-hex-case"',
+ endColumn: 60,
+ text: 'Needless disable for "color-named"',
rule: '--report-needless-disables',
severity: 'error',
},
diff --git a/lib/__tests__/overrides.test.mjs b/lib/__tests__/overrides.test.mjs
index 247154c732..bf27234c22 100644
--- a/lib/__tests__/overrides.test.mjs
+++ b/lib/__tests__/overrides.test.mjs
@@ -131,13 +131,13 @@ describe('single input file. all overrides are matching', () => {
it('priority to apply overrides: apply overrides extends', async () => {
const linted = await standalone({
- files: [path.join(fixturesPath, 'style.css')],
+ files: [path.join(fixturesPath, 'precision.css')],
config: {
- extends: [path.join(fixturesPath, 'indent4.json')],
+ extends: [path.join(fixturesPath, 'number-max-precision-4.json')],
overrides: [
{
files: ['*.css'],
- extends: [path.join(fixturesPath, 'indent8.json')],
+ extends: [path.join(fixturesPath, 'number-max-precision-8.json')],
},
],
},
@@ -146,26 +146,26 @@ describe('single input file. all overrides are matching', () => {
expect(linted.results).toHaveLength(1);
expect(linted.results[0].warnings).toHaveLength(1);
- expect(linted.results[0].warnings[0].rule).toBe('indentation');
+ expect(linted.results[0].warnings[0].rule).toBe('number-max-precision');
expect(linted.results[0].warnings[0].text).toBe(
- 'Expected indentation of 8 spaces (indentation)',
+ 'Expected "0.123456789" to be "0.12345679" (number-max-precision)',
);
});
it('priority to apply overrides: apply overrides rules', async () => {
const linted = await standalone({
- files: [path.join(fixturesPath, 'style.css')],
+ files: [path.join(fixturesPath, 'precision.css')],
config: {
- extends: [path.join(fixturesPath, 'indent4.json')],
+ extends: [path.join(fixturesPath, 'number-max-precision-4.json')],
rules: {
- indentation: 3,
+ 'number-max-precision': 1,
},
overrides: [
{
files: ['*.css'],
- extends: [path.join(fixturesPath, 'indent8.json')],
+ extends: [path.join(fixturesPath, 'number-max-precision-8.json')],
rules: {
- indentation: 'tab',
+ 'number-max-precision': 2,
},
},
],
@@ -175,22 +175,24 @@ describe('single input file. all overrides are matching', () => {
expect(linted.results).toHaveLength(1);
expect(linted.results[0].warnings).toHaveLength(1);
- expect(linted.results[0].warnings[0].rule).toBe('indentation');
- expect(linted.results[0].warnings[0].text).toBe('Expected indentation of 1 tab (indentation)');
+ expect(linted.results[0].warnings[0].rule).toBe('number-max-precision');
+ expect(linted.results[0].warnings[0].text).toBe(
+ 'Expected "0.123456789" to be "0.12" (number-max-precision)',
+ );
});
it('priority to apply overrides: apply rules', async () => {
const linted = await standalone({
- files: [path.join(fixturesPath, 'style.css')],
+ files: [path.join(fixturesPath, 'precision.css')],
config: {
- extends: [path.join(fixturesPath, 'indent4.json')],
+ extends: [path.join(fixturesPath, 'number-max-precision-4.json')],
rules: {
- indentation: 'tab',
+ 'number-max-precision': 1,
},
overrides: [
{
files: ['*.css'],
- extends: [path.join(fixturesPath, 'indent8.json')],
+ extends: [path.join(fixturesPath, 'number-max-precision-8.json')],
},
],
},
@@ -199,8 +201,10 @@ describe('single input file. all overrides are matching', () => {
expect(linted.results).toHaveLength(1);
expect(linted.results[0].warnings).toHaveLength(1);
- expect(linted.results[0].warnings[0].rule).toBe('indentation');
- expect(linted.results[0].warnings[0].text).toBe('Expected indentation of 1 tab (indentation)');
+ expect(linted.results[0].warnings[0].rule).toBe('number-max-precision');
+ expect(linted.results[0].warnings[0].text).toBe(
+ 'Expected "0.123456789" to be "0.1" (number-max-precision)',
+ );
});
// https://github.com/stylelint/stylelint/issues/5656
diff --git a/lib/__tests__/plugins.test.mjs b/lib/__tests__/plugins.test.mjs
index ae91ca6c3a..d226f5e6da 100644
--- a/lib/__tests__/plugins.test.mjs
+++ b/lib/__tests__/plugins.test.mjs
@@ -155,65 +155,65 @@ it('plugin with ESM import()', async () => {
});
describe('plugin using exposed rules via stylelint.rules', () => {
- const cssWithDirectiveLower = '/** @@check-color-hex-case */ a { color: #eee; }';
- const cssWithDirectiveUpper = '/** @@check-color-hex-case */ a { color: #EEE; }';
- const cssWithoutDirectiveLower = 'a { color: #eee; }';
- const cssWithoutDirectiveUpper = 'a { color: #EEE; }';
+ const cssWithDirectiveNever = '/** @@check-color-named */ a { color: #000; }';
+ const cssWithDirectiveAlways = '/** @@check-color-named */ a { color: black; }';
+ const cssWithoutDirectiveNever = 'a { color: #000; }';
+ const cssWithoutDirectiveAlways = 'a { color: black; }';
const config = (expectation) => ({
config: {
- plugins: [path.join(__dirname, 'fixtures/plugin-conditionally-check-color-hex-case')],
+ plugins: [path.join(__dirname, 'fixtures/plugin-conditionally-check-color-named')],
rules: {
- 'plugin/conditionally-check-color-hex-case': expectation,
+ 'plugin/conditionally-check-color-named': expectation,
},
},
});
- it('with uppercase expectation and lowercase color', async () => {
+ it('with always expectation and never color', async () => {
const result = await postcss()
- .use(stylelint(config('upper')))
- .process(cssWithDirectiveLower, { from: undefined });
+ .use(stylelint(config('always-where-possible')))
+ .process(cssWithDirectiveNever, { from: undefined });
expect(result.warnings()).toHaveLength(1);
- expect(result.warnings()[0].text).toBe('Expected "#eee" to be "#EEE" (color-hex-case)');
+ expect(result.warnings()[0].text).toBe('Expected "#000" to be "black" (color-named)');
});
- it('with uppercase expectation and uppercase color', async () => {
+ it('with always expectation and always color', async () => {
const result = await postcss()
- .use(stylelint(config('upper')))
- .process(cssWithDirectiveUpper, { from: undefined });
+ .use(stylelint(config('always-where-possible')))
+ .process(cssWithDirectiveAlways, { from: undefined });
expect(result.warnings()).toHaveLength(0);
});
- it('with lowercase expectation and uppercase color', async () => {
+ it('with never expectation and always color', async () => {
const result = await postcss()
- .use(stylelint(config('lower')))
- .process(cssWithDirectiveUpper, { from: undefined });
+ .use(stylelint(config('never')))
+ .process(cssWithDirectiveAlways, { from: undefined });
expect(result.warnings()).toHaveLength(1);
- expect(result.warnings()[0].text).toBe('Expected "#EEE" to be "#eee" (color-hex-case)');
+ expect(result.warnings()[0].text).toBe('Unexpected named color "black" (color-named)');
});
- it('with lowercase expectation and lowercase color', async () => {
+ it('with never expectation and never color', async () => {
const result = await postcss()
- .use(stylelint(config('lower')))
- .process(cssWithDirectiveLower, { from: undefined });
+ .use(stylelint(config('never')))
+ .process(cssWithDirectiveNever, { from: undefined });
expect(result.warnings()).toHaveLength(0);
});
- it('with uppercase expectation and lowercase color without directive', async () => {
+ it('with always expectation and never color without directive', async () => {
const result = await postcss()
- .use(stylelint(config('upper')))
- .process(cssWithoutDirectiveLower, { from: undefined });
+ .use(stylelint(config('always-where-possible')))
+ .process(cssWithoutDirectiveNever, { from: undefined });
expect(result.warnings()).toHaveLength(0);
});
- it('with uppercase expectation and uppercase color without directive', async () => {
+ it('with always expectation and always color without directive', async () => {
const result = await postcss()
- .use(stylelint(config('lower')))
- .process(cssWithoutDirectiveUpper, { from: undefined });
+ .use(stylelint(config('never')))
+ .process(cssWithoutDirectiveAlways, { from: undefined });
expect(result.warnings()).toHaveLength(0);
});
@@ -223,7 +223,7 @@ describe('module providing an array of plugins', () => {
const config = {
plugins: [path.join(__dirname, 'fixtures/plugin-array')],
rules: {
- 'plugin/conditionally-check-color-hex-case': 'upper',
+ 'plugin/conditionally-check-color-named': 'always-where-possible',
'plugin/warn-about-foo': 'always',
},
};
@@ -231,10 +231,10 @@ describe('module providing an array of plugins', () => {
it('first plugin works', async () => {
const result = await postcss()
.use(stylelint(config))
- .process('@@check-color-hex-case a { color: #eee; }', { from: undefined });
+ .process('@@check-color-named a { color: #000; }', { from: undefined });
expect(result.warnings()).toHaveLength(1);
- expect(result.warnings()[0].text).toBe('Expected "#eee" to be "#EEE" (color-hex-case)');
+ expect(result.warnings()[0].text).toBe('Expected "#000" to be "black" (color-named)');
});
it('second plugin works', async () => {
diff --git a/lib/__tests__/reportUnknownRuleNames.test.mjs b/lib/__tests__/reportUnknownRuleNames.test.mjs
index 64255dbb60..a3784592a0 100644
--- a/lib/__tests__/reportUnknownRuleNames.test.mjs
+++ b/lib/__tests__/reportUnknownRuleNames.test.mjs
@@ -3,7 +3,7 @@ import standalone from '../standalone.js';
it('test case (1)', async () => {
const config = {
rules: {
- 'color-hex-cas': ['upper'],
+ 'color-namd': ['always-where-possible'],
'function-allowed-lst': ['scale'],
},
};
@@ -21,8 +21,8 @@ it('test case (1)', async () => {
endLine: 1,
endColumn: 6,
severity: 'error',
- rule: 'color-hex-cas',
- text: 'Unknown rule color-hex-cas. Did you mean color-hex-case?',
+ rule: 'color-namd',
+ text: 'Unknown rule color-namd. Did you mean color-named?',
});
expect(results[0].warnings).toContainEqual({
line: 1,
@@ -38,7 +38,7 @@ it('test case (1)', async () => {
it('test case (2)', async () => {
const config = {
rules: {
- 'color-hex-case': ['upper'],
+ 'color-named': ['always-where-possible'],
'function-allowed-lst': ['rgb'],
},
};
@@ -62,7 +62,7 @@ it('test case (2)', async () => {
expect(results[0].warnings).toContainEqual(
expect.objectContaining({
severity: 'error',
- rule: 'color-hex-case',
+ rule: 'color-named',
}),
);
});
diff --git a/lib/__tests__/standalone-fix.test.mjs b/lib/__tests__/standalone-fix.test.mjs
index 8ec2071d2c..76ca3cf8fd 100644
--- a/lib/__tests__/standalone-fix.test.mjs
+++ b/lib/__tests__/standalone-fix.test.mjs
@@ -2,8 +2,6 @@ import { copyFile, readFile, rm } from 'fs/promises';
import { fileURLToPath } from 'node:url';
import path from 'node:path';
-import { stripIndent, stripIndents } from 'common-tags';
-
import replaceBackslashes from '../testUtils/replaceBackslashes.mjs';
import safeChdir from '../testUtils/safeChdir.mjs';
import standalone from '../standalone.js';
@@ -14,16 +12,16 @@ const fixturesPath = (...elems) =>
it('outputs fixed code when input is code string', async () => {
const result = await standalone({
- code: ' a { color: red; }',
+ code: 'a { color: #ffffff; }',
config: {
rules: {
- indentation: 2,
+ 'color-hex-length': 'short',
},
},
fix: true,
});
- expect(result.output).toBe('a { color: red; }');
+ expect(result.output).toBe('a { color: #fff; }');
});
it('fixes when enabled in config', async () => {
@@ -39,35 +37,16 @@ it('fixes when enabled in config', async () => {
expect(output).toBe('a { color: #fff; }');
});
-it('apply indentation autofix at last', async () => {
- const result = await standalone({
- code: 'a {\nbox-shadow: 0 -1px 0 0 rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(0, 0, 0, 0.2), inset 0 1px 2px 0 rgba(0, 0, 0, 0.1);\n}',
- config: {
- rules: {
- indentation: 2,
- 'value-list-comma-newline-after': 'always',
- },
- },
- fix: true,
- });
-
- expect(result.output).toBe(
- 'a {\n box-shadow: 0 -1px 0 0 rgba(0, 0, 0, 0.1),\n 0 0 0 1px rgba(0, 0, 0, 0.2),\n inset 0 1px 2px 0 rgba(0, 0, 0, 0.1);\n}',
- );
-});
-
it("doesn't fix with stylelint-disable commands", async () => {
const code = `
/* stylelint-disable */
- a {
- color: red;
- }`;
+ a { color: #ffffff; }`;
const result = await standalone({
code,
config: {
rules: {
- indentation: 2,
+ 'color-hex-length': 'short',
},
},
fix: true,
@@ -78,16 +57,14 @@ it("doesn't fix with stylelint-disable commands", async () => {
it("doesn't fix with scoped stylelint-disable commands", async () => {
const code = `
- /* stylelint-disable indentation */
- a {
- color: red;
- }`;
+ /* stylelint-disable color-hex-length */
+ a { color: #ffffff; }`;
const result = await standalone({
code,
config: {
rules: {
- indentation: 2,
+ 'color-hex-length': 'short',
},
},
fix: true,
@@ -98,17 +75,18 @@ it("doesn't fix with scoped stylelint-disable commands", async () => {
it("doesn't fix with multiple scoped stylelint-disable commands", async () => {
const code = `
- /* stylelint-disable indentation, color-hex-length */
+ /* stylelint-disable declaration-block-no-duplicate-properties, color-hex-length */
a {
color: #ffffff;
+ color: orange;
}`;
const result = await standalone({
code,
config: {
rules: {
- indentation: 2,
'color-hex-length': 'short',
+ 'declaration-block-no-duplicate-properties': true,
},
},
fix: true,
@@ -117,50 +95,21 @@ it("doesn't fix with multiple scoped stylelint-disable commands", async () => {
expect(result.output).toBe(code);
});
-it("the color-hex-length rule doesn't fix with scoped stylelint-disable commands", async () => {
- const result = await standalone({
- code: stripIndent`
- /* stylelint-disable color-hex-length */
- a {
- color: #ffffff;
- }`,
- config: {
- rules: {
- indentation: 2,
- 'color-hex-length': 'short',
- },
- },
- fix: true,
- });
-
- expect(result.output).toBe(stripIndent`
- /* stylelint-disable color-hex-length */
- a {
- color: #ffffff;
- }`);
-});
-
-it("the indentation rule doesn't fix with scoped stylelint-disable commands", async () => {
+it("doesn't fix with a scoped stylelint-disable command, but does fix other rules", async () => {
const result = await standalone({
- code: stripIndent`
- /* stylelint-disable indentation */
- a {
- color: #ffffff;
- }`,
+ code: '/* stylelint-disable declaration-block-no-duplicate-properties */ a { color: #ffffff; color: orange; }',
config: {
rules: {
- indentation: 2,
'color-hex-length': 'short',
+ 'declaration-block-no-duplicate-properties': true,
},
},
fix: true,
});
- expect(result.output).toBe(stripIndent`
- /* stylelint-disable indentation */
- a {
- color: #fff;
- }`);
+ expect(result.output).toBe(
+ '/* stylelint-disable declaration-block-no-duplicate-properties */ a { color: #fff; color: orange; }',
+ );
});
describe('writing fixes to files', () => {
@@ -241,15 +190,15 @@ describe('writing fixes to files', () => {
it('one rule being disabled', async () => {
const code = `
a {
- color: red;
+ color: #ffffff;
}`;
const result = await standalone({
code,
config: {
rules: {
- indentation: [
- 2,
+ 'color-hex-length': [
+ 'short',
{
disableFix: true,
},
@@ -265,22 +214,22 @@ it('one rule being disabled', async () => {
it('two rules being disabled', async () => {
const code = `
- a {
- COLOR: red;
+ a, a {
+ color: #ffffff;
}`;
const result = await standalone({
code,
config: {
rules: {
- indentation: [
- 2,
+ 'color-hex-length': [
+ 'short',
{
disableFix: true,
},
],
- 'property-case': [
- 'lower',
+ 'no-duplicate-selectors': [
+ true,
{
disableFix: true,
},
@@ -292,29 +241,32 @@ it('two rules being disabled', async () => {
const warnings = result.results[0].warnings;
- expect(warnings.some((w) => w.text === 'Expected indentation of 0 spaces (indentation)')).toBe(
- true,
- );
- expect(warnings.some((w) => w.text === 'Expected "COLOR" to be "color" (property-case)')).toBe(
- true,
- );
+ expect(
+ warnings.some((w) => w.text === 'Expected "#ffffff" to be "#fff" (color-hex-length)'),
+ ).toBe(true);
+ expect(
+ warnings.some(
+ (w) =>
+ w.text ===
+ 'Unexpected duplicate selector "a", first used at line 2 (no-duplicate-selectors)',
+ ),
+ ).toBe(true);
expect(result.output).toBe(code);
});
it('one rule being disabled and another still autofixing', async () => {
- // use stripIndent to remove first linebreak that is also removed in the stripIndents expect
- const code = stripIndent`
- a {
- COLOR: red;
+ const code = `
+ a, a {
+ color: #ffffff;
}`;
const result = await standalone({
code,
config: {
rules: {
- indentation: [0],
- 'property-case': [
- 'lower',
+ 'color-hex-length': ['short'],
+ 'no-duplicate-selectors': [
+ true,
{
disableFix: true,
},
@@ -326,11 +278,19 @@ it('one rule being disabled and another still autofixing', async () => {
const warnings = result.results[0].warnings;
- expect(warnings.some((w) => w.text === 'Expected indentation of 0 spaces (indentation)')).toBe(
- false,
- );
- expect(warnings.some((w) => w.text === 'Expected "COLOR" to be "color" (property-case)')).toBe(
- true,
- );
- expect(result.output).toBe(stripIndents(code));
+ expect(
+ warnings.some((w) => w.text === 'Expected "#ffffff" to be "#fff" (color-hex-length)'),
+ ).toBe(false);
+ expect(
+ warnings.some(
+ (w) =>
+ w.text ===
+ 'Unexpected duplicate selector "a", first used at line 2 (no-duplicate-selectors)',
+ ),
+ ).toBe(true);
+
+ expect(result.output).toBe(`
+ a, a {
+ color: #fff;
+ }`);
});
diff --git a/lib/__tests__/standalone-quiet-deprecation-warnings.test.mjs b/lib/__tests__/standalone-quiet-deprecation-warnings.test.mjs
index 07e0e77e1a..760a08ef29 100644
--- a/lib/__tests__/standalone-quiet-deprecation-warnings.test.mjs
+++ b/lib/__tests__/standalone-quiet-deprecation-warnings.test.mjs
@@ -1,9 +1,30 @@
+import { createRequire } from 'node:module';
+import { jest } from '@jest/globals';
+import report from '../utils/report.js';
import standalone from '../standalone.js';
+jest.mock('../rules/block-no-empty');
+
+const require = createRequire(import.meta.url);
+const deprecatedRule = require('../rules/block-no-empty/index.js');
+
+deprecatedRule.mockImplementation(() => {
+ return (root, result) => {
+ report({
+ ruleName: 'block-no-empty',
+ message: 'Foo bar',
+ node: root,
+ result,
+ });
+ };
+});
+
+deprecatedRule.meta = { deprecated: true };
+
it('standalone does not silence deprecation warnings by default', async () => {
const config = {
rules: {
- 'color-hex-case': 'lower',
+ 'block-no-empty': true,
},
};
@@ -16,7 +37,7 @@ it('standalone does not silence deprecation warnings by default', async () => {
it('standalone silences deprecation warnings when passed --quiet-deprecation-warnings', async () => {
const config = {
rules: {
- 'color-hex-case': 'lower',
+ 'block-no-empty': true,
},
};
diff --git a/lib/rules/__tests__/index.test.mjs b/lib/rules/__tests__/index.test.mjs
index 9af63d30d1..ca3e4458d8 100644
--- a/lib/rules/__tests__/index.test.mjs
+++ b/lib/rules/__tests__/index.test.mjs
@@ -46,7 +46,8 @@ describe('fixable rules', () => {
});
});
-describe('deprecated rules', () => {
+// eslint-disable-next-line jest/no-disabled-tests --- Leaving for future cases of deprecated rules.
+describe.skip('deprecated rules', () => {
const deprecatedRules = ruleEntries.filter(([, rule]) => rule.meta.deprecated);
test.each(deprecatedRules)('"%s" should describe deprecation in the rules doc', async (name) => {
diff --git a/lib/rules/at-rule-empty-line-before/README.md b/lib/rules/at-rule-empty-line-before/README.md
index be564caf6a..ab06ed8e37 100644
--- a/lib/rules/at-rule-empty-line-before/README.md
+++ b/lib/rules/at-rule-empty-line-before/README.md
@@ -16,7 +16,7 @@ This rule ignores:
- at-rules that are the very first node in the source
- `@import` in Less.
-The [`fix` option](../../../docs/user-guide/options.md#fix) can automatically fix all of the problems reported by this rule. We recommend to enable [`indentation`](../indentation/README.md) rule for better autofixing results with this rule.
+The [`fix` option](../../../docs/user-guide/options.md#fix) can automatically fix all of the problems reported by this rule.
## Options
diff --git a/lib/rules/at-rule-name-case/README.md b/lib/rules/at-rule-name-case/README.md
deleted file mode 100644
index ceeaf64d45..0000000000
--- a/lib/rules/at-rule-name-case/README.md
+++ /dev/null
@@ -1,112 +0,0 @@
-# at-rule-name-case
-
-> **Warning** This rule is deprecated and will be removed in the future. See [the migration guide](../../../docs/migration-guide/to-15.md).
-
-Specify lowercase or uppercase for at-rules names.
-
-
-```css
- @media (min-width: 10px) {}
-/** ↑
- * This at-rule name */
-```
-
-Only lowercase at-rule names are valid in SCSS.
-
-The [`fix` option](../../../docs/user-guide/options.md#fix) can automatically fix some of the problems reported by this rule.
-
-## Options
-
-`string`: `"lower"|"upper"`
-
-### `"lower"`
-
-The following patterns are considered problems:
-
-
-```css
-@Charset 'UTF-8';
-```
-
-
-```css
-@cHarSeT 'UTF-8';
-```
-
-
-```css
-@CHARSET 'UTF-8';
-```
-
-
-```css
-@Media (min-width: 50em) {}
-```
-
-
-```css
-@mEdIa (min-width: 50em) {}
-```
-
-
-```css
-@MEDIA (min-width: 50em) {}
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-@charset 'UTF-8';
-```
-
-
-```css
-@media (min-width: 50em) {}
-```
-
-### `"upper"`
-
-The following patterns are considered problems:
-
-
-```css
-@Charset 'UTF-8';
-```
-
-
-```css
-@cHarSeT 'UTF-8';
-```
-
-
-```css
-@charset 'UTF-8';
-```
-
-
-```css
-@Media (min-width: 50em) {}
-```
-
-
-```css
-@mEdIa (min-width: 50em) {}
-```
-
-
-```css
-@media (min-width: 50em) {}
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-@CHARSET 'UTF-8';
-```
-
-
-```css
-@MEDIA (min-width: 50em) {}
-```
diff --git a/lib/rules/at-rule-name-case/__tests__/index.js b/lib/rules/at-rule-name-case/__tests__/index.js
deleted file mode 100644
index a6747c62dd..0000000000
--- a/lib/rules/at-rule-name-case/__tests__/index.js
+++ /dev/null
@@ -1,295 +0,0 @@
-'use strict';
-
-const { messages, ruleName } = require('..');
-
-testRule({
- ruleName,
- config: ['lower'],
- fix: true,
-
- accept: [
- {
- code: "@charset 'UTF-8';",
- },
- {
- code: "@import 'test.css'",
- },
- {
- code: '@namespace url(XML-namespace-URL);',
- },
- {
- code: '@media screen {}',
- },
- {
- code: '@media (min-width: 50em) {}',
- },
- {
- code: '@media only screen and (min-width: 415px) { @keyframes pace-anim { 100% { opacity: 0; } } }',
- },
- {
- code: '@supports (animation-name: test) {}',
- },
- {
- code: "@document url(http://www.w3.org/), url-prefix(http://www.w3.org/Style/), domain(mozilla.org), regexp('https:.*')",
- },
- {
- code: '@page :first { margin: 1cm; }',
- },
- {
- code: '@keyframes { 0% { top: 0; } }',
- },
- {
- code: '@-webkit-keyframes { 0% { top: 0; } }',
- },
- {
- code: '@viewport { orientation: landscape; }',
- },
- {
- code: "@counter-style win-list { system: fixed; symbols: url(gold-medal.svg) url(silver-medal.svg) ; suffix: ' ';}",
- },
- {
- code: '@font-feature-values Font One { @styleset { nice-style: 12; } }',
- },
- ],
-
- reject: [
- {
- code: "@Charset 'UTF-8';",
- fixed: "@charset 'UTF-8';",
- message: messages.expected('Charset', 'charset'),
- line: 1,
- column: 1,
- },
- {
- code: "@cHaRsEt 'UTF-8';",
- fixed: "@charset 'UTF-8';",
- message: messages.expected('cHaRsEt', 'charset'),
- line: 1,
- column: 1,
- },
- {
- code: "@CHARSET 'UTF-8';",
- fixed: "@charset 'UTF-8';",
- message: messages.expected('CHARSET', 'charset'),
- line: 1,
- column: 1,
- },
- {
- code: '@Media screen {}',
- fixed: '@media screen {}',
- message: messages.expected('Media', 'media'),
- line: 1,
- column: 1,
- },
- {
- code: '@mEdIa screen {}',
- fixed: '@media screen {}',
- message: messages.expected('mEdIa', 'media'),
- line: 1,
- column: 1,
- },
- {
- code: '@MEDIA screen {}',
- fixed: '@media screen {}',
- message: messages.expected('MEDIA', 'media'),
- line: 1,
- column: 1,
- },
- {
- code: '@media only screen and (min-width: 415px) { @Keyframes pace-anim { 100% { opacity: 0; } } }',
- fixed:
- '@media only screen and (min-width: 415px) { @keyframes pace-anim { 100% { opacity: 0; } } }',
- message: messages.expected('Keyframes', 'keyframes'),
- line: 1,
- column: 45,
- },
- {
- code: '@media only screen and (min-width: 415px) { @kEyFrAmEs pace-anim { 100% { opacity: 0; } } }',
- fixed:
- '@media only screen and (min-width: 415px) { @keyframes pace-anim { 100% { opacity: 0; } } }',
- message: messages.expected('kEyFrAmEs', 'keyframes'),
- line: 1,
- column: 45,
- },
- {
- code: '@media only screen and (min-width: 415px) { @KEYFRAMES pace-anim { 100% { opacity: 0; } } }',
- fixed:
- '@media only screen and (min-width: 415px) { @keyframes pace-anim { 100% { opacity: 0; } } }',
- message: messages.expected('KEYFRAMES', 'keyframes'),
- line: 1,
- column: 45,
- },
- {
- code: '@-WEBKIT-keyframes { 0% { top: 0; } }',
- fixed: '@-webkit-keyframes { 0% { top: 0; } }',
- message: messages.expected('-WEBKIT-keyframes', '-webkit-keyframes'),
- line: 1,
- column: 1,
- },
- {
- code: '@-WEBKIT-KEYFRAMES { 0% { top: 0; } }',
- fixed: '@-webkit-keyframes { 0% { top: 0; } }',
- message: messages.expected('-WEBKIT-KEYFRAMES', '-webkit-keyframes'),
- line: 1,
- column: 1,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['upper'],
- fix: true,
-
- accept: [
- {
- code: "@CHARSET 'UTF-8';",
- },
- {
- code: "@IMPORT 'test.css'",
- },
- {
- code: '@NAMESPACE url(XML-namespace-URL);',
- },
- {
- code: '@MEDIA screen {}',
- },
- {
- code: '@MEDIA (min-width: 50em) {}',
- },
- {
- code: '@MEDIA only screen and (min-width: 415px) { @KEYFRAMES pace-anim { 100% { opacity: 0; } } }',
- },
- {
- code: '@SUPPORTS (animation-name: test) {}',
- },
- {
- code: "@DOCUMENT url(http://www.w3.org/), url-prefix(http://www.w3.org/Style/), domain(mozilla.org), regexp('https:.*')",
- },
- {
- code: '@PAGE :first { margin: 1cm; }',
- },
- {
- code: '@KEYFRAMES { 0% { top: 0; } }',
- },
- {
- code: '@-WEBKIT-KEYFRAMES { 0% { top: 0; } }',
- },
- {
- code: '@VIEWPORT { orientation: landscape; }',
- },
- {
- code: "@COUNTER-STYLE win-list { system: fixed; symbols: url(gold-medal.svg) url(silver-medal.svg) ; suffix: ' ';}",
- },
- {
- code: '@FONT-FEATURE-VALUES Font One { @STYLESET { nice-style: 12; } }',
- },
- ],
-
- reject: [
- {
- code: "@Charset 'UTF-8';",
- fixed: "@CHARSET 'UTF-8';",
- message: messages.expected('Charset', 'CHARSET'),
- line: 1,
- column: 1,
- },
- {
- code: "@cHaRsEt 'UTF-8';",
- fixed: "@CHARSET 'UTF-8';",
- message: messages.expected('cHaRsEt', 'CHARSET'),
- line: 1,
- column: 1,
- },
- {
- code: "@charset 'UTF-8';",
- fixed: "@CHARSET 'UTF-8';",
- message: messages.expected('charset', 'CHARSET'),
- line: 1,
- column: 1,
- },
- {
- code: '@Media screen {}',
- fixed: '@MEDIA screen {}',
- message: messages.expected('Media', 'MEDIA'),
- line: 1,
- column: 1,
- },
- {
- code: '@mEdIa screen {}',
- fixed: '@MEDIA screen {}',
- message: messages.expected('mEdIa', 'MEDIA'),
- line: 1,
- column: 1,
- },
- {
- code: '@media screen {}',
- fixed: '@MEDIA screen {}',
- message: messages.expected('media', 'MEDIA'),
- line: 1,
- column: 1,
- },
- {
- code: '@MEDIA only screen and (min-width: 415px) { @Keyframes pace-anim { 100% { opacity: 0; } } }',
- fixed:
- '@MEDIA only screen and (min-width: 415px) { @KEYFRAMES pace-anim { 100% { opacity: 0; } } }',
- message: messages.expected('Keyframes', 'KEYFRAMES'),
- line: 1,
- column: 45,
- },
- {
- code: '@MEDIA only screen and (min-width: 415px) { @kEyFrAmEs pace-anim { 100% { opacity: 0; } } }',
- fixed:
- '@MEDIA only screen and (min-width: 415px) { @KEYFRAMES pace-anim { 100% { opacity: 0; } } }',
- message: messages.expected('kEyFrAmEs', 'KEYFRAMES'),
- line: 1,
- column: 45,
- },
- {
- code: '@MEDIA only screen and (min-width: 415px) { @keyframes pace-anim { 100% { opacity: 0; } } }',
- fixed:
- '@MEDIA only screen and (min-width: 415px) { @KEYFRAMES pace-anim { 100% { opacity: 0; } } }',
- message: messages.expected('keyframes', 'KEYFRAMES'),
- line: 1,
- column: 45,
- },
- {
- code: '@-webkit-KEYFRAMES { 0% { top: 0; } }',
- fixed: '@-WEBKIT-KEYFRAMES { 0% { top: 0; } }',
- message: messages.expected('-webkit-KEYFRAMES', '-WEBKIT-KEYFRAMES'),
- line: 1,
- column: 1,
- },
- {
- code: '@-webkit-keyframes { 0% { top: 0; } }',
- fixed: '@-WEBKIT-KEYFRAMES { 0% { top: 0; } }',
- message: messages.expected('-webkit-keyframes', '-WEBKIT-KEYFRAMES'),
- line: 1,
- column: 1,
- },
- ],
-});
-
-testRule({
- ruleName,
- customSyntax: 'postcss-less',
- config: ['lower'],
-
- accept: [
- {
- code: `
- .someMixin() { margin: 0; }
-
- span { .someMixin(); }
- `,
- description: 'ignore Less mixin',
- },
- {
- code: `
- @myVariable: #f7f8f9;
- span { background-color: @myVariable; }
- `,
- description: 'ignore Less variable',
- },
- ],
-});
diff --git a/lib/rules/at-rule-name-case/index.js b/lib/rules/at-rule-name-case/index.js
deleted file mode 100644
index fd73f46518..0000000000
--- a/lib/rules/at-rule-name-case/index.js
+++ /dev/null
@@ -1,67 +0,0 @@
-'use strict';
-
-const isStandardSyntaxAtRule = require('../../utils/isStandardSyntaxAtRule');
-const report = require('../../utils/report');
-const ruleMessages = require('../../utils/ruleMessages');
-const validateOptions = require('../../utils/validateOptions');
-
-const ruleName = 'at-rule-name-case';
-
-const messages = ruleMessages(ruleName, {
- expected: (actual, expected) => `Expected "${actual}" to be "${expected}"`,
-});
-
-const meta = {
- url: 'https://stylelint.io/user-guide/rules/at-rule-name-case',
- fixable: true,
- deprecated: true,
-};
-
-/** @type {import('stylelint').Rule} */
-const rule = (primary, _secondary, context) => {
- return (root, result) => {
- const validOptions = validateOptions(result, ruleName, {
- actual: primary,
- possible: ['lower', 'upper'],
- });
-
- if (!validOptions) {
- return;
- }
-
- /** @type {'lower' | 'upper'} */
- const expectation = primary;
-
- root.walkAtRules((atRule) => {
- if (!isStandardSyntaxAtRule(atRule)) {
- return;
- }
-
- const name = atRule.name;
-
- const expectedName = expectation === 'lower' ? name.toLowerCase() : name.toUpperCase();
-
- if (name === expectedName) {
- return;
- }
-
- if (context.fix) {
- atRule.name = expectedName;
-
- return;
- }
-
- report({
- message: messages.expected(name, expectedName),
- node: atRule,
- ruleName,
- result,
- });
- });
- };
-};
-
-rule.ruleName = ruleName;
-rule.messages = messages;
-rule.meta = meta;
-module.exports = rule;
diff --git a/lib/rules/at-rule-name-newline-after/README.md b/lib/rules/at-rule-name-newline-after/README.md
deleted file mode 100644
index a9bfe63e2a..0000000000
--- a/lib/rules/at-rule-name-newline-after/README.md
+++ /dev/null
@@ -1,110 +0,0 @@
-# at-rule-name-newline-after
-
-> **Warning** This rule is deprecated and will be removed in the future. See [the migration guide](../../../docs/migration-guide/to-15.md).
-
-Require a newline after at-rule names.
-
-
-```css
- @media
- /*↑*/ (max-width: 600px) {}
-/** ↑
- * The newline after this at-rule name */
-```
-
-## Options
-
-`string`: `"always"|"always-multi-line"`
-
-### `"always"`
-
-There _must always_ be a newline after at-rule names.
-
-The following patterns are considered problems:
-
-
-```css
-@charset "UTF-8";
-```
-
-
-```css
-@media (min-width: 700px) and
- (orientation: landscape) {}
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-@charset
- "UTF-8";
-```
-
-
-```css
-@import
- "x.css" screen and
- (orientation:landscape);
-```
-
-
-```css
-@media
- (min-width: 700px) and (orientation: landscape) {}
-```
-
-
-```css
-@media
- (min-width: 700px) and
- (orientation: landscape) {}
-```
-
-### `"always-multi-line"`
-
-There _must always_ be a newline after at-rule names in at-rules with multi-line parameters.
-
-The following patterns are considered problems:
-
-
-```css
-@import "x.css" screen and
- (orientation:landscape);
-```
-
-
-```css
-@media (min-width: 700px) and
- (orientation: landscape) {}
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-@charset "UTF-8";
-```
-
-
-```css
-@charset
- "UTF-8";
-```
-
-
-```css
-@import "x.css" screen and (orientation:landscape);
-```
-
-
-```css
-@media (min-width: 700px) and (orientation: landscape) {}
-```
-
-
-```css
-@media
- (min-width: 700px) and
- (orientation: landscape) {}
-```
diff --git a/lib/rules/at-rule-name-newline-after/__tests__/index.js b/lib/rules/at-rule-name-newline-after/__tests__/index.js
deleted file mode 100644
index 4d6366b858..0000000000
--- a/lib/rules/at-rule-name-newline-after/__tests__/index.js
+++ /dev/null
@@ -1,397 +0,0 @@
-'use strict';
-
-const { messages, ruleName } = require('..');
-
-testRule({
- ruleName,
- config: ['always'],
-
- accept: [
- {
- code: '@charset\n"UTF-8";',
- },
- {
- code: '@charset\r\n"UTF-8";',
- },
- {
- code: '@import\n"x.css";',
- },
- {
- code: '@import\n"x.css" screen and (orientation:landscape);',
- },
- {
- code: '@import\nurl("x.css");',
- },
- {
- code: '@import\nurl("x.css") screen and (orientation:landscape);',
- },
- {
- code: '@namespace\nurl(XML-namespace-URL);',
- },
- {
- code: '@media\n(min-width: 700px) and (orientation: landscape) { }',
- },
- {
- code: '@media\n(min-width: 700px)\nand (orientation: landscape) { }',
- },
- {
- code: '@media\r\n(min-width: 700px)\r\nand (orientation: landscape) { }',
- },
- {
- code: '@media\n(min-width: 700px) and\n(orientation: landscape) { }',
- },
- {
- code: '@media\n(min-width: 700px) and (orientation: landscape) { }',
- },
- {
- code: '@media\n(min-width: 700px) and (orientation: landscape)\n{ }',
- },
- {
- code: '@media\n(min-width: 700px) and (orientation: landscape)\r\n{ }',
- },
- {
- code: '@media\n(min-width: 700px) and (orientation: landscape) { }',
- },
- {
- code: '@media\n(min-width: 700px)\nand (orientation: landscape) { }',
- },
- {
- code: '@media\n(min-width: 700px)\r\nand (orientation: landscape) { }',
- },
- {
- code: '@supports\n(animation-name: test) { }',
- },
- {
- code: '@keyframes\nidentifier { }',
- },
- {
- code: '@-webkit-keyframes\nidentifier { }',
- },
- {
- code: '@viewport { }',
- },
- {
- code: '@viewport{ }',
- },
- {
- code: '@viewport\n{ }',
- },
- {
- code: '@viewport\r\n\r\n{ }',
- },
- {
- code: '@counter-style\nwinners-list { }',
- },
- {
- code: '@font-face { };',
- },
- {
- code: '@unknown\n"ident";',
- },
- {
- code: '@unknown\nident { };',
- },
- {
- code: 'a { color: pink; @crazy-custom-at-rule; }',
- },
- {
- code: '@charset\n\n"UTF-8";',
- },
- {
- code: '@charset\r\n\r\n"UTF-8";',
- },
- {
- code: '@media\n\n(width <= 100px) { }',
- },
- ],
-
- reject: [
- {
- code: '@charset "UTF-8";',
- message: messages.expectedAfter('@charset'),
- line: 1,
- column: 8,
- },
- {
- code: '@charset"UTF-8";',
- message: messages.expectedAfter('@charset'),
- line: 1,
- column: 8,
- },
- {
- code: '@charset "UTF-8";',
- message: messages.expectedAfter('@charset'),
- line: 1,
- column: 8,
- },
- {
- code: '@media (width <= 100px) { }',
- message: messages.expectedAfter('@media'),
- line: 1,
- column: 6,
- },
- {
- code: '@media(width <= 100px) { }',
- message: messages.expectedAfter('@media'),
- line: 1,
- column: 6,
- },
- {
- code: '@media (width <= 100px) { }',
- message: messages.expectedAfter('@media'),
- line: 1,
- column: 6,
- },
- {
- code: '@unknown "ident";',
- message: messages.expectedAfter('@unknown'),
- line: 1,
- column: 8,
- },
- {
- code: '@unknown"ident";',
- message: messages.expectedAfter('@unknown'),
- line: 1,
- column: 8,
- },
- {
- code: '@unknown"ident" { };',
- message: messages.expectedAfter('@unknown'),
- line: 1,
- column: 8,
- },
- {
- code: '@unknown ident { };',
- message: messages.expectedAfter('@unknown'),
- line: 1,
- column: 8,
- },
- {
- code: '@unknown ident { };',
- message: messages.expectedAfter('@unknown'),
- line: 1,
- column: 8,
- },
- {
- code: '@-webkit-keyframes identifier { }',
- message: messages.expectedAfter('@-webkit-keyframes'),
- line: 1,
- column: 18,
- },
- ],
-});
-
-testRule({
- ruleName,
- customSyntax: 'postcss-less',
- config: ['always'],
-
- accept: [
- {
- code: '@nice-blue:#5B83AD;',
- description: 'ignore variables',
- },
- {
- code: '@nice-blue: #5B83AD;',
- description: 'ignore variables',
- },
- {
- code: '@nice-blue:\n#5B83AD;',
- description: 'ignore variables',
- },
- {
- code: '@variable: .bucket; .@{variable} { }',
- description: 'ignore interpolation',
- },
- {
- code: '@detached-ruleset: { background: red; }; .top { @detached-ruleset(); }',
- description: 'ignore passing rulesets to mixins',
- },
- {
- code: '@my-ruleset: { .my-selector { background-color: black; } };',
- },
- {
- code: '.class1 { .mixin(#ddd) }',
- description: 'ignore mixins',
- },
- {
- code: '.button { &-ok {} }',
- description: 'ignore parent selectors',
- },
- ],
-});
-
-testRule({
- ruleName,
- customSyntax: 'postcss-scss',
- config: ['always'],
-
- accept: [
- {
- code: '@mixin\nmixin() { @content; }; .colors { @include\nmixin { color: $color; }}',
- description: 'ignore content blocks',
- },
- {
- code: '@mixin\r\nmixin() { @content; }; .colors { @include\r\nmixin { color: $color; }}',
- description: 'ignore content blocks',
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['always-multi-line'],
-
- accept: [
- {
- code: '@charset "UTF-8";',
- },
- {
- code: '@charset "UTF-8"\n;',
- },
- {
- code: '@charset "UTF-8";',
- },
- {
- code: '@charset"UTF-8";',
- },
- {
- code: '@charset\n"UTF-8";',
- },
- {
- code: '@charset\r\n"UTF-8";',
- },
- {
- code: '@import"x.css";',
- },
- {
- code: '@import "x.css";',
- },
- {
- code: '@import "x.css" screen and (orientation:landscape);',
- },
- {
- code: '@import url("x.css");',
- },
- {
- code: '@import\nurl("x.css");',
- },
- {
- code: '@import url("x.css") screen and (orientation:landscape);',
- },
- {
- code: '@namespace url(XML-namespace-URL);',
- },
- {
- code: '@media(min-width: 700px) and (orientation: landscape) { }',
- },
- {
- code: '@media (min-width: 700px) and (orientation: landscape) { }',
- },
- {
- code: '@media (min-width: 700px) and (orientation: landscape) { }',
- },
- {
- code: '@media (min-width: 700px) and (orientation: landscape)\n{ }',
- },
- {
- code: '@media\n(min-width: 700px) and (orientation: landscape) { }',
- },
- {
- code: '@media\r\n(min-width: 700px) and (orientation: landscape) { }',
- },
- {
- code: '@supports (animation-name: test) { }',
- },
- {
- code: '@supports(animation-name: test) { }',
- },
- {
- code: '@keyframes identifier { }',
- },
- {
- code: '@-webkit-keyframes identifier { }',
- },
- {
- code: '@viewport { }',
- },
- {
- code: '@viewport{ }',
- },
- {
- code: '@viewport\n{ }',
- },
- {
- code: '@viewport\n\n{ }',
- },
- {
- code: '@counter-style winners-list { }',
- },
- {
- code: '@font-face { };',
- },
- {
- code: '@unknown "ident";',
- },
- {
- code: '@unknown"ident";',
- },
- {
- code: '@unknown ident { };',
- },
- {
- code: '@charset\n\n"UTF-8";',
- },
- {
- code: '@charset\r\n\r\n"UTF-8";',
- },
- {
- code: '@media\n\n(min-width: 700px) and (orientation: landscape) { }',
- },
- ],
-
- reject: [
- {
- code: '@import url("x.css")\nscreen and (orientation:landscape);',
- message: messages.expectedAfter('@import'),
- line: 1,
- column: 7,
- },
- {
- code: '@import url("x.css")\r\nscreen and (orientation:landscape);',
- message: messages.expectedAfter('@import'),
- line: 1,
- column: 7,
- },
- {
- code: '@media (\nmin-width: 700px) and (orientation: landscape) { }',
- message: messages.expectedAfter('@media'),
- line: 1,
- column: 6,
- },
- {
- code: '@media (\r\nmin-width: 700px) and (orientation: landscape) { }',
- message: messages.expectedAfter('@media'),
- line: 1,
- column: 6,
- },
- {
- code: '@media (min-width: 700px\n) and (orientation: landscape) { }',
- message: messages.expectedAfter('@media'),
- line: 1,
- column: 6,
- },
- {
- code: '@media (min-width\n: 700px) and (orientation: landscape) { }',
- message: messages.expectedAfter('@media'),
- line: 1,
- column: 6,
- },
- {
- code: '@media (min-width:\n700px) and (orientation: landscape) { }',
- message: messages.expectedAfter('@media'),
- line: 1,
- column: 6,
- },
- ],
-});
diff --git a/lib/rules/at-rule-name-newline-after/index.js b/lib/rules/at-rule-name-newline-after/index.js
deleted file mode 100644
index d04dbb312c..0000000000
--- a/lib/rules/at-rule-name-newline-after/index.js
+++ /dev/null
@@ -1,45 +0,0 @@
-'use strict';
-
-const atRuleNameSpaceChecker = require('../atRuleNameSpaceChecker');
-const ruleMessages = require('../../utils/ruleMessages');
-const validateOptions = require('../../utils/validateOptions');
-const whitespaceChecker = require('../../utils/whitespaceChecker');
-
-const ruleName = 'at-rule-name-newline-after';
-
-const messages = ruleMessages(ruleName, {
- expectedAfter: (name) => `Expected newline after at-rule name "${name}"`,
-});
-
-const meta = {
- url: 'https://stylelint.io/user-guide/rules/at-rule-name-newline-after',
- deprecated: true,
-};
-
-/** @type {import('stylelint').Rule} */
-const rule = (primary) => {
- const checker = whitespaceChecker('newline', primary, messages);
-
- return (root, result) => {
- const validOptions = validateOptions(result, ruleName, {
- actual: primary,
- possible: ['always', 'always-multi-line'],
- });
-
- if (!validOptions) {
- return;
- }
-
- atRuleNameSpaceChecker({
- root,
- result,
- locationChecker: checker.afterOneOnly,
- checkedRuleName: ruleName,
- });
- };
-};
-
-rule.ruleName = ruleName;
-rule.messages = messages;
-rule.meta = meta;
-module.exports = rule;
diff --git a/lib/rules/at-rule-name-space-after/README.md b/lib/rules/at-rule-name-space-after/README.md
deleted file mode 100644
index 4f55d4156d..0000000000
--- a/lib/rules/at-rule-name-space-after/README.md
+++ /dev/null
@@ -1,119 +0,0 @@
-# at-rule-name-space-after
-
-> **Warning** This rule is deprecated and will be removed in the future. See [the migration guide](../../../docs/migration-guide/to-15.md).
-
-Require a single space after at-rule names.
-
-
-```css
-@media (max-width: 600px) {}
-/** ↑
- * The space after at-rule names */
-```
-
-The [`fix` option](../../../docs/user-guide/options.md#fix) can automatically fix all of the problems reported by this rule.
-
-## Options
-
-`string`: `"always"|"always-single-line"`
-
-### `"always"`
-
-There _must always_ be a single space after at-rule names.
-
-The following patterns are considered problems:
-
-
-```css
-@charset"UTF-8";
-```
-
-
-```css
-@media(min-width: 700px) {}
-```
-
-
-```css
-@media (min-width: 700px) {}
-```
-
-
-```css
-@media
-(min-width: 700px) {}
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-@charset "UTF-8";
-```
-
-
-```css
-@import url("x.css");
-```
-
-
-```css
-@media (min-width: 700px) {}
-```
-
-### `"always-single-line"`
-
-There _must always_ be a single space after at-rule names in single-line declaration blocks.
-
-The following patterns are considered problems:
-
-
-```css
-@charset"UTF-8";
-```
-
-
-```css
-@media(min-width: 700px) {}
-```
-
-
-```css
-@media (min-width: 700px) {}
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-@charset "UTF-8";
-```
-
-
-```css
-@import url("x.css");
-```
-
-
-```css
-@media (min-width: 700px) {}
-```
-
-
-```css
-@media
-(min-width: 700px) {}
-```
-
-
-```css
-@media(min-width: 700px) and
- (orientation: portrait) {}
-```
-
-
-```css
-@media
- (min-width: 700px) and
- (orientation: portrait) {}
-```
diff --git a/lib/rules/at-rule-name-space-after/__tests__/index.js b/lib/rules/at-rule-name-space-after/__tests__/index.js
deleted file mode 100644
index b976655235..0000000000
--- a/lib/rules/at-rule-name-space-after/__tests__/index.js
+++ /dev/null
@@ -1,468 +0,0 @@
-'use strict';
-
-const { messages, ruleName } = require('..');
-
-testRule({
- ruleName,
- config: ['always'],
- fix: true,
-
- accept: [
- {
- code: '@charset "UTF-8";',
- },
- {
- code: '@charset "UTF-8";',
- },
- {
- code: '@import "x.css";',
- },
- {
- code: '@import "x.css" screen and (orientation:landscape);',
- },
- {
- code: '@import url("x.css");',
- },
- {
- code: '@import url("x.css") screen and (orientation:landscape);',
- },
- {
- code: '@namespace url(XML-namespace-URL);',
- },
- {
- code: '@media (min-width: 700px) and (orientation: landscape) { }',
- },
- {
- code: '@media (min-width: 700px) and (orientation: landscape) { }',
- },
- {
- code: '@media (min-width: 700px) and (orientation: landscape)\n{ }',
- },
- {
- code: '@media (min-width: 700px) and (orientation: landscape)\r\n{ }',
- },
- {
- code: '@media (min-width: 700px) and (orientation: landscape) { }',
- },
- {
- code: '@media (min-width: 700px)\nand (orientation: landscape) { }',
- },
- {
- code: '@media (min-width: 700px)\r\nand (orientation: landscape) { }',
- },
- {
- code: '@supports (animation-name: test) { }',
- },
- {
- code: '@keyframes identifier { }',
- },
- {
- code: '@-webkit-keyframes identifier { }',
- },
- {
- code: '@viewport { }',
- },
- {
- code: '@viewport{ }',
- },
- {
- code: '@viewport\n{ }',
- },
- {
- code: '@viewport\r\n{ }',
- },
- {
- code: '@viewport\n\n{ }',
- },
- {
- code: '@viewport\r\n\r\n{ }',
- },
- {
- code: '@counter-style winners-list { }',
- },
- {
- code: '@font-face { };',
- },
- {
- code: '@unknown "ident";',
- },
- {
- code: '@unknown ident { };',
- },
- {
- code: 'a { color: pink; @crazy-custom-at-rule; }',
- },
- ],
-
- reject: [
- {
- code: '@charset"UTF-8";',
- fixed: '@charset "UTF-8";',
- message: messages.expectedAfter('@charset'),
- line: 1,
- column: 8,
- },
- {
- code: '@charset"UTF-8";',
- fixed: '@charset "UTF-8";',
- message: messages.expectedAfter('@charset'),
- line: 1,
- column: 8,
- },
- {
- code: '@charset "UTF-8";',
- fixed: '@charset "UTF-8";',
- message: messages.expectedAfter('@charset'),
- line: 1,
- column: 8,
- },
- {
- code: '@charset\n"UTF-8";',
- fixed: '@charset "UTF-8";',
- message: messages.expectedAfter('@charset'),
- line: 1,
- column: 8,
- },
- {
- code: '@charset\r\n"UTF-8";',
- fixed: '@charset "UTF-8";',
- message: messages.expectedAfter('@charset'),
- line: 1,
- column: 8,
- },
- {
- code: '@charset\n\n"UTF-8";',
- fixed: '@charset "UTF-8";',
- message: messages.expectedAfter('@charset'),
- line: 1,
- column: 8,
- },
- {
- code: '@charset\r\n\r\n"UTF-8";',
- fixed: '@charset "UTF-8";',
- message: messages.expectedAfter('@charset'),
- line: 1,
- column: 8,
- },
- {
- code: '@media(width <= 100px) { }',
- fixed: '@media (width <= 100px) { }',
- message: messages.expectedAfter('@media'),
- line: 1,
- column: 6,
- },
- {
- code: '@media\n(width <= 100px) { }',
- fixed: '@media (width <= 100px) { }',
- message: messages.expectedAfter('@media'),
- line: 1,
- column: 6,
- },
- {
- code: '@media\r\n(width <= 100px) { }',
- fixed: '@media (width <= 100px) { }',
- message: messages.expectedAfter('@media'),
- line: 1,
- column: 6,
- },
- {
- code: '@media (width <= 100px) { }',
- fixed: '@media (width <= 100px) { }',
- message: messages.expectedAfter('@media'),
- line: 1,
- column: 6,
- },
- {
- code: '@unknown"ident";',
- fixed: '@unknown "ident";',
- message: messages.expectedAfter('@unknown'),
- line: 1,
- column: 8,
- },
- {
- code: '@unknown"ident" { };',
- fixed: '@unknown "ident" { };',
- message: messages.expectedAfter('@unknown'),
- line: 1,
- column: 8,
- },
- {
- code: '@unknown ident { };',
- fixed: '@unknown ident { };',
- message: messages.expectedAfter('@unknown'),
- line: 1,
- column: 8,
- },
- {
- code: '@-webkit-keyframes ident { };',
- fixed: '@-webkit-keyframes ident { };',
- message: messages.expectedAfter('@-webkit-keyframes'),
- line: 1,
- column: 18,
- },
- {
- code: '@media/*comment*/(width <= 100px) { }',
- fixed: '@media /*comment*/(width <= 100px) { }',
- message: messages.expectedAfter('@media'),
- line: 1,
- column: 6,
- },
- ],
-});
-
-testRule({
- ruleName,
- customSyntax: 'postcss-less',
- config: ['always'],
-
- accept: [
- {
- code: '@nice-blue:#5B83AD;',
- description: 'ignore variables',
- },
- {
- code: '@nice-blue: #5B83AD;',
- description: 'ignore variables',
- },
- {
- code: '@nice-blue:\n#5B83AD;',
- description: 'ignore variables',
- },
- {
- code: '@variable: .bucket; .@{variable} { }',
- description: 'ignore interpolation',
- },
- {
- code: '@detached-ruleset: { background: red; }; .top { @detached-ruleset(); }',
- description: 'ignore passing rulesets to mixins',
- },
- {
- code: '@my-ruleset: { .my-selector { background-color: black; } };',
- },
- {
- code: '.class1 { .mixin(#ddd) }',
- description: 'ignore mixins',
- },
- {
- code: '.button { &-ok {} }',
- description: 'ignore parent selectors',
- },
- ],
-});
-
-testRule({
- ruleName,
- customSyntax: 'postcss-scss',
- config: ['always'],
-
- accept: [
- {
- code: '@mixin mixin() { @content; }; .colors { @include mixin { color: $color; }}',
- description: 'ignore content blocks',
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['always-single-line'],
- fix: true,
-
- accept: [
- {
- code: '@charset "UTF-8";',
- },
- {
- code: '@charset\n"UTF-8";',
- },
- {
- code: '@charset\r\n"UTF-8";',
- },
- {
- code: '@charset\n\n"UTF-8";',
- },
- {
- code: '@charset\r\n\r\n"UTF-8";',
- },
- {
- code: '@charset "UTF-8";',
- },
- {
- code: '@charset\n"UTF-8";',
- },
- {
- code: '@charset\r\n"UTF-8";',
- },
- {
- code: '@charset\n\n"UTF-8";',
- },
- {
- code: '@charset\r\n\r\n"UTF-8";',
- },
- {
- code: '@import "x.css";',
- },
- {
- code: '@import "x.css" screen and (orientation:landscape);',
- },
- {
- code: '@import url("x.css");',
- },
- {
- code: '@import\nurl("x.css");',
- },
- {
- code: '@import\r\nurl("x.css");',
- },
- {
- code: '@import url("x.css") screen and (orientation:landscape);',
- },
- {
- code: '@namespace url(XML-namespace-URL);',
- },
- {
- code: '@media (min-width: 700px) and (orientation: landscape) { }',
- },
- {
- code: '@media (min-width: 700px) and (orientation: landscape) { }',
- },
- {
- code: '@media (min-width: 700px) and (orientation: landscape)\n{ }',
- },
- {
- code: '@media (min-width: 700px) and (orientation: landscape)\r\n{ }',
- },
- {
- code: '@media (min-width: 700px) and (orientation: landscape) { }',
- },
- {
- code: '@media (min-width: 700px)\nand (orientation: landscape) { }',
- },
- {
- code: '@media (min-width: 700px)\r\nand (orientation: landscape) { }',
- },
- {
- code: '@media(min-width: 700px)\nand (orientation: landscape) { }',
- },
- {
- code: '@media(min-width: 700px)\r\nand (orientation: landscape) { }',
- },
- {
- code: '@media(min-width: 700px) and\n(orientation: landscape) { }',
- },
- {
- code: '@media(min-width: 700px) and\r\n(orientation: landscape) { }',
- },
- {
- code: '@media\n(min-width: 700px) and (orientation: landscape) { }',
- },
- {
- code: '@media\r\n(min-width: 700px) and (orientation: landscape) { }',
- },
- {
- code: '@supports (animation-name: test) { }',
- },
- {
- code: '@keyframes identifier { }',
- },
- {
- code: '@-webkit-keyframes identifier { }',
- },
- {
- code: '@viewport { }',
- },
- {
- code: '@viewport{ }',
- },
- {
- code: '@viewport\n{ }',
- },
- {
- code: '@viewport\r\n{ }',
- },
- {
- code: '@viewport\n\n{ }',
- },
- {
- code: '@viewport\r\n\r\n{ }',
- },
- {
- code: '@counter-style winners-list { }',
- },
- {
- code: '@font-face { };',
- },
- {
- code: '@unknown "ident";',
- },
- {
- code: '@unknown ident { };',
- },
- ],
-
- reject: [
- {
- code: '@charset"UTF-8";',
- fixed: '@charset "UTF-8";',
- message: messages.expectedAfter('@charset'),
- line: 1,
- column: 8,
- },
- {
- code: '@charset"UTF-8";',
- fixed: '@charset "UTF-8";',
- message: messages.expectedAfter('@charset'),
- line: 1,
- column: 8,
- },
- {
- code: '@charset "UTF-8";',
- fixed: '@charset "UTF-8";',
- message: messages.expectedAfter('@charset'),
- line: 1,
- column: 8,
- },
- {
- code: '@media(width <= 100px) { }',
- fixed: '@media (width <= 100px) { }',
- message: messages.expectedAfter('@media'),
- line: 1,
- column: 6,
- },
- {
- code: '@media (width <= 100px) { }',
- fixed: '@media (width <= 100px) { }',
- message: messages.expectedAfter('@media'),
- line: 1,
- column: 6,
- },
- {
- code: '@unknown"ident";',
- fixed: '@unknown "ident";',
- message: messages.expectedAfter('@unknown'),
- line: 1,
- column: 8,
- },
- {
- code: '@unknown"ident" { };',
- fixed: '@unknown "ident" { };',
- message: messages.expectedAfter('@unknown'),
- line: 1,
- column: 8,
- },
- {
- code: '@unknown ident { };',
- fixed: '@unknown ident { };',
- message: messages.expectedAfter('@unknown'),
- line: 1,
- column: 8,
- },
- {
- code: '@-webkit-keyframes ident { };',
- fixed: '@-webkit-keyframes ident { };',
- message: messages.expectedAfter('@-webkit-keyframes'),
- line: 1,
- column: 18,
- },
- ],
-});
diff --git a/lib/rules/at-rule-name-space-after/index.js b/lib/rules/at-rule-name-space-after/index.js
deleted file mode 100644
index 473457dc70..0000000000
--- a/lib/rules/at-rule-name-space-after/index.js
+++ /dev/null
@@ -1,53 +0,0 @@
-'use strict';
-
-const atRuleNameSpaceChecker = require('../atRuleNameSpaceChecker');
-const ruleMessages = require('../../utils/ruleMessages');
-const validateOptions = require('../../utils/validateOptions');
-const whitespaceChecker = require('../../utils/whitespaceChecker');
-
-const ruleName = 'at-rule-name-space-after';
-
-const messages = ruleMessages(ruleName, {
- expectedAfter: (name) => `Expected single space after at-rule name "${name}"`,
-});
-
-const meta = {
- url: 'https://stylelint.io/user-guide/rules/at-rule-name-space-after',
- fixable: true,
- deprecated: true,
-};
-
-/** @type {import('stylelint').Rule} */
-const rule = (primary, _secondary, context) => {
- const checker = whitespaceChecker('space', primary, messages);
-
- return (root, result) => {
- const validOptions = validateOptions(result, ruleName, {
- actual: primary,
- possible: ['always', 'always-single-line'],
- });
-
- if (!validOptions) {
- return;
- }
-
- atRuleNameSpaceChecker({
- root,
- result,
- locationChecker: checker.after,
- checkedRuleName: ruleName,
- fix: context.fix
- ? (atRule) => {
- if (typeof atRule.raws.afterName === 'string') {
- atRule.raws.afterName = atRule.raws.afterName.replace(/^\s*/, ' ');
- }
- }
- : null,
- });
- };
-};
-
-rule.ruleName = ruleName;
-rule.messages = messages;
-rule.meta = meta;
-module.exports = rule;
diff --git a/lib/rules/at-rule-semicolon-newline-after/README.md b/lib/rules/at-rule-semicolon-newline-after/README.md
deleted file mode 100644
index afebd702c8..0000000000
--- a/lib/rules/at-rule-semicolon-newline-after/README.md
+++ /dev/null
@@ -1,65 +0,0 @@
-# at-rule-semicolon-newline-after
-
-> **Warning** This rule is deprecated and will be removed in the future. See [the migration guide](../../../docs/migration-guide/to-15.md).
-
-Require a newline after the semicolon of at-rules.
-
-
-```css
-@import url("x.css");
-@import url("y.css");
-/** ↑
- * The newline after these semicolons */
-```
-
-This rule allows an end-of-line comment followed by a newline. For example:
-
-
-```css
-@import url("x.css"); /* end-of-line comment */
-
-a {}
-```
-
-The [`fix` option](../../../docs/user-guide/options.md#fix) can automatically fix all of the problems reported by this rule.
-
-## Options
-
-`string`: `"always"`
-
-### `"always"`
-
-There _must always_ be a newline after the semicolon.
-
-The following patterns are considered problems:
-
-
-```css
-@import url("x.css"); @import url("y.css");
-```
-
-
-```css
-@import url("x.css"); a {}
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-@import url("x.css");
-@import url("y.css");
-```
-
-
-```css
-@import url("x.css"); /* end-of-line comment */
-a {}
-```
-
-
-```css
-@import url("x.css");
-
-a {}
-```
diff --git a/lib/rules/at-rule-semicolon-newline-after/__tests__/index.js b/lib/rules/at-rule-semicolon-newline-after/__tests__/index.js
deleted file mode 100644
index ed2ee5ab7d..0000000000
--- a/lib/rules/at-rule-semicolon-newline-after/__tests__/index.js
+++ /dev/null
@@ -1,147 +0,0 @@
-'use strict';
-
-const { messages, ruleName } = require('..');
-
-testRule({
- ruleName,
- config: ['always'],
- fix: true,
- accept: [
- {
- code: '@foo;\na {}',
- },
- {
- code: "@import 'x.css';\na {}",
- },
- {
- code: "@iMpOrT 'x.css';\na {}",
- },
- {
- code: "@IMPORT 'x.css';\na {}",
- },
- {
- code: "@charset 'UTF-8';\na {}",
- },
- {
- code: "@charset 'UTF-8';\n@import 'x.css'",
- },
- {
- code: "@charset 'UTF-8';\n@import 'x.css'\na {}",
- },
- {
- code: '@namespace url(XML-namespace-URL);\na {}',
- },
- {
- code: "@import 'x.css'); /* comment */\n",
- },
- {
- code: "@import 'x.css');/* comment */\n",
- },
- {
- code: "@import 'x.css'); /* comment */\n",
- },
- {
- code: "@import 'x.css');\t/* comment */\n",
- },
- {
- code: "@import 'x.css'); \t/* comment */\n",
- },
- {
- code: "@charset 'UTF-8';\n@media {}",
- },
- {
- code: "@import 'x.css';\r\n",
- description: 'windows',
- },
- {
- code: "@import 'x.css'; /* comment */\r\n",
- description: 'windows',
- },
- {
- code: "@import 'x.css';",
- description: 'single blockless rule',
- },
- {
- code: 'a{\n@extend .b;\n@extend .c\n}',
- description: 'non-standard nested rule',
- },
- {
- code: '@font-face {}; a {}',
- description: 'ignore at-rule with block',
- },
- ],
-
- reject: [
- {
- code: '@mixin foo; a {}',
- fixed: '@mixin foo;\n a {}',
- message: messages.expectedAfter(),
- line: 1,
- column: 12,
- },
- {
- code: '@mIxIn foo; a {}',
- fixed: '@mIxIn foo;\n a {}',
- message: messages.expectedAfter(),
- line: 1,
- column: 12,
- },
- {
- code: '@MIXIN foo; a {}',
- fixed: '@MIXIN foo;\n a {}',
- message: messages.expectedAfter(),
- line: 1,
- column: 12,
- },
- {
- code: '@import url("x.css"); @charset "UTF-8";',
- fixed: '@import url("x.css");\n @charset "UTF-8";',
- message: messages.expectedAfter(),
- line: 1,
- column: 22,
- },
- {
- code: '@charset "UTF-8"; a {};',
- fixed: '@charset "UTF-8";\n a {};',
- message: messages.expectedAfter(),
- line: 1,
- column: 18,
- },
- {
- code: 'a{\n@extend .b; @extend .c\n}',
- fixed: 'a{\n@extend .b;\n @extend .c\n}',
- message: messages.expectedAfter(),
- line: 2,
- column: 12,
- },
- {
- code: 'a{\r\n@extend .b; @extend .c\r\n}',
- fixed: 'a{\r\n@extend .b;\r\n @extend .c\r\n}',
- message: messages.expectedAfter(),
- line: 2,
- column: 12,
- },
- ],
-});
-
-testRule({
- ruleName,
- customSyntax: 'postcss-less',
- config: ['always'],
- accept: [
- {
- code: `
- .someMixin() { margin: 0; }
- span { .someMixin(); }
- `,
- description: 'ignore Less mixin',
- },
- {
- code: `
- @myVariable: #f7f8f9;
- span { background-color: @myVariable; }
- `,
- description: 'ignore Less variable',
- },
- ],
-});
diff --git a/lib/rules/at-rule-semicolon-newline-after/index.js b/lib/rules/at-rule-semicolon-newline-after/index.js
deleted file mode 100644
index 0b93de65a0..0000000000
--- a/lib/rules/at-rule-semicolon-newline-after/index.js
+++ /dev/null
@@ -1,84 +0,0 @@
-'use strict';
-
-const hasBlock = require('../../utils/hasBlock');
-const isStandardSyntaxAtRule = require('../../utils/isStandardSyntaxAtRule');
-const nextNonCommentNode = require('../../utils/nextNonCommentNode');
-const rawNodeString = require('../../utils/rawNodeString');
-const report = require('../../utils/report');
-const ruleMessages = require('../../utils/ruleMessages');
-const validateOptions = require('../../utils/validateOptions');
-const whitespaceChecker = require('../../utils/whitespaceChecker');
-
-const ruleName = 'at-rule-semicolon-newline-after';
-
-const messages = ruleMessages(ruleName, {
- expectedAfter: () => 'Expected newline after ";"',
-});
-
-const meta = {
- url: 'https://stylelint.io/user-guide/rules/at-rule-semicolon-newline-after',
- fixable: true,
- deprecated: true,
-};
-
-/** @type {import('stylelint').Rule} */
-const rule = (primary, _secondary, context) => {
- const checker = whitespaceChecker('newline', primary, messages);
-
- return (root, result) => {
- const validOptions = validateOptions(result, ruleName, {
- actual: primary,
- possible: ['always'],
- });
-
- if (!validOptions) {
- return;
- }
-
- root.walkAtRules((atRule) => {
- const nextNode = atRule.next();
-
- if (!nextNode) {
- return;
- }
-
- if (hasBlock(atRule)) {
- return;
- }
-
- if (!isStandardSyntaxAtRule(atRule)) {
- return;
- }
-
- // Allow an end-of-line comment
- const nodeToCheck = nextNonCommentNode(nextNode);
-
- if (!nodeToCheck) {
- return;
- }
-
- checker.afterOneOnly({
- source: rawNodeString(nodeToCheck),
- index: -1,
- err: (msg) => {
- if (context.fix) {
- nodeToCheck.raws.before = context.newline + nodeToCheck.raws.before;
- } else {
- report({
- message: msg,
- node: atRule,
- index: atRule.toString().length + 1,
- result,
- ruleName,
- });
- }
- },
- });
- });
- };
-};
-
-rule.ruleName = ruleName;
-rule.messages = messages;
-rule.meta = meta;
-module.exports = rule;
diff --git a/lib/rules/at-rule-semicolon-space-before/README.md b/lib/rules/at-rule-semicolon-space-before/README.md
deleted file mode 100644
index 2ee3251ef7..0000000000
--- a/lib/rules/at-rule-semicolon-space-before/README.md
+++ /dev/null
@@ -1,52 +0,0 @@
-# at-rule-semicolon-space-before
-
-> **Warning** This rule is deprecated and will be removed in the future. See [the migration guide](../../../docs/migration-guide/to-15.md).
-
-Require a single space or disallow whitespace before the semicolons of at-rules.
-
-
-```css
-@import "components/buttons";
-/** ↑
- * The space before this semicolon */
-```
-
-## Options
-
-`string`: `"always"|"never"`
-
-### `"always"`
-
-There _must always_ be a single space before the semicolons.
-
-The following pattern is considered a problem:
-
-
-```css
-@import "components/buttons";
-```
-
-The following pattern is _not_ considered a problem:
-
-
-```css
-@import "components/buttons" ;
-```
-
-### `"never"`
-
-There _must never_ be a single space before the semicolons.
-
-The following pattern is considered a problem:
-
-
-```css
-@import "components/buttons" ;
-```
-
-The following pattern is _not_ considered a problem:
-
-
-```css
-@import "components/buttons";
-```
diff --git a/lib/rules/at-rule-semicolon-space-before/__tests__/index.js b/lib/rules/at-rule-semicolon-space-before/__tests__/index.js
deleted file mode 100644
index 1d3102b73f..0000000000
--- a/lib/rules/at-rule-semicolon-space-before/__tests__/index.js
+++ /dev/null
@@ -1,170 +0,0 @@
-'use strict';
-
-const { messages, ruleName } = require('..');
-
-testRule({
- ruleName,
- config: ['always'],
-
- accept: [
- {
- code: '@import "styles/mystyle" ;',
- },
- {
- code: '@font-face {\n font-family: "MyFont"; src: url("myfont.woff2") format("woff2");\n}',
- },
- {
- code: '@font-face {\n font-family: "MyFont"; src: url("myfont.woff2") format("woff2");\n};',
- },
- {
- code: 'a { color: @brand-primary; }',
- },
- {
- code: '@myatrule "valuehassemicolon;" ;',
- },
- {
- code: '@import url(http://www.example.com/location;withsemicolon) ;',
- },
- {
- code: '@import /*my styles;*/ "styles/mystyle" ;',
- },
- {
- code: "@import\nurl('landscape.css')\nprojection ;",
- },
- ],
-
- reject: [
- {
- code: '@import "styles/mystyle";',
- message: messages.expectedBefore(),
- line: 1,
- column: 24,
- },
- {
- code: '@import "styles/mystyle" ;',
- message: messages.expectedBefore(),
- line: 1,
- column: 26,
- },
- {
- code: '@import "styles/mystyle"\t;',
- message: messages.expectedBefore(),
- line: 1,
- column: 25,
- },
- {
- code: '@import "styles/mystyle"\n;',
- message: messages.expectedBefore(),
- line: 1,
- column: 25,
- },
- {
- code: '@import "styles/mystyle"\r\n;',
- description: 'CRLF',
- message: messages.expectedBefore(),
- line: 1,
- column: 26,
- },
- {
- code: "@import\nurl('landscape.css')\nprojection;",
- message: messages.expectedBefore(),
- line: 3,
- column: 10,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['never'],
-
- accept: [
- {
- code: '@import "styles/mystyle";',
- },
- {
- code: '@font-face {\n font-family: "MyFont" ; src: url("myfont.woff2") format("woff2") ;\n}',
- },
- {
- code: '@font-face {\n font-family: "MyFont" ; src: url("myfont.woff2") format("woff2") ;\n} ;',
- },
- {
- code: 'a { color: @brand-primary ; }',
- },
- {
- code: '@myatrule "valuehassemicolon ;";',
- },
- {
- code: '@import url(http://www.example.com/location+;withsemicolon);',
- },
- {
- code: '@import /*my styles ;*/ "styles/mystyle";',
- },
- {
- code: "@import\nurl('landscape.css')\nprojection;",
- },
- ],
-
- reject: [
- {
- code: '@import "styles/mystyle" ;',
- message: messages.rejectedBefore(),
- line: 1,
- column: 25,
- },
- {
- code: '@import "styles/mystyle" ;',
- message: messages.rejectedBefore(),
- line: 1,
- column: 26,
- },
- {
- code: '@import "styles/mystyle"\t;',
- message: messages.rejectedBefore(),
- line: 1,
- column: 25,
- },
- {
- code: '@import "styles/mystyle"\n;',
- message: messages.rejectedBefore(),
- line: 1,
- column: 25,
- },
- {
- code: '@import "styles/mystyle"\r\n;',
- description: 'CRLF',
- message: messages.rejectedBefore(),
- line: 1,
- column: 26,
- },
- {
- code: "@import\nurl('landscape.css')\nprojection ;",
- message: messages.rejectedBefore(),
- line: 3,
- column: 11,
- },
- ],
-});
-
-testRule({
- ruleName,
- customSyntax: 'postcss-less',
- config: ['always'],
-
- accept: [
- {
- code: `
- .someMixin() { margin: 0; }
- span { .someMixin(); }
- `,
- description: 'ignore Less mixin',
- },
- {
- code: `
- @myVariable: #f7f8f9;
- span { background-color: @myVariable; }
- `,
- description: 'ignore Less variable',
- },
- ],
-});
diff --git a/lib/rules/at-rule-semicolon-space-before/index.js b/lib/rules/at-rule-semicolon-space-before/index.js
deleted file mode 100644
index b75d385317..0000000000
--- a/lib/rules/at-rule-semicolon-space-before/index.js
+++ /dev/null
@@ -1,68 +0,0 @@
-'use strict';
-
-const hasBlock = require('../../utils/hasBlock');
-const isStandardSyntaxAtRule = require('../../utils/isStandardSyntaxAtRule');
-const rawNodeString = require('../../utils/rawNodeString');
-const report = require('../../utils/report');
-const ruleMessages = require('../../utils/ruleMessages');
-const validateOptions = require('../../utils/validateOptions');
-const whitespaceChecker = require('../../utils/whitespaceChecker');
-
-const ruleName = 'at-rule-semicolon-space-before';
-
-const messages = ruleMessages(ruleName, {
- expectedBefore: () => 'Expected single space before ";"',
- rejectedBefore: () => 'Unexpected whitespace before ";"',
-});
-
-const meta = {
- url: 'https://stylelint.io/user-guide/rules/at-rule-semicolon-space-before',
- deprecated: true,
-};
-
-/** @type {import('stylelint').Rule} */
-const rule = (primary) => {
- const checker = whitespaceChecker('space', primary, messages);
-
- return (root, result) => {
- const validOptions = validateOptions(result, ruleName, {
- actual: primary,
- possible: ['always', 'never'],
- });
-
- if (!validOptions) {
- return;
- }
-
- root.walkAtRules((atRule) => {
- if (hasBlock(atRule)) {
- return;
- }
-
- if (!isStandardSyntaxAtRule(atRule)) {
- return;
- }
-
- const nodeString = rawNodeString(atRule);
-
- checker.before({
- source: nodeString,
- index: nodeString.length,
- err: (m) => {
- report({
- message: m,
- node: atRule,
- index: nodeString.length - 1,
- result,
- ruleName,
- });
- },
- });
- });
- };
-};
-
-rule.ruleName = ruleName;
-rule.messages = messages;
-rule.meta = meta;
-module.exports = rule;
diff --git a/lib/rules/atRuleNameSpaceChecker.js b/lib/rules/atRuleNameSpaceChecker.js
deleted file mode 100644
index e9213a453a..0000000000
--- a/lib/rules/atRuleNameSpaceChecker.js
+++ /dev/null
@@ -1,55 +0,0 @@
-'use strict';
-
-const isStandardSyntaxAtRule = require('../utils/isStandardSyntaxAtRule');
-const report = require('../utils/report');
-
-/**
- * @param {{
- * root: import('postcss').Root,
- * locationChecker: (opts: { source: string, index: number, err: (msg: string) => void, errTarget: string }) => void,
- * result: import('stylelint').PostcssResult,
- * checkedRuleName: string,
- * fix?: ((atRule: import('postcss').AtRule) => void) | null,
- * }} options
- */
-module.exports = function atRuleNameSpaceChecker(options) {
- options.root.walkAtRules((atRule) => {
- if (!isStandardSyntaxAtRule(atRule)) {
- return;
- }
-
- checkColon(
- `@${atRule.name}${atRule.raws.afterName || ''}${atRule.params}`,
- atRule.name.length,
- atRule,
- );
- });
-
- /**
- * @param {string} source
- * @param {number} index
- * @param {import('postcss').AtRule} node
- */
- function checkColon(source, index, node) {
- options.locationChecker({
- source,
- index,
- err: (m) => {
- if (options.fix) {
- options.fix(node);
-
- return;
- }
-
- report({
- message: m,
- node,
- index,
- result: options.result,
- ruleName: options.checkedRuleName,
- });
- },
- errTarget: `@${node.name}`,
- });
- }
-};
diff --git a/lib/rules/block-closing-brace-empty-line-before/README.md b/lib/rules/block-closing-brace-empty-line-before/README.md
deleted file mode 100644
index 015df7db5f..0000000000
--- a/lib/rules/block-closing-brace-empty-line-before/README.md
+++ /dev/null
@@ -1,240 +0,0 @@
-# block-closing-brace-empty-line-before
-
-> **Warning** This rule is deprecated and will be removed in the future. See [the migration guide](../../../docs/migration-guide/to-15.md).
-
-Require or disallow an empty line before the closing brace of blocks.
-
-
-```css
-a {
- color: pink;
- /* ← */
-} /* ↑ */
-/** ↑
- * This line */
-```
-
-The [`fix` option](../../../docs/user-guide/options.md#fix) can automatically fix all of the problems reported by this rule.
-
-## Options
-
-`string`: `"always-multi-line"|"never"`
-
-### `always-multi-line`
-
-The following patterns are considered problems:
-
-
-```css
-a {
- color: pink;
-}
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a {
- color: pink;
-
-}
-```
-
-
-```css
-a { color: pink; }
-```
-
-### `never`
-
-The following patterns are considered problems:
-
-
-```css
-a {
- color: pink;
-
-}
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a {
- color: pink;
-}
-```
-
-
-```css
-a { color: pink; }
-```
-
-## Optional secondary options
-
-### `except: ["after-closing-brace"]`
-
-When a rule is nested, `after-closing-brace` brace will reverse the primary option.
-
-For example, with `"never"` and `except: ["after-closing-brace"]`:
-
-The following patterns are considered problems:
-
-
-```css
-@media print {
-
- a {
- color: aquamarine;
- }
-}
-```
-
-
-```css
-@supports (animation-name: test) {
-
- a {
- color: aquamarine;
- }
-}
-```
-
-
-```css
-@keyframes test {
-
- 100% {
- color: aquamarine;
- }
-}
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-@media print {
-
- a {
- color: aquamarine;
- }
-
-}
-```
-
-
-```css
-@font-face {
- font-family: "MyFont";
- src: url("myfont.woff2") format("woff2");
-}
-```
-
-
-```css
-@supports (animation-name: test) {
-
- a {
- color: aquamarine;
- }
-
-}
-```
-
-
-```css
-@keyframes test {
-
- 100% {
- color: aquamarine;
- }
-
-}
-```
-
-For example, with `"always-multi-line"` and `except: ["after-closing-brace"]`:
-
-The following patterns are considered problems:
-
-
-```css
-@media print {
-
- a {
- color: aquamarine;
-
- }
-
-}
-```
-
-
-```css
-@supports (animation-name: test) {
-
- a {
- color: aquamarine;
-
- }
-
-}
-```
-
-
-```css
-@keyframes test {
-
- 100% {
- color: aquamarine;
-
- }
-
-}
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-@media print {
-
- a {
- color: aquamarine;
-
- }
-}
-```
-
-
-```css
-@font-face {
- font-family: "MyFont";
- src: url("myfont.woff2") format("woff2");
-
-}
-```
-
-
-```css
-@supports (animation-name: test) {
-
- a {
- color: aquamarine;
-
- }
-}
-```
-
-
-```css
-@keyframes test {
-
- 100% {
- color: aquamarine;
-
- }
-}
-```
diff --git a/lib/rules/block-closing-brace-empty-line-before/__tests__/index.js b/lib/rules/block-closing-brace-empty-line-before/__tests__/index.js
deleted file mode 100644
index aec615c397..0000000000
--- a/lib/rules/block-closing-brace-empty-line-before/__tests__/index.js
+++ /dev/null
@@ -1,420 +0,0 @@
-'use strict';
-
-const { messages, ruleName } = require('..');
-
-testRule({
- ruleName,
- config: ['always-multi-line'],
- fix: true,
-
- accept: [
- {
- code: 'a { color: pink; }',
- },
- {
- code: 'a { color: pink;\n\n}',
- },
- {
- code: 'a { color: pink;; ;\n\n}',
- },
- {
- code: 'a { color: pink;;\n\n;}',
- },
- {
- code: 'a {color: pink;\r\n\r\n}',
- },
- {
- code: 'a {\ncolor: pink;\n\n}',
- },
- {
- code: 'a {\r\ncolor: pink;\r\n\r\n}',
- },
- {
- code: 'a { color: pink;\n\n}b { color: red;\n\n}',
- },
- {
- code: 'a {\ncolor: pink;\n\n\n\n}',
- description: 'one *or more* empty lines are allowed',
- },
- {
- code: '@media print {\n a {\n color: pink;\n\n }\n\n}',
- description: 'indentation after the newline before the closing braces',
- },
- {
- code: '@media print {\n\ta {\n\t\tcolor: pink;\n\t\t&:hover{\n\t\t\tcolor: red;\n\n\t\t\t}\n\n\t\t}\n\n}',
- description:
- '3 level deep nesting with indentation after the newline before the closing braces',
- },
- ],
-
- reject: [
- {
- code: 'a { color: pink;\n}',
- fixed: 'a { color: pink;\n\n}',
- message: messages.expected,
- line: 2,
- column: 1,
- },
- {
- code: 'a { color: pink;\r\n}',
- fixed: 'a { color: pink;\r\n\r\n}',
- message: messages.expected,
- line: 2,
- column: 1,
- },
- {
- code: 'a { color: pink;\n }',
- fixed: 'a { color: pink;\n\n }',
- message: messages.expected,
- line: 2,
- column: 2,
- },
- {
- code: 'a { color: pink;\n\t}',
- fixed: 'a { color: pink;\n\n\t}',
- message: messages.expected,
- line: 2,
- column: 2,
- },
- {
- code: 'a { color: pink;\r\n }',
- fixed: 'a { color: pink;\r\n\r\n }',
- message: messages.expected,
- line: 2,
- column: 3,
- },
- {
- code: 'a { color: pink;\n;}',
- fixed: 'a { color: pink;\n;\n\n}',
- message: messages.expected,
- line: 2,
- column: 2,
- },
- {
- code: 'a {\ncolor: pink;\n}',
- fixed: 'a {\ncolor: pink;\n\n}',
- message: messages.expected,
- line: 3,
- column: 1,
- },
- {
- code: 'a {\n\ncolor: pink;\n}',
- fixed: 'a {\n\ncolor: pink;\n\n}',
- message: messages.expected,
- line: 4,
- column: 1,
- },
- {
- code: 'a { color: pink;\n\n/* comment here*/\n}',
- fixed: 'a { color: pink;\n\n/* comment here*/\n\n}',
- message: messages.expected,
- line: 4,
- column: 1,
- },
- {
- code: 'a { color: pink;\r\n\r\n/* comment here*/\r\n}',
- fixed: 'a { color: pink;\r\n\r\n/* comment here*/\r\n\r\n}',
- message: messages.expected,
- line: 4,
- column: 1,
- },
- {
- code: '@media print {\n a {\n color: pink;\n/* comment here*/\n }\n}',
- fixed: '@media print {\n a {\n color: pink;\n/* comment here*/\n\n }\n\n}',
- warnings: [
- {
- message: messages.expected,
- line: 5,
- column: 3,
- },
- {
- message: messages.expected,
- line: 6,
- column: 1,
- },
- ],
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['never'],
- fix: true,
-
- accept: [
- {
- code: 'a { color: pink; }',
- },
- {
- code: 'a { color: pink;\n}',
- },
- {
- code: 'a { color: pink;; ;\n}',
- },
- {
- code: 'a { color: pink;;\n;}',
- },
- {
- code: 'a {color: pink;\r\n}',
- },
- {
- code: 'a {\ncolor: pink;\n}',
- },
- {
- code: 'a {\r\ncolor: pink;\r\n}',
- },
- {
- code: 'a { color: pink;\n}b { color: red;\n}',
- },
- {
- code: '@media print {\n a {\n color: pink;\n }\n}',
- description: 'indentation after the newline before the closing braces',
- },
- {
- code: '@media print {\n\ta {\n\t\tcolor: pink;\n\t\t&:hover{\n\t\t\tcolor: red;\n\t\t\t}\n\t\t}\n}',
- description:
- '3 level deep nesting with indentation after the newline before the closing braces',
- },
- ],
-
- reject: [
- {
- code: 'a { color: pink;\n\n}',
- fixed: 'a { color: pink;\n}',
- message: messages.rejected,
- line: 3,
- column: 1,
- },
- {
- code: 'a { color: pink;\r\n\r\n}',
- fixed: 'a { color: pink;\r\n}',
- message: messages.rejected,
- line: 3,
- column: 1,
- },
- {
- code: 'a { color: pink;\n\n }',
- fixed: 'a { color: pink;\n }',
- message: messages.rejected,
- line: 3,
- column: 2,
- },
- {
- code: 'a { color: pink;\n\n\t}',
- fixed: 'a { color: pink;\n\t}',
- message: messages.rejected,
- line: 3,
- column: 2,
- },
- {
- code: 'a { color: pink;\r\n\r\n }',
- fixed: 'a { color: pink;\r\n }',
- message: messages.rejected,
- line: 3,
- column: 3,
- },
- {
- code: 'a { color: pink;\n\n;}',
- fixed: 'a { color: pink;\n;}',
- message: messages.rejected,
- line: 3,
- column: 2,
- },
- {
- code: 'a {\ncolor: pink;\n\n}',
- fixed: 'a {\ncolor: pink;\n}',
- message: messages.rejected,
- line: 4,
- column: 1,
- },
- {
- code: 'a {\n\ncolor: pink;\n\n}',
- fixed: 'a {\n\ncolor: pink;\n}',
- message: messages.rejected,
- line: 5,
- column: 1,
- },
- {
- code: '@media print {\n a {\n color: pink;\n\n }\n\n}',
- fixed: '@media print {\n a {\n color: pink;\n }\n}',
- warnings: [
- {
- message: messages.rejected,
- line: 5,
- column: 3,
- },
- {
- message: messages.rejected,
- line: 7,
- column: 1,
- },
- ],
- },
- {
- code: 'a {\n\ncolor: pink;\n\n/* comment here */\n\n}',
- fixed: 'a {\n\ncolor: pink;\n\n/* comment here */\n}',
- message: messages.rejected,
- line: 7,
- column: 1,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['never', { except: ['after-closing-brace'] }],
- fix: true,
-
- accept: [
- {
- code: 'a {\n\tcolor: aquamarine;\n}',
- },
- {
- code: '@media print {\n\n\ta {\n\t\tcolor: aquamarine;\n\t}\n\n}',
- },
- {
- code: '@font-face {\n\tfont-family: "MyFont";\n\tsrc: url("myfont.woff2") format("woff2");\n}',
- },
- {
- code: '@supports (animation-name: test) {\n\n\ta {\n\t\tcolor: aquamarine;\n\t}\n\n}',
- },
- {
- code: '@keyframes test {\n\n\t100% {\n\t\tcolor: aquamarine;\n\t}\n\n}',
- },
- ],
-
- reject: [
- {
- code: 'a {\n\tcolor: aquamarine;\n\n}',
- fixed: 'a {\n\tcolor: aquamarine;\n}',
- message: messages.rejected,
- line: 4,
- column: 1,
- },
- {
- code: '@media print {\n\n\ta {\n\t\tcolor: aquamarine;\n\t}\n}',
- fixed: '@media print {\n\n\ta {\n\t\tcolor: aquamarine;\n\t}\n\n}',
- message: messages.expected,
- line: 6,
- column: 1,
- },
- {
- code: '@media print {\n\n\ta {\n\t\tcolor: aquamarine;\n\t}\n\n\tb {\n\t\tcolor: hotpink;\n\t}\n}',
- fixed:
- '@media print {\n\n\ta {\n\t\tcolor: aquamarine;\n\t}\n\n\tb {\n\t\tcolor: hotpink;\n\t}\n\n}',
- warnings: [
- {
- message: messages.expected,
- line: 10,
- column: 1,
- },
- ],
- },
- {
- code: '@media print {\n\n\ta {\n\t\tcolor: aquamarine;\n\t}\n\n\tb {\n\t\tcolor: hotpink;\n\n\t}\n}',
- fixed:
- '@media print {\n\n\ta {\n\t\tcolor: aquamarine;\n\t}\n\n\tb {\n\t\tcolor: hotpink;\n\t}\n\n}',
- warnings: [
- {
- message: messages.rejected,
- line: 10,
- column: 2,
- },
- {
- message: messages.expected,
- line: 11,
- column: 1,
- },
- ],
- },
- {
- code: '@supports (animation-name: test) {\n\n\ta {\n\t\tcolor: aquamarine;\n\t}\n}',
- fixed: '@supports (animation-name: test) {\n\n\ta {\n\t\tcolor: aquamarine;\n\t}\n\n}',
- message: messages.expected,
- line: 6,
- column: 1,
- },
- {
- code: '@keyframes test {\n\n\t100% {\n\t\tcolor: aquamarine;\n\t}\n}',
- fixed: '@keyframes test {\n\n\t100% {\n\t\tcolor: aquamarine;\n\t}\n\n}',
- message: messages.expected,
- line: 6,
- column: 1,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['always-multi-line', { except: ['after-closing-brace'] }],
- fix: true,
-
- accept: [
- {
- code: 'a {\n\tcolor: aquamarine;\n\n}',
- },
- {
- code: 'a { color: aquamarine; }',
- },
- {
- code: '@media print {\n\n\ta {\n\t\tcolor: aquamarine;\n\n\t}\n}',
- },
- {
- code: '@font-face {\n\tfont-family: "MyFont";\n\tsrc: url("myfont.woff2") format("woff2");\n\n}',
- },
- {
- code: '@supports (animation-name: test) {\n\n\ta {\n\t\tcolor: aquamarine;\n\n\t}\n}',
- },
- {
- code: '@keyframes test {\n\n\t100% {\n\t\tcolor: aquamarine;\n\n\t}\n}',
- },
- ],
-
- reject: [
- {
- code: 'a {\n\tcolor: aquamarine;\n}',
- fixed: 'a {\n\tcolor: aquamarine;\n\n}',
- message: messages.expected,
- line: 3,
- column: 1,
- },
- {
- code: '@media print {\n\n\ta {\n\t\tcolor: aquamarine;\n\n\t}\n\n}',
- fixed: '@media print {\n\n\ta {\n\t\tcolor: aquamarine;\n\n\t}\n}',
- message: messages.rejected,
- line: 8,
- column: 1,
- },
- {
- code: '@media print {\n\n\ta {\n\t\tcolor: aquamarine;\n\n\t}\n\n\tb {\n\t\tcolor: hotpink;\n\n\t}\n\n}',
- fixed:
- '@media print {\n\n\ta {\n\t\tcolor: aquamarine;\n\n\t}\n\n\tb {\n\t\tcolor: hotpink;\n\n\t}\n}',
- message: messages.rejected,
- line: 13,
- column: 1,
- },
- {
- code: '@media print {\n\n\ta {\n\t\tcolor: aquamarine;\n\n\t}\n\n\tb {\n\t\tcolor: hotpink;\n\n\t}\n\n}',
- fixed:
- '@media print {\n\n\ta {\n\t\tcolor: aquamarine;\n\n\t}\n\n\tb {\n\t\tcolor: hotpink;\n\n\t}\n}',
- message: messages.rejected,
- line: 13,
- column: 1,
- },
- {
- code: '@supports (animation-name: test) {\n\n\ta {\n\t\tcolor: aquamarine;\n\n\t}\n\n}',
- fixed: '@supports (animation-name: test) {\n\n\ta {\n\t\tcolor: aquamarine;\n\n\t}\n}',
- message: messages.rejected,
- line: 8,
- column: 1,
- },
- {
- code: '@keyframes test {\n\n\t100% {\n\t\tcolor: aquamarine;\n\n\t}\n\n}',
- fixed: '@keyframes test {\n\n\t100% {\n\t\tcolor: aquamarine;\n\n\t}\n}',
- message: messages.rejected,
- line: 8,
- column: 1,
- },
- ],
-});
diff --git a/lib/rules/block-closing-brace-empty-line-before/index.js b/lib/rules/block-closing-brace-empty-line-before/index.js
deleted file mode 100644
index e33a1c398e..0000000000
--- a/lib/rules/block-closing-brace-empty-line-before/index.js
+++ /dev/null
@@ -1,129 +0,0 @@
-'use strict';
-
-const addEmptyLineAfter = require('../../utils/addEmptyLineAfter');
-const blockString = require('../../utils/blockString');
-const hasBlock = require('../../utils/hasBlock');
-const hasEmptyBlock = require('../../utils/hasEmptyBlock');
-const hasEmptyLine = require('../../utils/hasEmptyLine');
-const isSingleLineString = require('../../utils/isSingleLineString');
-const optionsMatches = require('../../utils/optionsMatches');
-const removeEmptyLinesAfter = require('../../utils/removeEmptyLinesAfter');
-const report = require('../../utils/report');
-const ruleMessages = require('../../utils/ruleMessages');
-const validateOptions = require('../../utils/validateOptions');
-
-const ruleName = 'block-closing-brace-empty-line-before';
-
-const messages = ruleMessages(ruleName, {
- expected: 'Expected empty line before closing brace',
- rejected: 'Unexpected empty line before closing brace',
-});
-
-const meta = {
- url: 'https://stylelint.io/user-guide/rules/block-closing-brace-empty-line-before',
- fixable: true,
- deprecated: true,
-};
-
-/** @type {import('stylelint').Rule} */
-const rule = (primary, secondaryOptions, context) => {
- return (root, result) => {
- const validOptions = validateOptions(
- result,
- ruleName,
- {
- actual: primary,
- possible: ['always-multi-line', 'never'],
- },
- {
- actual: secondaryOptions,
- possible: {
- except: ['after-closing-brace'],
- },
- optional: true,
- },
- );
-
- if (!validOptions) {
- return;
- }
-
- // Check both kinds of statements: rules and at-rules
- root.walkRules(check);
- root.walkAtRules(check);
-
- /**
- * @param {import('postcss').Rule | import('postcss').AtRule} statement
- */
- function check(statement) {
- // Return early if blockless or has empty block
- if (!hasBlock(statement) || hasEmptyBlock(statement)) {
- return;
- }
-
- // Get whitespace after ""}", ignoring extra semicolon
- const before = (statement.raws.after || '').replace(/;+/, '');
-
- // Calculate index
- const statementString = statement.toString();
- let index = statementString.length - 1;
-
- if (statementString[index - 1] === '\r') {
- index -= 1;
- }
-
- // Set expectation
- const expectEmptyLineBefore = (() => {
- const childNodeTypes = statement.nodes.map((item) => item.type);
-
- // Reverse the primary options if `after-closing-brace` is set
- if (
- optionsMatches(secondaryOptions, 'except', 'after-closing-brace') &&
- statement.type === 'atrule' &&
- !childNodeTypes.includes('decl')
- ) {
- return primary === 'never';
- }
-
- return primary === 'always-multi-line' && !isSingleLineString(blockString(statement));
- })();
-
- // Check for at least one empty line
- const hasEmptyLineBefore = hasEmptyLine(before);
-
- // Return if the expectation is met
- if (expectEmptyLineBefore === hasEmptyLineBefore) {
- return;
- }
-
- if (context.fix) {
- const { newline } = context;
-
- if (typeof newline !== 'string') return;
-
- if (expectEmptyLineBefore) {
- addEmptyLineAfter(statement, newline);
- } else {
- removeEmptyLinesAfter(statement, newline);
- }
-
- return;
- }
-
- const message = expectEmptyLineBefore ? messages.expected : messages.rejected;
-
- report({
- message,
- result,
- ruleName,
- node: statement,
- index,
- });
- }
- };
-};
-
-rule.ruleName = ruleName;
-rule.messages = messages;
-rule.meta = meta;
-module.exports = rule;
diff --git a/lib/rules/block-closing-brace-newline-after/README.md b/lib/rules/block-closing-brace-newline-after/README.md
deleted file mode 100644
index 939c7a84e5..0000000000
--- a/lib/rules/block-closing-brace-newline-after/README.md
+++ /dev/null
@@ -1,198 +0,0 @@
-# block-closing-brace-newline-after
-
-> **Warning** This rule is deprecated and will be removed in the future. See [the migration guide](../../../docs/migration-guide/to-15.md).
-
-Require a newline or disallow whitespace after the closing brace of blocks.
-
-
-```css
-a { color: pink; }
-a { color: red; }↑
-/** ↑
- * The newline after this brace */
-```
-
-This rule allows an end-of-line comment separated from the closing brace by spaces, as long as the comment contains no newlines. For example,
-
-
-```css
-a {
- color: pink;
-} /* end-of-line comment */
-```
-
-This rule allows a trailing semicolon after the closing brace of a block. For example,
-
-
-```css
-:root {
- --toolbar-theme: {
- background-color: hsl(120, 70%, 95%);
- };
-/* ↑
- * This semicolon */
-}
-```
-
-The [`fix` option](../../../docs/user-guide/options.md#fix) can automatically fix all of the problems reported by this rule.
-
-## Options
-
-`string`: `"always"|"always-single-line"|"never-single-line"|"always-multi-line"|"never-multi-line"`
-
-### `"always"`
-
-There _must always_ be a newline after the closing brace.
-
-The following patterns are considered problems:
-
-
-```css
-a { color: pink; }b { color: red; }
-```
-
-
-```css
-a { color: pink;
-} b { color: red; }
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { color: pink; }
-b { color: red; }
-```
-
-### `"always-single-line"`
-
-There _must always_ be a newline after the closing brace in single-line blocks.
-
-The following patterns are considered problems:
-
-
-```css
-a { color: pink; } b { color: red; }
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { color: pink;
-} b { color: red; }
-```
-
-
-```css
-a { color: pink; }
-b { color: red; }
-```
-
-### `"never-single-line"`
-
-There _must never_ be whitespace after the closing brace in single-line blocks.
-
-The following patterns are considered problems:
-
-
-```css
-a { color: pink; } b { color: red; }
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { color: pink; }b { color: red; }
-```
-
-
-```css
-a { color: pink;
-} b { color: red; }
-```
-
-### `"always-multi-line"`
-
-There _must always_ be a newline after the closing brace in multi-line blocks.
-
-The following patterns are considered problems:
-
-
-```css
-a { color: pink;
-}b { color: red; }
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { color: pink; }b { color: red; }
-```
-
-
-```css
-a { color: pink;
-}
-b { color: red; }
-```
-
-### `"never-multi-line"`
-
-There _must never_ be whitespace after the closing brace in multi-line blocks.
-
-The following patterns are considered problems:
-
-
-```css
-a { color: pink;
-} b { color: red; }
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { color: pink; } b { color: red; }
-```
-
-
-```css
-a { color: pink;
-}b { color: red; }
-```
-
-## Optional secondary options
-
-### `ignoreAtRules: ["/regex/", "non-regex"]`
-
-Ignore specified at-rules.
-
-For example, with `"always"` or `"always-multi-line"`.
-
-Given:
-
-```json
-["if", "else"]
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-@if ($var) {
- color: pink;
-} @else if ($var2) {
- color: red;
-} @else {
- color: blue;
-}
-```
-
-
-```css
-@if ($var) { color: pink; } @else { color: blue; }
-```
diff --git a/lib/rules/block-closing-brace-newline-after/__tests__/index.js b/lib/rules/block-closing-brace-newline-after/__tests__/index.js
deleted file mode 100644
index 0d16a8332c..0000000000
--- a/lib/rules/block-closing-brace-newline-after/__tests__/index.js
+++ /dev/null
@@ -1,518 +0,0 @@
-'use strict';
-
-const { messages, ruleName } = require('..');
-
-testRule({
- ruleName,
- config: ['always'],
- fix: true,
-
- accept: [
- {
- code: 'a { color: pink; }',
- },
- {
- code: 'a { color: pink; }\nb { color: red; }',
- },
- {
- code: 'a { color: pink; }\r\nb { color: red; }',
- description: 'CRLF',
- },
- {
- code: 'a { color: pink; }\n\nb { color: red; }',
- },
- {
- code: 'a { color: pink; }\r\n\r\nb { color: red; }',
- description: 'CRLF',
- },
- {
- code: 'a { color: pink;}\n\t\tb { color: red;}',
- },
- {
- code: 'a { color: pink;}\r\n\t\tb { color: red;}',
- description: 'CRLF',
- },
- {
- code: 'a { @extend foo; color: pink; }',
- },
- {
- code: 'a { @extend foo; /* comment */\ncolor: pink; }',
- },
- {
- code: '@media print { a { color: pink; }\nb { color: red; }}',
- },
- {
- code: '@media print { a { color: pink; }}\n@media screen { b { color: red; }}',
- },
- {
- code: '.a {} /* comment */',
- },
- {
- code: '.a {} /* comment */\n b {}',
- },
- {
- code: ':root {\n --x { color: pink; };\n --y { color: red; };\n }',
- description: 'Allow a trailing semicolon after the closing brace of a block',
- },
- {
- code: ':root {\n --x { color: pink; } ;\n --y { color: red; };\n }',
- description: 'Allow a spaced trailing semicolon after the closing brace of an at-apply block',
- },
- {
- code: '.foo {\n --my-theme: { color: red; };\n --toolbar-theme: { color: green; };\n }',
- description: 'Make sure trailing semicolon works well for blocks outside :root',
- },
- ],
-
- reject: [
- {
- code: 'a { color: pink; }b { color: red; }',
- fixed: 'a { color: pink; }\nb { color: red; }',
- message: messages.expectedAfter(),
- line: 1,
- column: 19,
- },
- {
- code: 'a { color: pink; } b { color: red; }',
- fixed: 'a { color: pink; }\n b { color: red; }',
- message: messages.expectedAfter(),
- line: 1,
- column: 19,
- },
- {
- code: 'a { color: pink; } b { color: red; }',
- fixed: 'a { color: pink; }\n b { color: red; }',
- message: messages.expectedAfter(),
- line: 1,
- column: 19,
- },
- {
- code: 'a { color: pink; }\tb { color: red; }',
- fixed: 'a { color: pink; }\n\tb { color: red; }',
- message: messages.expectedAfter(),
- line: 1,
- column: 19,
- },
- {
- code: '@media print { a { color: pink; } b { color: red; }}',
- fixed: '@media print { a { color: pink; }\n b { color: red; }}',
- message: messages.expectedAfter(),
- line: 1,
- column: 34,
- },
- {
- code: '@media print { a { color: pink; }} @media screen { b { color: red; }}',
- fixed: '@media print { a { color: pink; }}\n @media screen { b { color: red; }}',
- message: messages.expectedAfter(),
- line: 1,
- column: 35,
- },
- {
- code: '.a {} /* comment */ b {}',
- fixed: '.a {} /* comment */\n b {}',
- message: messages.expectedAfter(),
- line: 1,
- column: 6,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['always', { ignoreAtRules: ['if', 'else'] }],
- fix: true,
-
- accept: [
- {
- code: 'a { color: pink; }\nb {}',
- },
- {
- code: '@if ... { color: pink; } @else {}',
- },
- {
- code: '@if ... { color: pink; } @else if {} else {}',
- },
- {
- code: '@if ... {\r\n color: pink; \n} @else if {\n color: pink;\n} else {}',
- },
- ],
-
- reject: [
- {
- code: 'a { color: pink; }b{}',
- fixed: 'a { color: pink; }\nb{}',
- message: messages.expectedAfter(),
- line: 1,
- column: 19,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['always', { ignoreAtRules: '/if/' }],
- fix: true,
-
- accept: [
- {
- code: 'a { color: pink; }\nb {}',
- },
- {
- code: '@if ... { color: pink; } @else {}',
- },
- ],
-
- reject: [
- {
- code: 'a { color: pink; }b{}',
- fixed: 'a { color: pink; }\nb{}',
- message: messages.expectedAfter(),
- line: 1,
- column: 19,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['always-single-line'],
- fix: true,
-
- accept: [
- {
- code: 'a { color: pink; }',
- },
- {
- code: 'a { color: pink; }\nb { color: red; }',
- },
- {
- code: 'a { color: pink; }\r\nb { color: red; }',
- description: 'CRLF',
- },
- {
- code: 'a { color: pink;}\n\t\tb { color: red;}',
- },
- {
- code: 'a { color: pink;}\r\n\t\tb { color: red;}',
- description: 'CRLF',
- },
- {
- code: '@media print { a { color: pink; }\nb { color: red; }}',
- },
- {
- code: '@media print { a { color: pink; }}\n@media screen { b { color: red; }}',
- },
- {
- code: 'a { color: pink;\ntop: 0; }b { color: red; }',
- },
- {
- code: 'a { color: pink;\ntop: 0;}b { color: red;}',
- },
- {
- code: 'a { color: pink;\r\ntop: 0;}b { color: red;}',
- description: 'CRLF',
- },
- ],
-
- reject: [
- {
- code: 'a { color: pink; }b { color: red; }',
- fixed: 'a { color: pink; }\nb { color: red; }',
- message: messages.expectedAfterSingleLine(),
- line: 1,
- column: 19,
- },
- {
- code: 'a { color: pink; } b { color: red; }',
- fixed: 'a { color: pink; }\n b { color: red; }',
- message: messages.expectedAfterSingleLine(),
- line: 1,
- column: 19,
- },
- {
- code: 'a { color: pink; } b { color: red; }',
- fixed: 'a { color: pink; }\n b { color: red; }',
- message: messages.expectedAfterSingleLine(),
- line: 1,
- column: 19,
- },
- {
- code: 'a { color: pink; }\tb { color: red; }',
- fixed: 'a { color: pink; }\n\tb { color: red; }',
- message: messages.expectedAfterSingleLine(),
- line: 1,
- column: 19,
- },
- {
- code: '@media print { a { color: pink; } b { color: red; }}',
- fixed: '@media print { a { color: pink; }\n b { color: red; }}',
- message: messages.expectedAfterSingleLine(),
- line: 1,
- column: 34,
- },
- {
- code: '@media print { a { color: pink; }} @media screen { b { color: red; }}',
- fixed: '@media print { a { color: pink; }}\n @media screen { b { color: red; }}',
- message: messages.expectedAfterSingleLine(),
- line: 1,
- column: 35,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['never-single-line'],
- fix: true,
-
- accept: [
- {
- code: 'a { color: pink; }',
- },
- {
- code: 'a { color: pink; }b { color: red; }',
- },
- {
- code: 'a { color: pink;}b { color: red;}',
- },
- {
- code: '@media print { a { color: pink; }b { color: red; }}',
- },
- {
- code: '@media print { a { color: pink; }}@media screen { b { color: red; }}',
- },
- {
- code: 'a { color: pink;\ntop: 0; }\nb { color: red; }',
- },
- {
- code: 'a { color: pink;\ntop: 0;} b { color: red;}',
- },
- ],
-
- reject: [
- {
- code: 'a { color: pink; }\nb { color: red; }',
- fixed: 'a { color: pink; }b { color: red; }',
- message: messages.rejectedAfterSingleLine(),
- line: 1,
- column: 19,
- },
- {
- code: 'a { color: pink; } b { color: red; }',
- fixed: 'a { color: pink; }b { color: red; }',
- message: messages.rejectedAfterSingleLine(),
- line: 1,
- column: 19,
- },
- {
- code: 'a { color: pink; } b { color: red; }',
- fixed: 'a { color: pink; }b { color: red; }',
- message: messages.rejectedAfterSingleLine(),
- line: 1,
- column: 19,
- },
- {
- code: 'a { color: pink; }\tb { color: red; }',
- fixed: 'a { color: pink; }b { color: red; }',
- message: messages.rejectedAfterSingleLine(),
- line: 1,
- column: 19,
- },
- {
- code: '@media print { a { color: pink; }\nb { color: red; }}',
- fixed: '@media print { a { color: pink; }b { color: red; }}',
- message: messages.rejectedAfterSingleLine(),
- line: 1,
- column: 34,
- },
- {
- code: '@media print { a { color: pink; }}\n @media screen { b { color: red; }}',
- fixed: '@media print { a { color: pink; }}@media screen { b { color: red; }}',
- message: messages.rejectedAfterSingleLine(),
- line: 1,
- column: 35,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['always-multi-line'],
- fix: true,
-
- accept: [
- {
- code: 'a { color: pink;\ntop: 0; }',
- },
- {
- code: 'a { color: pink;\ntop: 0; }\nb { color: red; }',
- },
- {
- code: 'a { color: pink;\r\ntop: 0; }\r\nb { color: red; }',
- description: 'CRLF',
- },
- {
- code: 'a { color: pink;\ntop: 0;}\n\t\tb { color: red;}',
- },
- {
- code: '@media print { a {\ncolor: pink; }\nb { color: red; }}',
- },
- {
- code: '@media print { a {\ncolor: pink; }}\n@media screen { b { color: red; }}',
- },
- {
- code: 'a { color: pink; }\nb { color: red; }',
- },
- {
- code: 'a { color: pink; }b { color: red;}',
- },
- ],
-
- reject: [
- {
- code: 'a { color: pink;\ntop: 0; }b { color: red; }',
- fixed: 'a { color: pink;\ntop: 0; }\nb { color: red; }',
- message: messages.expectedAfterMultiLine(),
- line: 2,
- column: 10,
- },
- {
- code: 'a { color: pink;\r\ntop: 0; }b { color: red; }',
- fixed: 'a { color: pink;\r\ntop: 0; }\r\nb { color: red; }',
- description: 'CRLF',
- message: messages.expectedAfterMultiLine(),
- line: 2,
- column: 10,
- },
- {
- code: 'a { color: pink;\ntop: 0; } b { color: red; }',
- fixed: 'a { color: pink;\ntop: 0; }\n b { color: red; }',
- message: messages.expectedAfterMultiLine(),
- line: 2,
- column: 10,
- },
- {
- code: 'a { color: pink;\ntop: 0; } b { color: red; }',
- fixed: 'a { color: pink;\ntop: 0; }\n b { color: red; }',
- message: messages.expectedAfterMultiLine(),
- line: 2,
- column: 10,
- },
- {
- code: 'a { color: pink;\ntop: 0; }\tb { color: red; }',
- fixed: 'a { color: pink;\ntop: 0; }\n\tb { color: red; }',
- message: messages.expectedAfterMultiLine(),
- line: 2,
- column: 10,
- },
- {
- code: '@media print { a {\ncolor: pink; } b { color: red; }}',
- fixed: '@media print { a {\ncolor: pink; }\n b { color: red; }}',
- message: messages.expectedAfterMultiLine(),
- line: 2,
- column: 15,
- },
- {
- code: '@media print { a {\ncolor: pink; }} @media screen { b {\ncolor: red; }}',
- fixed: '@media print { a {\ncolor: pink; }}\n @media screen { b {\ncolor: red; }}',
- message: messages.expectedAfterMultiLine(),
- line: 2,
- column: 16,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['never-multi-line'],
- fix: true,
-
- accept: [
- {
- code: 'a { color: pink;\ntop: 0; }',
- },
- {
- code: 'a { color: pink;\ntop: 0; }b { color: red; }',
- },
- {
- code: 'a { color: pink;\ntop: 0;}b { color: red;}',
- },
- {
- code: 'a { color: pink;\r\ntop: 0;}b { color: red;}',
- description: 'CRLF',
- },
- {
- code: '@media print { a {\ncolor: pink; }b { color: red; }}',
- },
- {
- code: '@media print { a {\ncolor: pink; }}@media screen { b { color: red; }}',
- },
- {
- code: '@media print { a {\r\ncolor: pink; }}@media screen { b { color: red; }}',
- description: 'CRLF',
- },
- {
- code: 'a { color: pink; }\nb { color: red; }',
- },
- {
- code: 'a { color: pink; }\r\nb { color: red; }',
- description: 'CRLF',
- },
- {
- code: 'a { color: pink;} b { color: red;}',
- },
- ],
-
- reject: [
- {
- code: 'a { color: pink;\ntop: 0; }\nb { color: red; }',
- fixed: 'a { color: pink;\ntop: 0; }b { color: red; }',
- message: messages.rejectedAfterMultiLine(),
- line: 2,
- column: 10,
- },
- {
- code: 'a { color: pink;\r\ntop: 0; }\r\nb { color: red; }',
- fixed: 'a { color: pink;\r\ntop: 0; }b { color: red; }',
- description: 'CRLF',
- message: messages.rejectedAfterMultiLine(),
- line: 2,
- column: 10,
- },
- {
- code: 'a { color: pink;\ntop: 0; } b { color: red; }',
- fixed: 'a { color: pink;\ntop: 0; }b { color: red; }',
- message: messages.rejectedAfterMultiLine(),
- line: 2,
- column: 10,
- },
- {
- code: 'a { color: pink;\ntop: 0; } b { color: red; }',
- fixed: 'a { color: pink;\ntop: 0; }b { color: red; }',
- message: messages.rejectedAfterMultiLine(),
- line: 2,
- column: 10,
- },
- {
- code: 'a { color: pink;\ntop: 0; }\tb { color: red; }',
- fixed: 'a { color: pink;\ntop: 0; }b { color: red; }',
- message: messages.rejectedAfterMultiLine(),
- line: 2,
- column: 10,
- },
- {
- code: '@media print { a {\ncolor: pink; }\nb { color: red; }}',
- fixed: '@media print { a {\ncolor: pink; }b { color: red; }}',
- message: messages.rejectedAfterMultiLine(),
- line: 2,
- column: 15,
- },
- {
- code: '@media print { a {\ncolor: pink; }}\n@media screen { b {\ncolor: red; }}',
- fixed: '@media print { a {\ncolor: pink; }}@media screen { b {\ncolor: red; }}',
- message: messages.rejectedAfterMultiLine(),
- line: 2,
- column: 16,
- },
- ],
-});
diff --git a/lib/rules/block-closing-brace-newline-after/index.js b/lib/rules/block-closing-brace-newline-after/index.js
deleted file mode 100644
index 47a0495e13..0000000000
--- a/lib/rules/block-closing-brace-newline-after/index.js
+++ /dev/null
@@ -1,152 +0,0 @@
-'use strict';
-
-const blockString = require('../../utils/blockString');
-const hasBlock = require('../../utils/hasBlock');
-const optionsMatches = require('../../utils/optionsMatches');
-const rawNodeString = require('../../utils/rawNodeString');
-const report = require('../../utils/report');
-const ruleMessages = require('../../utils/ruleMessages');
-const validateOptions = require('../../utils/validateOptions');
-const whitespaceChecker = require('../../utils/whitespaceChecker');
-const { isString } = require('../../utils/validateTypes');
-
-const ruleName = 'block-closing-brace-newline-after';
-
-const messages = ruleMessages(ruleName, {
- expectedAfter: () => 'Expected newline after "}"',
- expectedAfterSingleLine: () => 'Expected newline after "}" of a single-line block',
- rejectedAfterSingleLine: () => 'Unexpected whitespace after "}" of a single-line block',
- expectedAfterMultiLine: () => 'Expected newline after "}" of a multi-line block',
- rejectedAfterMultiLine: () => 'Unexpected whitespace after "}" of a multi-line block',
-});
-
-const meta = {
- url: 'https://stylelint.io/user-guide/rules/block-closing-brace-newline-after',
- fixable: true,
- deprecated: true,
-};
-
-/** @type {import('stylelint').Rule} */
-const rule = (primary, secondaryOptions, context) => {
- const checker = whitespaceChecker('newline', primary, messages);
-
- return (root, result) => {
- const validOptions = validateOptions(
- result,
- ruleName,
- {
- actual: primary,
- possible: [
- 'always',
- 'always-single-line',
- 'never-single-line',
- 'always-multi-line',
- 'never-multi-line',
- ],
- },
- {
- actual: secondaryOptions,
- possible: {
- ignoreAtRules: [isString],
- },
- optional: true,
- },
- );
-
- if (!validOptions) {
- return;
- }
-
- // Check both kinds of statements: rules and at-rules
- root.walkRules(check);
- root.walkAtRules(check);
-
- /**
- * @param {import('postcss').Rule | import('postcss').AtRule} statement
- */
- function check(statement) {
- if (!hasBlock(statement)) {
- return;
- }
-
- if (
- statement.type === 'atrule' &&
- optionsMatches(secondaryOptions, 'ignoreAtRules', statement.name)
- ) {
- return;
- }
-
- const nextNode = statement.next();
-
- if (!nextNode) {
- return;
- }
-
- // Allow an end-of-line comment x spaces after the brace
- const nextNodeIsSingleLineComment =
- nextNode.type === 'comment' &&
- !/[^ ]/.test(nextNode.raws.before || '') &&
- !nextNode.toString().includes('\n');
-
- const nodeToCheck = nextNodeIsSingleLineComment ? nextNode.next() : nextNode;
-
- if (!nodeToCheck) {
- return;
- }
-
- let reportIndex = statement.toString().length;
- let source = rawNodeString(nodeToCheck);
-
- // Skip a semicolon at the beginning, if any
- if (source && source.startsWith(';')) {
- source = source.slice(1);
- reportIndex++;
- }
-
- // Only check one after, because there might be other
- // spaces handled by the indentation rule
- checker.afterOneOnly({
- source,
- index: -1,
- lineCheckStr: blockString(statement),
- err: (msg) => {
- if (context.fix) {
- const nodeToCheckRaws = nodeToCheck.raws;
-
- if (typeof nodeToCheckRaws.before !== 'string') return;
-
- if (primary.startsWith('always')) {
- const index = nodeToCheckRaws.before.search(/\r?\n/);
-
- nodeToCheckRaws.before =
- index >= 0
- ? nodeToCheckRaws.before.slice(index)
- : context.newline + nodeToCheckRaws.before;
-
- return;
- }
-
- if (primary.startsWith('never')) {
- nodeToCheckRaws.before = '';
-
- return;
- }
- }
-
- report({
- message: msg,
- node: statement,
- index: reportIndex,
- result,
- ruleName,
- });
- },
- });
- }
- };
-};
-
-rule.ruleName = ruleName;
-rule.messages = messages;
-rule.meta = meta;
-module.exports = rule;
diff --git a/lib/rules/block-closing-brace-newline-before/README.md b/lib/rules/block-closing-brace-newline-before/README.md
deleted file mode 100644
index 936ba1978e..0000000000
--- a/lib/rules/block-closing-brace-newline-before/README.md
+++ /dev/null
@@ -1,95 +0,0 @@
-# block-closing-brace-newline-before
-
-> **Warning** This rule is deprecated and will be removed in the future. See [the migration guide](../../../docs/migration-guide/to-15.md).
-
-Require a newline or disallow whitespace before the closing brace of blocks.
-
-
-```css
- a { color: pink;
- }
-/** ↑
- * The newline before this brace */
-```
-
-The [`fix` option](../../../docs/user-guide/options.md#fix) can automatically fix all of the problems reported by this rule.
-
-## Options
-
-`string`: `"always"|"always-multi-line"|"never-multi-line"`
-
-### `"always"`
-
-There _must always_ be a newline before the closing brace.
-
-The following patterns are considered problems:
-
-
-```css
-a { color: pink;}
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { color: pink;
-}
-```
-
-
-```css
-a {
-color: pink;
-}
-```
-
-### `"always-multi-line"`
-
-There _must always_ be a newline before the closing brace in multi-line blocks.
-
-The following patterns are considered problems:
-
-
-```css
-a {
-color: pink;}
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { color: pink; }
-```
-
-
-```css
-a { color: pink;
-}
-```
-
-### `"never-multi-line"`
-
-There _must never_ be whitespace before the closing brace in multi-line blocks.
-
-The following patterns are considered problems:
-
-
-```css
-a {
-color: pink; }
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { color: pink; }
-```
-
-
-```css
-a {
-color: pink;}
-```
diff --git a/lib/rules/block-closing-brace-newline-before/__tests__/index.js b/lib/rules/block-closing-brace-newline-before/__tests__/index.js
deleted file mode 100644
index 8c4f3ef8a1..0000000000
--- a/lib/rules/block-closing-brace-newline-before/__tests__/index.js
+++ /dev/null
@@ -1,386 +0,0 @@
-'use strict';
-
-const { messages, ruleName } = require('..');
-
-testRule({
- ruleName,
- config: ['always'],
- fix: true,
-
- accept: [
- {
- code: 'a { color: pink;\n}',
- },
- {
- code: 'a { color: pink;;\n}',
- },
- {
- code: 'a { color: pink;;;\n}',
- },
- {
- code: 'a { color: pink;\r\n}',
- description: 'CRLF',
- },
- {
- code: 'a { color: pink;\n\n}',
- },
- {
- code: 'a { color: pink;\r\n\r\n}',
- description: 'CRLF',
- },
- {
- code: 'a { color: pink;\n\t\t}',
- },
- {
- code: 'a { color: pink;\n} b { color: red;\n}',
- },
- {
- code: 'a { color: pink;\n}b { color: red;\n}',
- },
- {
- code: '@media print {\n a {\n color: pink;\n }\n}',
- description: 'indentation after the newline before the closing braces',
- },
- {
- code: '@media print {\n\ta {\n\t\tcolor: pink;\n\t\t{\n\t\t\t&:hover;\n\t\t\t}\n\t\t}\n}',
- description:
- '3 level deep nesting with indentation after the newline before the closing braces',
- },
- ],
-
- reject: [
- {
- code: 'a { color: pink;}',
- fixed: 'a { color: pink;\n}',
- message: messages.expectedBefore,
- line: 1,
- column: 16,
- },
- {
- code: 'a { color: pink;;}',
- fixed: 'a { color: pink;;\n}',
- message: messages.expectedBefore,
- line: 1,
- column: 17,
- },
- {
- code: 'a { color: pink; }',
- fixed: 'a { color: pink;\n }',
- message: messages.expectedBefore,
- line: 1,
- column: 17,
- },
- {
- code: 'a { color: pink; \n}',
- fixed: 'a { color: pink;\n}',
- message: messages.expectedBefore,
- line: 1,
- column: 18,
- },
- {
- code: 'a { color: pink; \r\n}',
- fixed: 'a { color: pink;\r\n}',
- description: 'CRLF',
- message: messages.expectedBefore,
- line: 1,
- column: 18,
- },
- {
- code: 'a { color: pink; }',
- fixed: 'a { color: pink;\n }',
- message: messages.expectedBefore,
- line: 1,
- column: 18,
- },
- {
- code: 'a { color: pink;\t}',
- fixed: 'a { color: pink;\n\t}',
- message: messages.expectedBefore,
- line: 1,
- column: 17,
- },
- {
- code: 'a { color: pink;\n} b { color: red; }',
- fixed: 'a { color: pink;\n} b { color: red;\n }',
- message: messages.expectedBefore,
- line: 2,
- column: 18,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['always-multi-line'],
- fix: true,
-
- accept: [
- {
- code: 'a { color: pink;\ntop: 0;\n}',
- },
- {
- code: 'a { color: pink;\r\ntop: 0;\r\n}',
- description: 'CRLF',
- },
- {
- code: 'a { color: pink;;\ntop: 0;;\n}',
- },
- {
- code: 'a { color: pink;;\r\ntop: 0;;\r\n}',
- description: 'CRLF',
- },
- {
- code: 'a { color: pink;;;\ntop: 0;;;\n}',
- },
- {
- code: 'a { color: pink;;;\r\ntop: 0;;;\r\n}',
- description: 'CRLF',
- },
- {
- code: 'a { color: pink;\ntop: 0;\n\t\t}',
- },
- {
- code: 'a { color: pink;\r\ntop: 0;\r\n\t\t}',
- description: 'CRLF',
- },
- {
- code: 'a { color: pink;\ntop: 0;\n} b { color: red;\n}',
- },
- {
- code: 'a { color: pink;\ntop: 0;\n}b { color: red;\n}',
- },
- {
- code: 'a { color: pink;}',
- },
- {
- code: 'a { color: pink;;}',
- },
- {
- code: 'a { color: pink;;;}',
- },
- {
- code: 'a { color: pink;} b { color: red;}',
- },
- {
- code: 'a { color: pink;}b { color: red;}',
- },
- ],
-
- reject: [
- {
- code: 'a { color: pink;\ntop: 0;}',
- fixed: 'a { color: pink;\ntop: 0;\n}',
- message: messages.expectedBeforeMultiLine,
- line: 2,
- column: 7,
- },
- {
- code: 'a { color: pink;\r\ntop: 0;}',
- fixed: 'a { color: pink;\r\ntop: 0;\r\n}',
- description: 'CRLF',
- message: messages.expectedBeforeMultiLine,
- line: 2,
- column: 7,
- },
- {
- code: 'a { color: pink;;\ntop: 0;;}',
- fixed: 'a { color: pink;;\ntop: 0;;\n}',
- message: messages.expectedBeforeMultiLine,
- line: 2,
- column: 8,
- },
- {
- code: 'a { color: pink;;\r\ntop: 0;;}',
- fixed: 'a { color: pink;;\r\ntop: 0;;\r\n}',
- description: 'CRLF',
- message: messages.expectedBeforeMultiLine,
- line: 2,
- column: 8,
- },
- {
- code: 'a { color: pink;;;\ntop: 0;;;}',
- fixed: 'a { color: pink;;;\ntop: 0;;;\n}',
- message: messages.expectedBeforeMultiLine,
- line: 2,
- column: 9,
- },
- {
- code: 'a { color: pink;;;\r\ntop: 0;;;}',
- fixed: 'a { color: pink;;;\r\ntop: 0;;;\r\n}',
- description: 'CRLF',
- message: messages.expectedBeforeMultiLine,
- line: 2,
- column: 9,
- },
- {
- code: 'a { color: pink;\ntop: 0; }',
- fixed: 'a { color: pink;\ntop: 0;\n }',
- message: messages.expectedBeforeMultiLine,
- line: 2,
- column: 8,
- },
- {
- code: 'a { color: pink;\ntop: 0; \n}',
- fixed: 'a { color: pink;\ntop: 0;\n}',
- message: messages.expectedBeforeMultiLine,
- line: 2,
- column: 9,
- },
- {
- code: 'a { color: pink;\ntop: 0; }',
- fixed: 'a { color: pink;\ntop: 0;\n }',
- message: messages.expectedBeforeMultiLine,
- line: 2,
- column: 9,
- },
- {
- code: 'a { color: pink;\ntop: 0;\t}',
- fixed: 'a { color: pink;\ntop: 0;\n\t}',
- message: messages.expectedBeforeMultiLine,
- line: 2,
- column: 8,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['never-multi-line'],
- fix: true,
-
- accept: [
- {
- code: 'a { color: pink;\ntop: 0;}',
- },
- {
- code: 'a { color: pink;\r\ntop: 0;}',
- description: 'CRLF',
- },
- {
- code: 'a { color: pink;;\ntop: 0;;}',
- },
- {
- code: 'a { color: pink;;\r\ntop: 0;;}',
- description: 'CRLF',
- },
- {
- code: 'a { color: pink;;;\ntop: 0;;;}',
- },
- {
- code: 'a { color: pink;;;\r\ntop: 0;;;}',
- description: 'CRLF',
- },
- {
- code: 'a { color: pink;\ntop: 0;} b { color: red;\ntop: 0;}',
- },
- {
- code: 'a { color: pink;\ntop: 0;}b { color: red;\ntop: 0;}',
- },
- {
- code: 'a { color: pink; }',
- },
- {
- code: 'a { color: pink;\t}',
- },
- {
- code: 'a { color: pink; }',
- },
- ],
-
- reject: [
- {
- code: 'a { color: pink;\ntop: 0; }',
- fixed: 'a { color: pink;\ntop: 0;}',
- message: messages.rejectedBeforeMultiLine,
- line: 2,
- column: 8,
- },
- {
- code: 'a { color: pink;\r\ntop: 0; }',
- fixed: 'a { color: pink;\r\ntop: 0;}',
- description: 'CRLF',
- message: messages.rejectedBeforeMultiLine,
- line: 2,
- column: 8,
- },
- {
- code: 'a { color: pink;;\ntop: 0;; }',
- fixed: 'a { color: pink;;\ntop: 0;;}',
- message: messages.rejectedBeforeMultiLine,
- line: 2,
- column: 9,
- },
- {
- code: 'a { color: pink;;\r\ntop: 0;; }',
- fixed: 'a { color: pink;;\r\ntop: 0;;}',
- description: 'CRLF',
- message: messages.rejectedBeforeMultiLine,
- line: 2,
- column: 9,
- },
- {
- code: 'a { color: pink;;;\ntop: 0;;; }',
- fixed: 'a { color: pink;;;\ntop: 0;;;}',
- message: messages.rejectedBeforeMultiLine,
- line: 2,
- column: 10,
- },
- {
- code: 'a { color: pink;;;\r\ntop: 0;;; }',
- fixed: 'a { color: pink;;;\r\ntop: 0;;;}',
- description: 'CRLF',
- message: messages.rejectedBeforeMultiLine,
- line: 2,
- column: 10,
- },
- {
- code: 'a { color: pink;\ntop: 0;\n}',
- fixed: 'a { color: pink;\ntop: 0;}',
- message: messages.rejectedBeforeMultiLine,
- line: 2,
- column: 8,
- },
- {
- code: 'a { color: pink;\ntop: 0; }',
- fixed: 'a { color: pink;\ntop: 0;}',
- message: messages.rejectedBeforeMultiLine,
- line: 2,
- column: 9,
- },
- {
- code: 'a { color: pink;\ntop: 0;\t}',
- fixed: 'a { color: pink;\ntop: 0;}',
- message: messages.rejectedBeforeMultiLine,
- line: 2,
- column: 8,
- },
- {
- code: 'a { color: pink;\ntop: 0;} b { color: red;\ntop: 0;\n}',
- fixed: 'a { color: pink;\ntop: 0;} b { color: red;\ntop: 0;}',
- message: messages.rejectedBeforeMultiLine,
- line: 3,
- column: 8,
- },
- {
- code: 'a { color: pink;;;\ntop: 0; ;;}',
- fixed: 'a { color: pink;;;\ntop: 0;;;}',
- message: messages.rejectedBeforeMultiLine,
- line: 2,
- column: 10,
- },
- {
- code: 'a { color: pink;;;\ntop: 0;; ;}',
- fixed: 'a { color: pink;;;\ntop: 0;;;}',
- message: messages.rejectedBeforeMultiLine,
- line: 2,
- column: 10,
- },
- {
- code: 'a { color: pink;;;\ntop: 0; ; ; }',
- fixed: 'a { color: pink;;;\ntop: 0;;;}',
- message: messages.rejectedBeforeMultiLine,
- line: 2,
- column: 12,
- },
- ],
-});
diff --git a/lib/rules/block-closing-brace-newline-before/index.js b/lib/rules/block-closing-brace-newline-before/index.js
deleted file mode 100644
index e6f96aad9b..0000000000
--- a/lib/rules/block-closing-brace-newline-before/index.js
+++ /dev/null
@@ -1,132 +0,0 @@
-'use strict';
-
-const blockString = require('../../utils/blockString');
-const hasBlock = require('../../utils/hasBlock');
-const hasEmptyBlock = require('../../utils/hasEmptyBlock');
-const isSingleLineString = require('../../utils/isSingleLineString');
-const report = require('../../utils/report');
-const ruleMessages = require('../../utils/ruleMessages');
-const validateOptions = require('../../utils/validateOptions');
-
-const ruleName = 'block-closing-brace-newline-before';
-
-const messages = ruleMessages(ruleName, {
- expectedBefore: 'Expected newline before "}"',
- expectedBeforeMultiLine: 'Expected newline before "}" of a multi-line block',
- rejectedBeforeMultiLine: 'Unexpected whitespace before "}" of a multi-line block',
-});
-
-const meta = {
- url: 'https://stylelint.io/user-guide/rules/block-closing-brace-newline-before',
- fixable: true,
- deprecated: true,
-};
-
-/** @type {import('stylelint').Rule} */
-const rule = (primary, _secondaryOptions, context) => {
- return (root, result) => {
- const validOptions = validateOptions(result, ruleName, {
- actual: primary,
- possible: ['always', 'always-multi-line', 'never-multi-line'],
- });
-
- if (!validOptions) {
- return;
- }
-
- // Check both kinds of statements: rules and at-rules
- root.walkRules(check);
- root.walkAtRules(check);
-
- /**
- * @param {import('postcss').Rule | import('postcss').AtRule} statement
- */
- function check(statement) {
- // Return early if blockless or has empty block
- if (!hasBlock(statement) || hasEmptyBlock(statement)) {
- return;
- }
-
- // Ignore extra semicolon
- const after = (statement.raws.after || '').replace(/;+/, '');
-
- if (after === undefined) {
- return;
- }
-
- const blockIsMultiLine = !isSingleLineString(blockString(statement));
- const statementString = statement.toString();
-
- let index = statementString.length - 2;
-
- if (statementString[index - 1] === '\r') {
- index -= 1;
- }
-
- // We're really just checking whether a
- // newline *starts* the block's final space -- between
- // the last declaration and the closing brace. We can
- // ignore any other whitespace between them, because that
- // will be checked by the indentation rule.
- if (!after.startsWith('\n') && !after.startsWith('\r\n')) {
- if (primary === 'always') {
- complain(messages.expectedBefore);
- } else if (blockIsMultiLine && primary === 'always-multi-line') {
- complain(messages.expectedBeforeMultiLine);
- }
- }
-
- if (after !== '' && blockIsMultiLine && primary === 'never-multi-line') {
- complain(messages.rejectedBeforeMultiLine);
- }
-
- /**
- * @param {string} message
- */
- function complain(message) {
- if (context.fix) {
- const statementRaws = statement.raws;
-
- if (typeof statementRaws.after !== 'string') return;
-
- if (primary.startsWith('always')) {
- const firstWhitespaceIndex = statementRaws.after.search(/\s/);
- const newlineBefore =
- firstWhitespaceIndex >= 0
- ? statementRaws.after.slice(0, firstWhitespaceIndex)
- : statementRaws.after;
- const newlineAfter =
- firstWhitespaceIndex >= 0 ? statementRaws.after.slice(firstWhitespaceIndex) : '';
- const newlineIndex = newlineAfter.search(/\r?\n/);
-
- statementRaws.after =
- newlineIndex >= 0
- ? newlineBefore + newlineAfter.slice(newlineIndex)
- : newlineBefore + context.newline + newlineAfter;
-
- return;
- }
-
- if (primary === 'never-multi-line') {
- statementRaws.after = statementRaws.after.replace(/\s/g, '');
-
- return;
- }
- }
-
- report({
- message,
- result,
- ruleName,
- node: statement,
- index,
- });
- }
- }
- };
-};
-
-rule.ruleName = ruleName;
-rule.messages = messages;
-rule.meta = meta;
-module.exports = rule;
diff --git a/lib/rules/block-closing-brace-space-after/README.md b/lib/rules/block-closing-brace-space-after/README.md
deleted file mode 100644
index b566960f96..0000000000
--- a/lib/rules/block-closing-brace-space-after/README.md
+++ /dev/null
@@ -1,181 +0,0 @@
-# block-closing-brace-space-after
-
-> **Warning** This rule is deprecated and will be removed in the future. See [the migration guide](../../../docs/migration-guide/to-15.md).
-
-Require a single space or disallow whitespace after the closing brace of blocks.
-
-
-```css
-a { color: pink; }
-/** ↑
- * The space after this brace */
-```
-
-This rule allows a trailing semicolon after the closing brace of a block. For example,
-
-
-```css
-:root {
- --toolbar-theme: {
- background-color: hsl(120, 70%, 95%);
- };
-/* ↑
- * This semicolon */
-}
-```
-
-## Options
-
-`string`: `"always"|"never"|"always-single-line"|"never-single-line"|"always-multi-line"|"never-multi-line"`
-
-### `"always"`
-
-There _must always_ be a single space after the closing brace.
-
-The following patterns are considered problems:
-
-
-```css
-a { color: pink; }b { color: red; }
-```
-
-
-```css
-a { color: pink; }
-b { color: red; }
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { color: pink; } b { color: red; }
-```
-
-### `"never"`
-
-There _must never_ be whitespace after the closing brace.
-
-The following patterns are considered problems:
-
-
-```css
-a { color: pink; } b { color: red; }
-```
-
-
-```css
-a { color: pink; }
-b { color: red; }
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { color: pink; }b { color: red; }
-```
-
-
-```css
-a { color: pink;
-}b { color: red; }
-```
-
-### `"always-single-line"`
-
-There _must always_ be a single space after the closing brace in single-line blocks.
-
-The following patterns are considered problems:
-
-
-```css
-a { color: pink; }b { color: red; }
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { color: pink; } b { color: red; }
-```
-
-
-```css
-a { color: pink;
-}b { color: red; }
-```
-
-### `"never-single-line"`
-
-There _must never_ be whitespace after the closing brace in single-line blocks.
-
-The following patterns are considered problems:
-
-
-```css
-a { color: pink; } b { color: red; }
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { color: pink; }b { color: red; }
-```
-
-
-```css
-a { color: pink;
-} b { color: red; }
-```
-
-### `"always-multi-line"`
-
-There _must always_ be a single space after the closing brace in multi-line blocks.
-
-The following patterns are considered problems:
-
-
-```css
-a { color: pink;
-}b { color: red; }
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { color: pink; }b { color: red; }
-```
-
-
-```css
-a { color: pink;
-} b { color: red; }
-```
-
-### `"never-multi-line"`
-
-There _must never_ be whitespace after the closing brace in multi-line blocks.
-
-The following patterns are considered problems:
-
-
-```css
-a { color: pink;
-} b { color: red; }
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { color: pink; } b { color: red; }
-```
-
-
-```css
-a { color: pink;
-}b { color: red; }
-```
diff --git a/lib/rules/block-closing-brace-space-after/__tests__/index.js b/lib/rules/block-closing-brace-space-after/__tests__/index.js
deleted file mode 100644
index 6f5f57af60..0000000000
--- a/lib/rules/block-closing-brace-space-after/__tests__/index.js
+++ /dev/null
@@ -1,472 +0,0 @@
-'use strict';
-
-const { messages, ruleName } = require('..');
-
-testRule({
- ruleName,
- config: ['always'],
-
- accept: [
- {
- code: 'a { color: pink; }',
- },
- {
- code: 'a { color: pink; } b { color: red; }',
- },
- {
- code: 'a { color: pink;} b { color: red;}',
- },
- {
- code: '@media print { a { color: pink; } b { color: red; } }',
- },
- {
- code: '@media print { a { color: pink; } } @media screen { b { color: red; } }',
- },
- {
- code: "@import 'foo.css';\n@import 'bar.css';",
- description: 'two blockless statements',
- },
- {
- code: '@media print { a { color: pink; } b { color: red; }}',
- },
- {
- code: '@media print { a { color: pink; }} @media screen { b { color: red; }}',
- },
- {
- code: '.a {} /* stylelint-disable-line block-no-empty */',
- },
- ],
-
- reject: [
- {
- code: 'a { color: pink; }b { color: red; }',
- message: messages.expectedAfter(),
- line: 1,
- column: 19,
- },
- {
- code: 'a { color: pink; } b { color: red; }',
- message: messages.expectedAfter(),
- line: 1,
- column: 19,
- },
- {
- code: 'a { color: pink; }\nb { color: red; }',
- message: messages.expectedAfter(),
- line: 1,
- column: 19,
- },
- {
- code: 'a { color: pink; }\r\nb { color: red; }',
- description: 'CRLF',
- message: messages.expectedAfter(),
- line: 1,
- column: 19,
- },
- {
- code: 'a { color: pink; }\tb { color: red; }',
- message: messages.expectedAfter(),
- line: 1,
- column: 19,
- },
- {
- code: '@media print { a { color: pink; }b { color: red; }}',
- message: messages.expectedAfter(),
- line: 1,
- column: 34,
- },
- {
- code: '@media print { a { color: pink; }}@media screen { b { color: red; }}',
- message: messages.expectedAfter(),
- line: 1,
- column: 35,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['never'],
-
- accept: [
- {
- code: 'a { color: pink; }',
- },
- {
- code: 'a { color: pink; }b { color: red; }',
- },
- {
- code: 'a { color: pink;}b { color: red;}',
- },
- {
- code: '@media print { a { color: pink; }b { color: red; } }',
- },
- {
- code: '@media print { a { color: pink; } }@media screen { b { color: red; } }',
- },
- ],
-
- reject: [
- {
- code: 'a { color: pink; } b { color: red; }',
- message: messages.rejectedAfter(),
- line: 1,
- column: 19,
- },
- {
- code: 'a { color: pink; } b { color: red; }',
- message: messages.rejectedAfter(),
- line: 1,
- column: 19,
- },
- {
- code: 'a { color: pink; }\nb { color: red; }',
- message: messages.rejectedAfter(),
- line: 1,
- column: 19,
- },
- {
- code: 'a { color: pink; }\r\nb { color: red; }',
- description: 'CRLF',
- message: messages.rejectedAfter(),
- line: 1,
- column: 19,
- },
- {
- code: 'a { color: pink; }\tb { color: red; }',
- message: messages.rejectedAfter(),
- line: 1,
- column: 19,
- },
- {
- code: '@media print { a { color: pink; } b { color: red; }}',
- message: messages.rejectedAfter(),
- line: 1,
- column: 34,
- },
- {
- code: '@media print { a { color: pink; }} @media screen { b { color: red; }}',
- message: messages.rejectedAfter(),
- line: 1,
- column: 35,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['always-single-line'],
-
- accept: [
- {
- code: 'a { color: pink; background: orange; }',
- },
- {
- code: 'a { color: pink; background: orange; } b { color: red; }',
- },
- {
- code: 'a { color: pink; background: orange;} b { color: red;}',
- },
- {
- code: 'a { color:\npink;}',
- },
- {
- code: 'a { color:\r\npink;}',
- description: 'CRLF',
- },
- {
- code: 'a { color:\npink;}b { color: red; }',
- },
- {
- code: 'a { color:\npink;}b { color:\nred;}',
- },
- {
- code: '@media print { a {\ncolor: pink; } b { color: red;}}',
- },
- {
- code: '@media print { a {\ncolor: pink; }} @media screen { b { color: red;}}',
- },
- {
- code: '@media print { a {\r\ncolor: pink; }} @media screen { b { color: red;}}',
- description: 'CRLF',
- },
- ],
-
- reject: [
- {
- code: 'a { color: pink; background: orange;}b { color: red; }',
- message: messages.expectedAfterSingleLine(),
- line: 1,
- column: 38,
- },
- {
- code: 'a { color: pink; background: orange;} b { color: red; }',
- message: messages.expectedAfterSingleLine(),
- line: 1,
- column: 38,
- },
- {
- code: 'a { color: pink; background: orange;}\tb { color: red; }',
- message: messages.expectedAfterSingleLine(),
- line: 1,
- column: 38,
- },
- {
- code: '@media print { a { color: pink; }b { color: red; }}',
- message: messages.expectedAfterSingleLine(),
- line: 1,
- column: 34,
- },
- {
- code: '@media print { a { color: pink; }}@media screen { b { color: red; }}',
- message: messages.expectedAfterSingleLine(),
- line: 1,
- column: 35,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['never-single-line'],
-
- accept: [
- {
- code: 'a { color: pink; background: orange; }',
- },
- {
- code: 'a { color: pink; background: orange; }b { color: red; }',
- },
- {
- code: 'a { color: pink; background: orange;}b { color: red;}',
- },
- {
- code: 'a { color:\npink;}',
- },
- {
- code: 'a { color:\r\npink;}',
- description: 'CRLF',
- },
- {
- code: 'a { color:\npink;} b { color: red; }',
- },
- {
- code: 'a { color:\npink;} b { color:\nred;}',
- },
- {
- code: '@media print { a {\ncolor: pink;} b { color: red;} }',
- },
- {
- code: '@media print { a {\r\ncolor: pink;} b { color: red;} }',
- description: 'CRLF',
- },
- {
- code: '@media print { a {\ncolor: pink;} } @media screen { b { color: red;} }',
- },
- ],
-
- reject: [
- {
- code: 'a { color: pink; background: orange;} b { color: red; }',
- message: messages.rejectedAfterSingleLine(),
- line: 1,
- column: 38,
- },
- {
- code: 'a { color: pink; background: orange;} b { color: red; }',
- message: messages.rejectedAfterSingleLine(),
- line: 1,
- column: 38,
- },
- {
- code: 'a { color: pink; background: orange;}\tb { color: red; }',
- message: messages.rejectedAfterSingleLine(),
- line: 1,
- column: 38,
- },
- {
- code: '@media print { a { color: pink; } b { color: red; }}',
- message: messages.rejectedAfterSingleLine(),
- line: 1,
- column: 34,
- },
- {
- code: '@media print { a { color: pink; }} @media screen { b { color: red; }}',
- message: messages.rejectedAfterSingleLine(),
- line: 1,
- column: 35,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['always-multi-line'],
-
- accept: [
- {
- code: 'a { color: pink;\nbackground: orange; }',
- },
- {
- code: 'a { color: pink;\r\nbackground: orange; }',
- description: 'CRLF',
- },
- {
- code: 'a { color: pink;\nbackground: orange; } b { color: red; }',
- },
- {
- code: 'a { color: pink;\nbackground: orange;} b { color: red;}',
- },
- {
- code: 'a { color: pink; }',
- },
- {
- code: 'a { color: pink; }b { color: red; }',
- },
- {
- code: 'a { color: pink;}b { color: red;}',
- },
- {
- code: '@media print { a {\ncolor: pink; } b { color: red; }}',
- },
- {
- code: '@media print { a {\r\ncolor: pink; } b { color: red; }}',
- description: 'CRLF',
- },
- {
- code: '@media print { a {\ncolor: pink; }} @media screen { b { color: red; }}',
- },
- ],
-
- reject: [
- {
- code: 'a { color: pink;\nbackground: orange;}b { color: red; }',
- message: messages.expectedAfterMultiLine(),
- line: 2,
- column: 21,
- },
- {
- code: 'a { color: pink;\nbackground: orange;} b { color: red; }',
- message: messages.expectedAfterMultiLine(),
- line: 2,
- column: 21,
- },
- {
- code: 'a { color: pink;\nbackground: orange;}\nb { color: red; }',
- message: messages.expectedAfterMultiLine(),
- line: 2,
- column: 21,
- },
- {
- code: 'a { color: pink;\r\nbackground: orange;}\r\nb { color: red; }',
- description: 'CRLF',
- message: messages.expectedAfterMultiLine(),
- line: 2,
- column: 21,
- },
- {
- code: 'a { color: pink;\nbackground: orange;}\tb { color: red; }',
- message: messages.expectedAfterMultiLine(),
- line: 2,
- column: 21,
- },
- {
- code: '@media print { a {\ncolor: pink; }b { color: red; }}',
- message: messages.expectedAfterMultiLine(),
- line: 2,
- column: 15,
- },
- {
- code: '@media print { a {\ncolor: pink; }}@media screen { b {\ncolor: red; }}',
- message: messages.expectedAfterMultiLine(),
- line: 2,
- column: 16,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['never-multi-line'],
-
- accept: [
- {
- code: 'a { color: pink;\nbackground: orange; }',
- },
- {
- code: 'a { color: pink;\r\nbackground: orange; }',
- description: 'CRLF',
- },
- {
- code: 'a { color: pink;\nbackground: orange; }b { color: red; }',
- },
- {
- code: 'a { color: pink;\nbackground: orange;}b { color: red;}',
- },
- {
- code: 'a { color: pink; }',
- },
- {
- code: 'a { color: pink; } b { color: red; }',
- },
- {
- code: 'a { color: pink;} b { color: red;}',
- },
- {
- code: '@media print { a {\ncolor: pink; }b { color: red; } }',
- },
- {
- code: '@media print { a {\r\ncolor: pink; }b { color: red; } }',
- description: 'CRLF',
- },
- {
- code: '@media print { a {\ncolor: pink; }}@media screen { b { color: red; } }',
- },
- ],
-
- reject: [
- {
- code: 'a { color: pink;\nbackground: orange;} b { color: red; }',
- message: messages.rejectedAfterMultiLine(),
- line: 2,
- column: 21,
- },
- {
- code: 'a { color: pink;\nbackground: orange;} b { color: red; }',
- message: messages.rejectedAfterMultiLine(),
- line: 2,
- column: 21,
- },
- {
- code: 'a { color: pink;\nbackground: orange;}\nb { color: red; }',
- message: messages.rejectedAfterMultiLine(),
- line: 2,
- column: 21,
- },
- {
- code: 'a { color: pink;\nbackground: orange;}\tb { color: red; }',
- message: messages.rejectedAfterMultiLine(),
- line: 2,
- column: 21,
- },
- {
- code: '@media print { a {\ncolor: pink; } b { color: red; }}',
- message: messages.rejectedAfterMultiLine(),
- line: 2,
- column: 15,
- },
- {
- code: '@media print { a {\ncolor: pink; }} @media screen { b {\ncolor: red; }}',
- message: messages.rejectedAfterMultiLine(),
- line: 2,
- column: 16,
- },
- {
- code: '@media print { a {\r\ncolor: pink; }} @media screen { b {\r\ncolor: red; }}',
- description: 'CRLF',
- message: messages.rejectedAfterMultiLine(),
- line: 2,
- column: 16,
- },
- ],
-});
diff --git a/lib/rules/block-closing-brace-space-after/index.js b/lib/rules/block-closing-brace-space-after/index.js
deleted file mode 100644
index f285d06723..0000000000
--- a/lib/rules/block-closing-brace-space-after/index.js
+++ /dev/null
@@ -1,96 +0,0 @@
-'use strict';
-
-const blockString = require('../../utils/blockString');
-const hasBlock = require('../../utils/hasBlock');
-const rawNodeString = require('../../utils/rawNodeString');
-const report = require('../../utils/report');
-const ruleMessages = require('../../utils/ruleMessages');
-const validateOptions = require('../../utils/validateOptions');
-const whitespaceChecker = require('../../utils/whitespaceChecker');
-
-const ruleName = 'block-closing-brace-space-after';
-
-const messages = ruleMessages(ruleName, {
- expectedAfter: () => 'Expected single space after "}"',
- rejectedAfter: () => 'Unexpected whitespace after "}"',
- expectedAfterSingleLine: () => 'Expected single space after "}" of a single-line block',
- rejectedAfterSingleLine: () => 'Unexpected whitespace after "}" of a single-line block',
- expectedAfterMultiLine: () => 'Expected single space after "}" of a multi-line block',
- rejectedAfterMultiLine: () => 'Unexpected whitespace after "}" of a multi-line block',
-});
-
-const meta = {
- url: 'https://stylelint.io/user-guide/rules/block-closing-brace-space-after',
- deprecated: true,
-};
-
-/** @type {import('stylelint').Rule} */
-const rule = (primary) => {
- const checker = whitespaceChecker('space', primary, messages);
-
- return (root, result) => {
- const validOptions = validateOptions(result, ruleName, {
- actual: primary,
- possible: [
- 'always',
- 'never',
- 'always-single-line',
- 'never-single-line',
- 'always-multi-line',
- 'never-multi-line',
- ],
- });
-
- if (!validOptions) {
- return;
- }
-
- // Check both kinds of statements: rules and at-rules
- root.walkRules(check);
- root.walkAtRules(check);
-
- /**
- * @param {import('postcss').Rule | import('postcss').AtRule} statement
- */
- function check(statement) {
- const nextNode = statement.next();
-
- if (!nextNode) {
- return;
- }
-
- if (!hasBlock(statement)) {
- return;
- }
-
- let reportIndex = statement.toString().length;
- let source = rawNodeString(nextNode);
-
- // Skip a semicolon at the beginning, if any
- if (source && source.startsWith(';')) {
- source = source.slice(1);
- reportIndex++;
- }
-
- checker.after({
- source,
- index: -1,
- lineCheckStr: blockString(statement),
- err: (msg) => {
- report({
- message: msg,
- node: statement,
- index: reportIndex,
- result,
- ruleName,
- });
- },
- });
- }
- };
-};
-
-rule.ruleName = ruleName;
-rule.messages = messages;
-rule.meta = meta;
-module.exports = rule;
diff --git a/lib/rules/block-closing-brace-space-before/README.md b/lib/rules/block-closing-brace-space-before/README.md
deleted file mode 100644
index c765edfb93..0000000000
--- a/lib/rules/block-closing-brace-space-before/README.md
+++ /dev/null
@@ -1,176 +0,0 @@
-# block-closing-brace-space-before
-
-> **Warning** This rule is deprecated and will be removed in the future. See [the migration guide](../../../docs/migration-guide/to-15.md).
-
-Require a single space or disallow whitespace before the closing brace of blocks.
-
-
-```css
-a { color: pink; }
-/** ↑
- * The space before this brace */
-```
-
-The [`fix` option](../../../docs/user-guide/options.md#fix) can automatically fix all of the problems reported by this rule.
-
-## Options
-
-`string`: `"always"|"never"|"always-single-line"|"never-single-line"|"always-multi-line"|"never-multi-line"`
-
-### `"always"`
-
-There _must always_ be a single space before the closing brace.
-
-The following patterns are considered problems:
-
-
-```css
-a { color: pink;}
-```
-
-
-```css
-a
-{ color: pink;}
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { color: pink; }
-```
-
-
-```css
-a {
-color: pink; }
-```
-
-### `"never"`
-
-There _must never_ be whitespace before the closing brace.
-
-The following patterns are considered problems:
-
-
-```css
-a { color: pink; }
-```
-
-
-```css
-a
-{ color: pink; }
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a{ color: pink;}
-```
-
-
-```css
-a{
-color: pink;}
-```
-
-### `"always-single-line"`
-
-There _must always_ be a single space before the closing brace in single-line blocks.
-
-The following patterns are considered problems:
-
-
-```css
-a { color: pink;}
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { color: pink; }
-```
-
-
-```css
-a {
-color: pink;}
-```
-
-### `"never-single-line"`
-
-There _must never_ be whitespace before the closing brace in single-line blocks.
-
-The following patterns are considered problems:
-
-
-```css
-a { color: pink; }
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { color: pink;}
-```
-
-
-```css
-a {
-color: pink; }
-```
-
-### `"always-multi-line"`
-
-There _must always_ be a single space before the closing brace in multi-line blocks.
-
-The following patterns are considered problems:
-
-
-```css
-a {
-color: pink;}
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { color: pink;}
-```
-
-
-```css
-a {
-color: pink; }
-```
-
-### `"never-multi-line"`
-
-There _must never_ be whitespace before the closing brace in multi-line blocks.
-
-The following patterns are considered problems:
-
-
-```css
-a {
-color: pink; }
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { color: pink; }
-```
-
-
-```css
-a {
-color: pink;}
-```
diff --git a/lib/rules/block-closing-brace-space-before/__tests__/index.js b/lib/rules/block-closing-brace-space-before/__tests__/index.js
deleted file mode 100644
index d5cd400889..0000000000
--- a/lib/rules/block-closing-brace-space-before/__tests__/index.js
+++ /dev/null
@@ -1,514 +0,0 @@
-'use strict';
-
-const { messages, ruleName } = require('..');
-
-testRule({
- ruleName,
- config: ['always'],
- fix: true,
-
- accept: [
- {
- code: 'a { color: pink; }',
- },
- {
- code: 'a { color: pink; } b { color: red; }',
- },
- {
- code: 'a { color: pink; }b { color: red; }',
- },
- ],
-
- reject: [
- {
- code: 'a { color: pink;}',
- fixed: 'a { color: pink; }',
- message: messages.expectedBefore(),
- line: 1,
- column: 16,
- },
- {
- code: 'a { color: pink; }',
- fixed: 'a { color: pink; }',
- message: messages.expectedBefore(),
- line: 1,
- column: 18,
- },
- {
- code: 'a { color: pink;\n}',
- fixed: 'a { color: pink; }',
- message: messages.expectedBefore(),
- line: 1,
- column: 17,
- },
- {
- code: 'a { color: pink;\r\n}',
- fixed: 'a { color: pink; }',
- description: 'CRLF',
- message: messages.expectedBefore(),
- line: 1,
- column: 17,
- },
- {
- code: 'a { color: pink;\t}',
- fixed: 'a { color: pink; }',
- message: messages.expectedBefore(),
- line: 1,
- column: 17,
- },
- {
- code: 'a { color: pink; } b { color: red;}',
- fixed: 'a { color: pink; } b { color: red; }',
- message: messages.expectedBefore(),
- line: 1,
- column: 34,
- },
- {
- code: 'a { color: pink;} b { color: red;}',
- fixed: 'a { color: pink; } b { color: red; }',
- warnings: [
- {
- message: messages.expectedBefore(),
- line: 1,
- column: 16,
- },
- {
- message: messages.expectedBefore(),
- line: 1,
- column: 33,
- },
- ],
- },
- {
- code: 'a { color: pink;/*comment*/}',
- fixed: 'a { color: pink;/*comment*/ }',
- message: messages.expectedBefore(),
- line: 1,
- column: 27,
- },
- {
- code: 'a { color: pink;;;}',
- fixed: 'a { color: pink;;; }',
- message: messages.expectedBefore(),
- line: 1,
- column: 18,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['never'],
- fix: true,
-
- accept: [
- {
- code: 'a { color: pink;}',
- },
- {
- code: 'a { color: pink;} b { color: red;}',
- },
- {
- code: 'a { color: pink;}b { color: red;}',
- },
- ],
-
- reject: [
- {
- code: 'a { color: pink; }',
- fixed: 'a { color: pink;}',
- message: messages.rejectedBefore(),
- line: 1,
- column: 17,
- },
- {
- code: 'a { color: pink; }',
- fixed: 'a { color: pink;}',
- message: messages.rejectedBefore(),
- line: 1,
- column: 18,
- },
- {
- code: 'a { color: pink;\n}',
- fixed: 'a { color: pink;}',
- message: messages.rejectedBefore(),
- line: 1,
- column: 17,
- },
- {
- code: 'a { color: pink;\r\n}',
- fixed: 'a { color: pink;}',
- description: 'CRLF',
- message: messages.rejectedBefore(),
- line: 1,
- column: 17,
- },
- {
- code: 'a { color: pink;\t}',
- fixed: 'a { color: pink;}',
- message: messages.rejectedBefore(),
- line: 1,
- column: 17,
- },
- {
- code: 'a { color: pink;} b { color: red; }',
- fixed: 'a { color: pink;} b { color: red;}',
- message: messages.rejectedBefore(),
- line: 1,
- column: 34,
- },
- {
- code: 'a { color: pink; } b { color: red; }',
- fixed: 'a { color: pink;} b { color: red;}',
- warnings: [
- {
- message: messages.rejectedBefore(),
- line: 1,
- column: 17,
- },
- {
- message: messages.rejectedBefore(),
- line: 1,
- column: 35,
- },
- ],
- },
- {
- code: 'a { color: pink; /*comment*/ }',
- fixed: 'a { color: pink; /*comment*/}',
- message: messages.rejectedBefore(),
- line: 1,
- column: 29,
- },
- {
- code: 'a { color: pink ; ; ; }',
- fixed: 'a { color: pink ; ; ;}',
- message: messages.rejectedBefore(),
- line: 1,
- column: 22,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['always-single-line'],
- fix: true,
-
- accept: [
- {
- code: 'a { color: pink; }',
- },
- {
- code: 'a { color: pink; } b { color: red; }',
- },
- {
- code: 'a { color: pink; }b { color: red; }',
- },
- {
- code: 'a,\nb { color: pink; } c { color: red; }',
- description: 'multi-line rule, single-line block',
- },
- {
- code: 'a { color: pink;\ntop: 0;}',
- },
- {
- code: 'a { color: pink;\n\ntop: 0;}',
- description: 'CRLF',
- },
- {
- code: 'a { color: pink;\ntop: 0; } b { color: red; }',
- },
- {
- code: 'a { color: pink;\ntop: 0;\n}b { color: red; }',
- },
- ],
-
- reject: [
- {
- code: 'a { color: pink;}',
- fixed: 'a { color: pink; }',
- message: messages.expectedBeforeSingleLine(),
- line: 1,
- column: 16,
- },
- {
- code: 'a,\nb { color: pink;}',
- fixed: 'a,\nb { color: pink; }',
- message: messages.expectedBeforeSingleLine(),
- line: 2,
- column: 16,
- },
- {
- code: 'a,\r\nb { color: pink;}',
- fixed: 'a,\r\nb { color: pink; }',
- description: 'CRLF',
- message: messages.expectedBeforeSingleLine(),
- line: 2,
- column: 16,
- },
- {
- code: 'a { color: pink; }',
- fixed: 'a { color: pink; }',
- message: messages.expectedBeforeSingleLine(),
- line: 1,
- column: 18,
- },
- {
- code: 'a { color: pink;\t}',
- fixed: 'a { color: pink; }',
- message: messages.expectedBeforeSingleLine(),
- line: 1,
- column: 17,
- },
- {
- code: 'a { color: pink; } b { color: red;}',
- fixed: 'a { color: pink; } b { color: red; }',
- message: messages.expectedBeforeSingleLine(),
- line: 1,
- column: 34,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['never-single-line'],
- fix: true,
-
- accept: [
- {
- code: 'a { color: pink;}',
- },
- {
- code: 'a { color: pink;} b { color: red;}',
- },
- {
- code: 'a { color: pink;}b { color: red;}',
- },
- {
- code: 'a,\nb { color: pink;} b { color: red;}',
- description: 'multi-line rule, single-line block',
- },
- {
- code: 'a { color: pink;\ntop: 0; }',
- },
- {
- code: 'a { color: pink;\r\ntop: 0; }',
- description: 'CRLF',
- },
- {
- code: 'a { color: pink;\ntop: 0; } b { color: red;}',
- },
- {
- code: 'a { color: pink;\ntop: 0;\n}b { color: red;}',
- },
- ],
-
- reject: [
- {
- code: 'a { color: pink; }',
- fixed: 'a { color: pink;}',
- message: messages.rejectedBeforeSingleLine(),
- line: 1,
- column: 17,
- },
- {
- code: 'a,\nb { color: pink; }',
- fixed: 'a,\nb { color: pink;}',
- message: messages.rejectedBeforeSingleLine(),
- line: 2,
- column: 17,
- },
- {
- code: 'a,\r\nb { color: pink; }',
- fixed: 'a,\r\nb { color: pink;}',
- description: 'CRLF',
- message: messages.rejectedBeforeSingleLine(),
- line: 2,
- column: 17,
- },
- {
- code: 'a { color: pink; }',
- fixed: 'a { color: pink;}',
- message: messages.rejectedBeforeSingleLine(),
- line: 1,
- column: 18,
- },
- {
- code: 'a { color: pink;\t}',
- fixed: 'a { color: pink;}',
- message: messages.rejectedBeforeSingleLine(),
- line: 1,
- column: 17,
- },
- {
- code: 'a { color: pink;} b { color: red;\t}',
- fixed: 'a { color: pink;} b { color: red;}',
- message: messages.rejectedBeforeSingleLine(),
- line: 1,
- column: 34,
- },
- {
- code: 'a { color: pink; } b { color: red;}',
- fixed: 'a { color: pink;} b { color: red;}',
- message: messages.rejectedBeforeSingleLine(),
- line: 1,
- column: 18,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['always-multi-line'],
- fix: true,
-
- accept: [
- {
- code: 'a { color: pink;\ntop: 0; }',
- },
- {
- code: 'a { color: pink;\ntop: 0; } b { color: red; }',
- },
- {
- code: 'a { color: pink;\ntop: 0; }b { color: red; }',
- },
- {
- code: 'a { color: pink;\r\ntop: 0; }b { color: red; }',
- description: 'CRLF',
- },
- {
- code: 'a { color: pink;}',
- },
- {
- code: 'a { color: pink; } b { color: red; }',
- },
- {
- code: 'a { color: pink;\t}b { color: red; }',
- },
- ],
-
- reject: [
- {
- code: 'a { color: pink;\ntop: 0;}',
- fixed: 'a { color: pink;\ntop: 0; }',
- message: messages.expectedBeforeMultiLine(),
- line: 2,
- column: 7,
- },
- {
- code: 'a { color: pink;\ntop: 0; }',
- fixed: 'a { color: pink;\ntop: 0; }',
- message: messages.expectedBeforeMultiLine(),
- line: 2,
- column: 9,
- },
- {
- code: 'a { color: pink;\ntop: 0;\t}',
- fixed: 'a { color: pink;\ntop: 0; }',
- message: messages.expectedBeforeMultiLine(),
- line: 2,
- column: 8,
- },
- {
- code: 'a { color: pink; } b { color: red;\ntop: 0;}',
- fixed: 'a { color: pink; } b { color: red;\ntop: 0; }',
- message: messages.expectedBeforeMultiLine(),
- line: 2,
- column: 7,
- },
- {
- code: 'a { color: pink;\ntop: 0;} b { color: red; }',
- fixed: 'a { color: pink;\ntop: 0; } b { color: red; }',
- message: messages.expectedBeforeMultiLine(),
- line: 2,
- column: 7,
- },
- {
- code: 'a { color: pink;\r\ntop: 0;} b { color: red; }',
- fixed: 'a { color: pink;\r\ntop: 0; } b { color: red; }',
- description: 'CRLF',
- message: messages.expectedBeforeMultiLine(),
- line: 2,
- column: 7,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['never-multi-line'],
- fix: true,
-
- accept: [
- {
- code: 'a { color: pink;\ntop: 0;}',
- },
- {
- code: 'a { color: pink;\ntop: 0;} b { color: red;}',
- },
- {
- code: 'a { color: pink;\r\ntop: 0;} b { color: red;}',
- description: 'CRLF',
- },
- {
- code: 'a { color: pink;\ntop: 0;}b { color: red;}',
- },
- {
- code: 'a { color: pink; }',
- },
- {
- code: 'a { color: pink; } b { color: red; }',
- },
- {
- code: 'a { color: pink;\t}b { color: red; }',
- },
- ],
-
- reject: [
- {
- code: 'a { color: pink;\ntop: 0; }',
- fixed: 'a { color: pink;\ntop: 0;}',
- message: messages.rejectedBeforeMultiLine(),
- line: 2,
- column: 8,
- },
- {
- code: 'a { color: pink;\ntop: 0; }',
- fixed: 'a { color: pink;\ntop: 0;}',
- message: messages.rejectedBeforeMultiLine(),
- line: 2,
- column: 9,
- },
- {
- code: 'a { color: pink;\ntop: 0;\t}',
- fixed: 'a { color: pink;\ntop: 0;}',
- message: messages.rejectedBeforeMultiLine(),
- line: 2,
- column: 8,
- },
- {
- code: 'a { color: pink;\r\ntop: 0;\t}',
- fixed: 'a { color: pink;\r\ntop: 0;}',
- description: 'CRLF',
- message: messages.rejectedBeforeMultiLine(),
- line: 2,
- column: 8,
- },
- {
- code: 'a { color: pink; } b { color: red;\ntop: 0; }',
- fixed: 'a { color: pink; } b { color: red;\ntop: 0;}',
- message: messages.rejectedBeforeMultiLine(),
- line: 2,
- column: 8,
- },
- {
- code: 'a { color: pink;\ntop: 0; } b { color: red; }',
- fixed: 'a { color: pink;\ntop: 0;} b { color: red; }',
- message: messages.rejectedBeforeMultiLine(),
- line: 2,
- column: 8,
- },
- ],
-});
diff --git a/lib/rules/block-closing-brace-space-before/index.js b/lib/rules/block-closing-brace-space-before/index.js
deleted file mode 100644
index 03ac08f1f8..0000000000
--- a/lib/rules/block-closing-brace-space-before/index.js
+++ /dev/null
@@ -1,109 +0,0 @@
-'use strict';
-
-const blockString = require('../../utils/blockString');
-const hasBlock = require('../../utils/hasBlock');
-const hasEmptyBlock = require('../../utils/hasEmptyBlock');
-const report = require('../../utils/report');
-const ruleMessages = require('../../utils/ruleMessages');
-const validateOptions = require('../../utils/validateOptions');
-const whitespaceChecker = require('../../utils/whitespaceChecker');
-
-const ruleName = 'block-closing-brace-space-before';
-
-const messages = ruleMessages(ruleName, {
- expectedBefore: () => 'Expected single space before "}"',
- rejectedBefore: () => 'Unexpected whitespace before "}"',
- expectedBeforeSingleLine: () => 'Expected single space before "}" of a single-line block',
- rejectedBeforeSingleLine: () => 'Unexpected whitespace before "}" of a single-line block',
- expectedBeforeMultiLine: () => 'Expected single space before "}" of a multi-line block',
- rejectedBeforeMultiLine: () => 'Unexpected whitespace before "}" of a multi-line block',
-});
-
-const meta = {
- url: 'https://stylelint.io/user-guide/rules/block-closing-brace-space-before',
- fixable: true,
- deprecated: true,
-};
-
-/** @type {import('stylelint').Rule} */
-const rule = (primary, _secondaryOptions, context) => {
- const checker = whitespaceChecker('space', primary, messages);
-
- return (root, result) => {
- const validOptions = validateOptions(result, ruleName, {
- actual: primary,
- possible: [
- 'always',
- 'never',
- 'always-single-line',
- 'never-single-line',
- 'always-multi-line',
- 'never-multi-line',
- ],
- });
-
- if (!validOptions) {
- return;
- }
-
- // Check both kinds of statement: rules and at-rules
- root.walkRules(check);
- root.walkAtRules(check);
-
- /**
- * @param {import('postcss').Rule | import('postcss').AtRule} statement
- */
- function check(statement) {
- // Return early if blockless or has empty block
- if (!hasBlock(statement) || hasEmptyBlock(statement)) {
- return;
- }
-
- const source = blockString(statement);
- const statementString = statement.toString();
-
- let index = statementString.length - 2;
-
- if (statementString[index - 1] === '\r') {
- index -= 1;
- }
-
- checker.before({
- source,
- index: source.length - 1,
- err: (msg) => {
- if (context.fix) {
- const statementRaws = statement.raws;
-
- if (typeof statementRaws.after !== 'string') return;
-
- if (primary.startsWith('always')) {
- statementRaws.after = statementRaws.after.replace(/\s*$/, ' ');
-
- return;
- }
-
- if (primary.startsWith('never')) {
- statementRaws.after = statementRaws.after.replace(/\s*$/, '');
-
- return;
- }
- }
-
- report({
- message: msg,
- node: statement,
- index,
- result,
- ruleName,
- });
- },
- });
- }
- };
-};
-
-rule.ruleName = ruleName;
-rule.messages = messages;
-rule.meta = meta;
-module.exports = rule;
diff --git a/lib/rules/block-opening-brace-newline-after/README.md b/lib/rules/block-opening-brace-newline-after/README.md
deleted file mode 100644
index b93548c3bb..0000000000
--- a/lib/rules/block-opening-brace-newline-after/README.md
+++ /dev/null
@@ -1,140 +0,0 @@
-# block-opening-brace-newline-after
-
-> **Warning** This rule is deprecated and will be removed in the future. See [the migration guide](../../../docs/migration-guide/to-15.md).
-
-Require a newline after the opening brace of blocks.
-
-
-```css
- a {
- ↑ color: pink; }
-/** ↑
- * The newline after this brace */
-```
-
-This rule allows an end-of-line comment followed by a newline. For example,
-
-
-```css
-a { /* end-of-line comment */
- color: pink;
-}
-```
-
-The [`fix` option](../../../docs/user-guide/options.md#fix) can automatically fix all of the problems reported by this rule.
-
-## Options
-
-`string`: `"always"|"always-multi-line"|"never-multi-line"`
-
-### `"always"`
-
-There _must always_ be a newline after the opening brace.
-
-The following patterns are considered problems:
-
-
-```css
-a{ color: pink; }
-```
-
-
-```css
-a{ color: pink;
-}
-```
-
-
-```css
-a{ /* end-of-line comment
- with a newline */
- color: pink;
-}
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a {
-color: pink; }
-```
-
-
-```css
-a
-{
-color: pink; }
-```
-
-
-```css
-a { /* end-of-line comment */
- color: pink;
-}
-```
-
-### `"always-multi-line"`
-
-There _must always_ be a newline after the opening brace in multi-line blocks.
-
-The following patterns are considered problems:
-
-
-```css
-a{color: pink;
-}
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { color: pink; }
-```
-
-
-```css
-a {
-color: pink; }
-```
-
-### `"never-multi-line"`
-
-There _must never_ be whitespace after the opening brace in multi-line blocks.
-
-The following patterns are considered problems:
-
-
-```css
-a { color: pink;
-}
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { color: pink; }
-```
-
-
-```css
-a {color: pink;
-}
-```
-
-## Optional secondary options
-
-### `ignore: ["rules"]`
-
-Ignore the opening brace of rules.
-
-For example, with `"always"`:
-
-The following pattern is _not_ considered a problem:
-
-
-```css
-a { color: pink; }
-```
diff --git a/lib/rules/block-opening-brace-newline-after/__tests__/index.js b/lib/rules/block-opening-brace-newline-after/__tests__/index.js
deleted file mode 100644
index c91c26816d..0000000000
--- a/lib/rules/block-opening-brace-newline-after/__tests__/index.js
+++ /dev/null
@@ -1,460 +0,0 @@
-'use strict';
-
-const { messages, ruleName } = require('..');
-
-testRule({
- ruleName,
- config: ['always'],
- fix: true,
-
- accept: [
- {
- code: '@import url(x.css)',
- },
- {
- code: 'a {\ncolor: pink; }',
- },
- {
- code: 'a {\r\ncolor: pink; }',
- description: 'CRLF',
- },
- {
- code: 'a {\n\ncolor: pink; }',
- },
- {
- code: 'a {\r\n\r\ncolor: pink; }',
- description: 'CRLF',
- },
- {
- code: 'a{\ncolor: pink; }',
- },
- {
- code: 'a{\n\tcolor: pink; }',
- },
- {
- code: 'a{\n color: pink; }',
- },
- {
- code: 'a{\r\n color: pink; }',
- description: 'CRLF',
- },
- {
- code: '@media print {\na {\ncolor: pink; } }',
- },
- {
- code: '@media print{\na{\ncolor: pink; } }',
- },
- {
- code: '@media print{\r\na{\r\ncolor: pink; } }',
- description: 'CRLF',
- },
- {
- code: '@media print{\n\ta{\n color: pink; } }',
- },
- {
- code: 'a { /* 1 */\n color: pink;\n}',
- description: 'end-of-line comment',
- },
- {
- code: 'a { /* 1 */\n color: pink;\n}',
- description: 'end-of-line comment with multiple spaces before',
- },
- {
- code: 'a {\n /* 1 */\n color: pink;\n}',
- description: 'next-line comment',
- },
- {
- code: 'a {\r\n /* 1 */\r\n color: pink;\r\n}',
- description: 'next-line comment and CRLF',
- },
- {
- code: '.a {\n/*.b*/.c {\n color: pink; }\n }',
- description: 'next-line comment with quasi-qualified selector',
- },
- {
- code: '.a {\r\n/*.b*/.c {\r\n color: pink; }\r\n }',
- description: 'next-line comment and CRLF with quasi-qualified selector',
- },
- {
- code: '@media print {\n /*.test2*/.a {\n color: pink;\n }\n }',
- },
- {
- code: '@media print {\r\n /*.test2*/.a {\r\n color: pink;\r\n }\r\n }',
- },
- {
- code: '@media print {\n /*.test2*/\n .a {\n color: pink;\n }\n }',
- },
- {
- code: '@media print {\r\n /*.test2*/\r\n .a {\r\n color: pink;\r\n }\r\n }',
- },
- {
- code: '@media print {\r\n /*.test2*/\r\n .a {\r\n color: pink;\r\n }\r\n }',
- },
- ],
-
- reject: [
- {
- code: 'a { color: pink; }',
- fixed: 'a {\n color: pink; }',
- message: messages.expectedAfter(),
- line: 1,
- column: 4,
- },
- {
- code: 'a {color: pink; }',
- fixed: 'a {\ncolor: pink; }',
- message: messages.expectedAfter(),
- line: 1,
- column: 4,
- },
- {
- code: 'a { color: pink; }',
- fixed: 'a {\n color: pink; }',
- message: messages.expectedAfter(),
- line: 1,
- column: 4,
- },
- {
- code: 'a {\tcolor: pink; }',
- fixed: 'a {\n\tcolor: pink; }',
- message: messages.expectedAfter(),
- line: 1,
- column: 4,
- },
- {
- code: '@media print { a {\ncolor: pink; } }',
- fixed: '@media print {\n a {\ncolor: pink; } }',
- message: messages.expectedAfter(),
- line: 1,
- column: 15,
- },
- {
- code: '@media print {\na { color: pink; } }',
- fixed: '@media print {\na {\n color: pink; } }',
- message: messages.expectedAfter(),
- line: 2,
- column: 4,
- },
- {
- code: '@media print {\r\na { color: pink; } }',
- fixed: '@media print {\r\na {\r\n color: pink; } }',
- description: 'CRLF',
- message: messages.expectedAfter(),
- line: 2,
- column: 4,
- },
- {
- code: 'a { /* 1 */ color: pink; }',
- fixed: 'a { /* 1 */\n color: pink; }',
- description: 'next node is comment without newline after',
- message: messages.expectedAfter(),
- line: 1,
- column: 4,
- },
- {
- code: '.a {/*.b*/.c { color: pink; } }',
- fixed: '.a {/*.b*/\n.c {\n color: pink; } }',
- description: 'next node is quasi-qualified selector without newline after',
- warnings: [
- {
- message: messages.expectedAfter(),
- line: 1,
- column: 5,
- },
- {
- message: messages.expectedAfter(),
- line: 1,
- column: 15,
- },
- ],
- },
- {
- code: '.a {/*.b*/\n.c { color: pink; } }',
- fixed: '.a {/*.b*/\n.c {\n color: pink; } }',
- description: 'next node is quasi-qualified selector with newline',
- message: messages.expectedAfter(),
- line: 2,
- column: 5,
- },
- {
- code: '.a {/*.b*/\r\n.c { color: pink; } }',
- fixed: '.a {/*.b*/\r\n.c {\r\n color: pink; } }',
- description: 'next node is quasi-qualified selector with CRLF',
- message: messages.expectedAfter(),
- line: 2,
- column: 5,
- },
- {
- code: 'a { \ncolor: pink; }',
- fixed: 'a {\ncolor: pink; }',
- description: 'space before a newline',
- message: messages.expectedAfter(),
- line: 1,
- column: 4,
- },
- {
- code: 'a { \r\ncolor: pink; }',
- fixed: 'a {\r\ncolor: pink; }',
- description: 'space before a CRLF',
- message: messages.expectedAfter(),
- line: 1,
- column: 4,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['always-multi-line'],
- fix: true,
-
- accept: [
- {
- code: 'a {\ncolor: pink; }',
- },
- {
- code: 'a {\n color: pink;\n background: orange; }',
- },
- {
- code: 'a {\r\n color: pink;\r\n background: orange; }',
- description: 'CRLF',
- },
- {
- code: 'a{\ncolor: pink; }',
- },
- {
- code: 'a{\n\tcolor: pink; }',
- },
- {
- code: 'a{\n color: pink; }',
- },
- {
- code: '@media print {\na {\ncolor: pink; } }',
- },
- {
- code: '@media print {\r\na {\r\ncolor: pink; } }',
- description: 'CRLF',
- },
- {
- code: '@media print{\na{\ncolor: pink; } }',
- },
- {
- code: '@media print{\n\ta{\n color: pink; } }',
- },
- {
- code: '@media print{\r\n\ta{\r\n color: pink; } }',
- description: 'CRLF',
- },
- {
- code: 'a { color: pink; }',
- },
- {
- code: 'a {\tcolor: pink; }',
- },
- {
- code: 'a { color: pink; background: orange; }',
- },
- {
- code: 'a { /* 1 */ color: pink; }',
- },
- {
- code: '.a {/*.b*/.c { color: pink; } }',
- },
- ],
-
- reject: [
- {
- code: 'a { color: pink;\nbackground: orange; }',
- fixed: 'a {\n color: pink;\nbackground: orange; }',
- message: messages.expectedAfterMultiLine(),
- line: 1,
- column: 4,
- },
- {
- code: 'a {color: pink;\nbackground: orange; }',
- fixed: 'a {\ncolor: pink;\nbackground: orange; }',
- message: messages.expectedAfterMultiLine(),
- line: 1,
- column: 4,
- },
- {
- code: 'a { color: pink;\nbackground: orange; }',
- fixed: 'a {\n color: pink;\nbackground: orange; }',
- message: messages.expectedAfterMultiLine(),
- line: 1,
- column: 4,
- },
- {
- code: 'a {\tcolor: pink;\nbackground: orange; }',
- fixed: 'a {\n\tcolor: pink;\nbackground: orange; }',
- message: messages.expectedAfterMultiLine(),
- line: 1,
- column: 4,
- },
- {
- code: 'a {\tcolor: pink;\r\nbackground: orange; }',
- fixed: 'a {\r\n\tcolor: pink;\r\nbackground: orange; }',
- description: 'CRLF',
- message: messages.expectedAfterMultiLine(),
- line: 1,
- column: 4,
- },
- {
- code: '@media print { a {\ncolor:\npink; } }',
- fixed: '@media print {\n a {\ncolor:\npink; } }',
- message: messages.expectedAfterMultiLine(),
- line: 1,
- column: 15,
- },
- {
- code: '@media print {\na { color:\npink; } }',
- fixed: '@media print {\na {\n color:\npink; } }',
- message: messages.expectedAfterMultiLine(),
- line: 2,
- column: 4,
- },
- {
- code: '@media print {\r\na { color:\r\npink; } }',
- fixed: '@media print {\r\na {\r\n color:\r\npink; } }',
- description: 'CRLF',
- message: messages.expectedAfterMultiLine(),
- line: 2,
- column: 4,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['never-multi-line'],
- fix: true,
-
- accept: [
- {
- code: 'a {color: pink;\nbackground: orange; }',
- },
- {
- code: 'a {color: pink;\r\nbackground: orange; }',
- description: 'CRLF',
- },
- {
- code: 'a{color: pink;\nbackground: orange; }',
- },
- {
- code: '@media print {a {color: pink;\nbackground: orange; } }',
- },
- {
- code: '@media print{a{color: pink;\nbackground: orange; } }',
- },
- {
- code: 'a { color: pink; }',
- },
- {
- code: 'a { color: pink; }',
- },
- {
- code: 'a {\tcolor: pink; }',
- },
- {
- code: '@media print { a { color: pink; } }',
- },
- {
- code: '@media print {\ta {\tcolor: pink; } }',
- },
- ],
-
- reject: [
- {
- code: 'a { color: pink;\nbackground: orange; }',
- fixed: 'a {color: pink;\nbackground: orange; }',
- message: messages.rejectedAfterMultiLine(),
- line: 1,
- column: 4,
- },
- {
- code: 'a {\ncolor: pink;\nbackground: orange; }',
- fixed: 'a {color: pink;\nbackground: orange; }',
- message: messages.rejectedAfterMultiLine(),
- line: 1,
- column: 4,
- },
- {
- code: 'a {\r\ncolor: pink;\r\nbackground: orange; }',
- fixed: 'a {color: pink;\r\nbackground: orange; }',
- description: 'CRLF',
- message: messages.rejectedAfterMultiLine(),
- line: 1,
- column: 4,
- },
- {
- code: 'a { color: pink;\nbackground: orange; }',
- fixed: 'a {color: pink;\nbackground: orange; }',
- message: messages.rejectedAfterMultiLine(),
- line: 1,
- column: 4,
- },
- {
- code: 'a {\tcolor: pink;\nbackground: orange; }',
- fixed: 'a {color: pink;\nbackground: orange; }',
- message: messages.rejectedAfterMultiLine(),
- line: 1,
- column: 4,
- },
- {
- code: '@media print {\na {color: pink;\nbackground: orange; } }',
- fixed: '@media print {a {color: pink;\nbackground: orange; } }',
- message: messages.rejectedAfterMultiLine(),
- line: 1,
- column: 15,
- },
- {
- code: '@media print {a {\ncolor: pink;\nbackground: orange; } }',
- fixed: '@media print {a {color: pink;\nbackground: orange; } }',
- message: messages.rejectedAfterMultiLine(),
- line: 1,
- column: 18,
- },
- {
- code: 'a {\n/*comment*/ color: pink;\nbackground: orange; }',
- fixed: 'a {/*comment*/color: pink;\nbackground: orange; }',
- description: 'include comment',
- message: messages.rejectedAfterMultiLine(),
- line: 1,
- column: 4,
- },
- {
- code: 'a {\n /*c1*/ /*c2*/ \n\n /*c3*/ color: pink;\nbackground: orange; }',
- fixed: 'a { /*c1*/ /*c2*/ /*c3*/color: pink;\nbackground: orange; }',
- description: 'multi comments',
- message: messages.rejectedAfterMultiLine(),
- line: 1,
- column: 4,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['always', { ignore: ['rules'] }],
- fix: true,
- accept: [
- {
- code: 'a { color: pink; }',
- },
- {
- code: 'a {\ncolor: pink; }',
- },
- {
- code: '@media print {\na {\ncolor: pink; } }',
- },
- ],
- reject: [
- {
- code: '@media print { a { color: pink; } }',
- fixed: '@media print {\n a { color: pink; } }',
- message: messages.expectedAfter(),
- line: 1,
- column: 15,
- },
- ],
-});
diff --git a/lib/rules/block-opening-brace-newline-after/index.js b/lib/rules/block-opening-brace-newline-after/index.js
deleted file mode 100644
index fc6984e7b4..0000000000
--- a/lib/rules/block-opening-brace-newline-after/index.js
+++ /dev/null
@@ -1,182 +0,0 @@
-'use strict';
-
-const beforeBlockString = require('../../utils/beforeBlockString');
-const blockString = require('../../utils/blockString');
-const hasBlock = require('../../utils/hasBlock');
-const hasEmptyBlock = require('../../utils/hasEmptyBlock');
-const optionsMatches = require('../../utils/optionsMatches');
-const rawNodeString = require('../../utils/rawNodeString');
-const report = require('../../utils/report');
-const ruleMessages = require('../../utils/ruleMessages');
-const validateOptions = require('../../utils/validateOptions');
-const whitespaceChecker = require('../../utils/whitespaceChecker');
-
-const ruleName = 'block-opening-brace-newline-after';
-
-const messages = ruleMessages(ruleName, {
- expectedAfter: () => 'Expected newline after "{"',
- expectedAfterMultiLine: () => 'Expected newline after "{" of a multi-line block',
- rejectedAfterMultiLine: () => 'Unexpected whitespace after "{" of a multi-line block',
-});
-
-const meta = {
- url: 'https://stylelint.io/user-guide/rules/block-opening-brace-newline-after',
- fixable: true,
- deprecated: true,
-};
-
-/** @type {import('stylelint').Rule} */
-const rule = (primary, secondaryOptions, context) => {
- const checker = whitespaceChecker('newline', primary, messages);
-
- return (root, result) => {
- const validOptions = validateOptions(
- result,
- ruleName,
- {
- actual: primary,
- possible: ['always', 'rules', 'always-multi-line', 'never-multi-line'],
- },
- {
- actual: secondaryOptions,
- possible: {
- ignore: ['rules'],
- },
- optional: true,
- },
- );
-
- if (!validOptions) {
- return;
- }
-
- // Check both kinds of statement: rules and at-rules
- if (!optionsMatches(secondaryOptions, 'ignore', 'rules')) {
- root.walkRules(check);
- }
-
- root.walkAtRules(check);
-
- /**
- * @param {import('postcss').Rule | import('postcss').AtRule} statement
- */
- function check(statement) {
- // Return early if blockless or has an empty block
- if (!hasBlock(statement) || hasEmptyBlock(statement)) {
- return;
- }
-
- const backupCommentNextBefores = new Map();
-
- /**
- * next node with checking newlines after comment
- *
- * @param {import('postcss').ChildNode | undefined} startNode
- * @returns {import('postcss').ChildNode | undefined}
- */
- function nextNode(startNode) {
- if (!startNode || !startNode.next) return;
-
- if (startNode.type === 'comment') {
- const reNewLine = /\r?\n/;
- const newLineMatch = reNewLine.test(startNode.raws.before || '');
-
- const next = startNode.next();
-
- if (next && newLineMatch && !reNewLine.test(next.raws.before || '')) {
- backupCommentNextBefores.set(next, next.raws.before);
- next.raws.before = startNode.raws.before;
- }
-
- return nextNode(next);
- }
-
- return startNode;
- }
-
- // Allow an end-of-line comment
- const nodeToCheck = nextNode(statement.first);
-
- if (!nodeToCheck) {
- return;
- }
-
- checker.afterOneOnly({
- source: rawNodeString(nodeToCheck),
- index: -1,
- lineCheckStr: blockString(statement),
- err: (m) => {
- if (context.fix) {
- const nodeToCheckRaws = nodeToCheck.raws;
-
- if (typeof nodeToCheckRaws.before !== 'string') return;
-
- if (primary.startsWith('always')) {
- const index = nodeToCheckRaws.before.search(/\r?\n/);
-
- nodeToCheckRaws.before =
- index >= 0
- ? nodeToCheckRaws.before.slice(index)
- : context.newline + nodeToCheckRaws.before;
-
- backupCommentNextBefores.delete(nodeToCheck);
-
- return;
- }
-
- if (primary === 'never-multi-line') {
- // Restore the `before` of the node next to the comment node.
- for (const [node, before] of backupCommentNextBefores.entries()) {
- node.raws.before = before;
- }
-
- backupCommentNextBefores.clear();
-
- // Fix
- const reNewLine = /\r?\n/;
- let fixTarget = statement.first;
-
- while (fixTarget) {
- const fixTargetRaws = fixTarget.raws;
-
- if (typeof fixTargetRaws.before !== 'string') continue;
-
- if (reNewLine.test(fixTargetRaws.before || '')) {
- fixTargetRaws.before = fixTargetRaws.before.replace(/\r?\n/g, '');
- }
-
- if (fixTarget.type !== 'comment') {
- break;
- }
-
- fixTarget = fixTarget.next();
- }
-
- nodeToCheckRaws.before = '';
-
- return;
- }
- }
-
- report({
- message: m,
- node: statement,
- index: beforeBlockString(statement, { noRawBefore: true }).length + 1,
- result,
- ruleName,
- });
- },
- });
-
- // Restore the `before` of the node next to the comment node.
- for (const [node, before] of backupCommentNextBefores.entries()) {
- node.raws.before = before;
- }
- }
- };
-};
-
-rule.ruleName = ruleName;
-rule.messages = messages;
-rule.meta = meta;
-module.exports = rule;
diff --git a/lib/rules/block-opening-brace-newline-before/README.md b/lib/rules/block-opening-brace-newline-before/README.md
deleted file mode 100644
index 503cf250d9..0000000000
--- a/lib/rules/block-opening-brace-newline-before/README.md
+++ /dev/null
@@ -1,176 +0,0 @@
-# block-opening-brace-newline-before
-
-> **Warning** This rule is deprecated and will be removed in the future. See [the migration guide](../../../docs/migration-guide/to-15.md).
-
-Require a newline or disallow whitespace before the opening brace of blocks.
-
-
-```css
- a
- { color: pink; }
-/** ↑
- * The newline before this brace */
-```
-
-The [`fix` option](../../../docs/user-guide/options.md#fix) can automatically fix all of the problems reported by this rule.
-
-## Options
-
-`string`: `"always"|"always-single-line"|"never-single-line"|"always-multi-line"|"never-multi-line"`
-
-### `"always"`
-
-There _must always_ be a newline before the opening brace.
-
-The following patterns are considered problems:
-
-
-```css
-a{ color: pink; }
-```
-
-
-```css
-a{ color: pink;
-}
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a
-{ color: pink; }
-```
-
-
-```css
-a
-{
-color: pink; }
-```
-
-
-```css
-a /* foo */
- {
- color: pink;
- }
-```
-
-### `"always-single-line"`
-
-There _must always_ be a newline before the opening brace in single-line blocks.
-
-The following patterns are considered problems:
-
-
-```css
-a{ color: pink; }
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a
-{ color: pink; }
-```
-
-
-```css
-a{
-color: pink; }
-```
-
-### `"never-single-line"`
-
-There _must never_ be whitespace before the opening brace in single-line blocks.
-
-The following patterns are considered problems:
-
-
-```css
-a { color: pink; }
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a{ color: pink; }
-```
-
-
-```css
-a {
-color: pink; }
-```
-
-### `"always-multi-line"`
-
-There _must always_ be a newline before the opening brace in multi-line blocks.
-
-The following patterns are considered problems:
-
-
-```css
-a{
-color: pink; }
-```
-
-
-```css
-a {
-color: pink; }
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a{ color: pink; }
-```
-
-
-```css
-a { color: pink; }
-```
-
-
-```css
-a
-{ color: pink; }
-```
-
-
-```css
-a
-{
-color: pink; }
-```
-
-### `"never-multi-line"`
-
-There _must never_ be whitespace before the opening brace in multi-line blocks.
-
-The following patterns are considered problems:
-
-
-```css
-a {
-color: pink; }
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { color: pink; }
-```
-
-
-```css
-a{
-color: pink;}
-```
diff --git a/lib/rules/block-opening-brace-newline-before/__tests__/index.js b/lib/rules/block-opening-brace-newline-before/__tests__/index.js
deleted file mode 100644
index f71900584e..0000000000
--- a/lib/rules/block-opening-brace-newline-before/__tests__/index.js
+++ /dev/null
@@ -1,572 +0,0 @@
-'use strict';
-
-const { messages, ruleName } = require('..');
-
-testRule({
- ruleName,
- config: ['always'],
- fix: true,
-
- accept: [
- {
- code: '@import url(x.css)',
- },
- {
- code: 'a\n{ color: pink; }',
- },
- {
- code: 'a\r\n{ color: pink; }',
- description: 'CRLF',
- },
- {
- code: 'a\n\n{ color: pink; }',
- },
- {
- code: 'a\r\n\r\n{ color: pink; }',
- description: 'CRLF',
- },
- {
- code: 'a\n{color: pink; }',
- },
- {
- code: '@media print\n{ a\n{ color: pink; } }',
- },
- {
- code: '@media print\r\n{ a\r\n{ color: pink; } }',
- description: 'CRLF',
- },
- {
- code: '@media print\n{a\n{color: pink; } }',
- },
- {
- code: '@media print\n\t{a\n\t\t{color: pink; } }',
- description: 'indentation after the newline before the opening braces',
- },
- {
- code: '@media print\n\t{a\n\t\t{color: pink;\n\t\t&:hover\n\t\t\t{\n\t\t\t\tcolor:black;} } }',
- description: '3 level deep indentation after the newline before the opening braces',
- },
- {
- code: '@media print\r\n\t{a\r\n\t\t{color: pink;\r\n\t\t&:hover\r\n\t\t\t{\r\n\t\t\t\tcolor:black;} } }',
- description: '3 level deep indentation after the newline before the opening braces and CRLF',
- },
- {
- code: 'a\n{ &:hover\n{ color: pink; }}',
- },
- {
- code: 'a\n{ color: red; &:hover\n{ color: pink; }}',
- },
- {
- code: 'a /* x */\n{ color: pink; }',
- description: 'end-of-line comment after selector',
- },
- ],
-
- reject: [
- {
- code: 'a { color: pink; }',
- fixed: 'a\n { color: pink; }',
- message: messages.expectedBefore(),
- line: 1,
- column: 2,
- },
- {
- code: 'a{ color: pink; }',
- fixed: 'a\n{ color: pink; }',
- message: messages.expectedBefore(),
- line: 1,
- column: 1,
- },
- {
- code: 'a { color: pink; }',
- fixed: 'a\n { color: pink; }',
- message: messages.expectedBefore(),
- line: 1,
- column: 3,
- },
- {
- code: 'a\t{ color: pink; }',
- fixed: 'a\n\t{ color: pink; }',
- message: messages.expectedBefore(),
- line: 1,
- column: 2,
- },
- {
- code: '@media print { a\n{ color: pink; } }',
- fixed: '@media print\n { a\n{ color: pink; } }',
- message: messages.expectedBefore(),
- line: 1,
- column: 13,
- },
- {
- code: '@media print { a\r\n{ color: pink; } }',
- fixed: '@media print\r\n { a\r\n{ color: pink; } }',
- description: 'CRLF',
- message: messages.expectedBefore(),
- line: 1,
- column: 13,
- },
- {
- code: '@media print\n{ a { color: pink; } }',
- fixed: '@media print\n{ a\n { color: pink; } }',
- message: messages.expectedBefore(),
- line: 2,
- column: 4,
- },
- {
- code: '@media print{ a\n{ color: pink; } }',
- fixed: '@media print\n{ a\n{ color: pink; } }',
- message: messages.expectedBefore(),
- line: 1,
- column: 12,
- },
- {
- code: '@media print{ a\r\n{ color: pink; } }',
- fixed: '@media print\r\n{ a\r\n{ color: pink; } }',
- description: 'CRLF',
- message: messages.expectedBefore(),
- line: 1,
- column: 12,
- },
- {
- code: '@media print\n{ a{ color: pink; } }',
- fixed: '@media print\n{ a\n{ color: pink; } }',
- message: messages.expectedBefore(),
- line: 2,
- column: 3,
- },
- {
- code: 'a\n/* foo */{ color: pink; }',
- fixed: 'a\n/* foo */\n{ color: pink; }',
- message: messages.expectedBefore(),
- line: 2,
- column: 9,
- },
- {
- code: 'a\r\n/* foo */{ color: pink; }',
- fixed: 'a\r\n/* foo */\r\n{ color: pink; }',
- description: 'CRLF',
- message: messages.expectedBefore(),
- line: 2,
- column: 9,
- },
- {
- code: '@media print /* foo */ { a /* foo */ { color: pink; } }',
- fixed: '@media print /* foo */\n { a /* foo */\n { color: pink; } }',
- warnings: [
- {
- message: messages.expectedBefore(),
- line: 1,
- column: 37,
- },
- {
- message: messages.expectedBefore(),
- line: 1,
- column: 23,
- },
- ],
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['always-single-line'],
- fix: true,
-
- accept: [
- {
- code: 'a\n{ color: pink; }',
- },
- {
- code: 'a\n{color: pink; }',
- },
- {
- code: '@media print\n{ a\n{ color: pink; } }',
- },
- {
- code: '@media print\r\n{ a\r\n{ color: pink; } }',
- description: 'CRLF',
- },
- {
- code: '@media print\n{a\n{color: pink; } }',
- },
- {
- code: 'a{ color: pink;\nbackground:orange; }',
- },
- {
- code: '@media print { a{ color: pink;\nbackground:orange; } }',
- },
- {
- code: '@media print{ a { color: pink;\nbackground:orange; } }',
- },
- {
- code: '@media print{\na\n{ color: pink; } }',
- },
- {
- code: '@media print{\r\na\r\n{ color: pink; } }',
- description: 'CRLF',
- },
- ],
-
- reject: [
- {
- code: 'a { color: pink; }',
- fixed: 'a\n { color: pink; }',
- message: messages.expectedBeforeSingleLine(),
- line: 1,
- column: 2,
- },
- {
- code: 'a{ color: pink; }',
- fixed: 'a\n{ color: pink; }',
- message: messages.expectedBeforeSingleLine(),
- line: 1,
- column: 1,
- },
- {
- code: 'a { color: pink; }',
- fixed: 'a\n { color: pink; }',
- message: messages.expectedBeforeSingleLine(),
- line: 1,
- column: 3,
- },
- {
- code: 'a\t{ color: pink; }',
- fixed: 'a\n\t{ color: pink; }',
- message: messages.expectedBeforeSingleLine(),
- line: 1,
- column: 2,
- },
- {
- code: '@media print\n{ a { color: pink; } }',
- fixed: '@media print\n{ a\n { color: pink; } }',
- message: messages.expectedBeforeSingleLine(),
- line: 2,
- column: 4,
- },
- {
- code: '@media print\n{ a{ color: pink; } }',
- fixed: '@media print\n{ a\n{ color: pink; } }',
- message: messages.expectedBeforeSingleLine(),
- line: 2,
- column: 3,
- },
- {
- code: '@media print\r\n{ a{ color: pink; } }',
- fixed: '@media print\r\n{ a\r\n{ color: pink; } }',
- description: 'CRLF',
- message: messages.expectedBeforeSingleLine(),
- line: 2,
- column: 3,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['never-single-line'],
- fix: true,
-
- accept: [
- {
- code: 'a{ color: pink; }',
- },
- {
- code: 'a{color: pink; }',
- },
- {
- code: '@media print{ a{ color: pink; } }',
- },
- {
- code: '@media print{a{color: pink; } }',
- },
- {
- code: 'a\n{ color: pink;\nbackground:orange; }',
- },
- {
- code: 'a\r\n{ color: pink;\r\nbackground:orange; }',
- description: 'CRLF',
- },
- {
- code: '@media print { a\n{ color: pink;\nbackground:orange; } }',
- },
- {
- code: '@media print{ a\n{ color: pink;\nbackground:orange; } }',
- },
- {
- code: '@media print{\na{ color: pink; } }',
- },
- {
- code: '@media print{\r\na{ color: pink; } }',
- description: 'CRLF',
- },
- ],
-
- reject: [
- {
- code: 'a\n{ color: pink; }',
- fixed: 'a{ color: pink; }',
- message: messages.rejectedBeforeSingleLine(),
- line: 1,
- column: 2,
- },
- {
- code: 'a\r\n{ color: pink; }',
- fixed: 'a{ color: pink; }',
- description: 'CRLF',
- message: messages.rejectedBeforeSingleLine(),
- line: 1,
- column: 2,
- },
- {
- code: 'a { color: pink; }',
- fixed: 'a{ color: pink; }',
- message: messages.rejectedBeforeSingleLine(),
- line: 1,
- column: 2,
- },
- {
- code: 'a { color: pink; }',
- fixed: 'a{ color: pink; }',
- message: messages.rejectedBeforeSingleLine(),
- line: 1,
- column: 3,
- },
- {
- code: 'a\t{ color: pink; }',
- fixed: 'a{ color: pink; }',
- message: messages.rejectedBeforeSingleLine(),
- line: 1,
- column: 2,
- },
- {
- code: '@media print\n{ a\n{ color: pink; } }',
- fixed: '@media print{ a{ color: pink; } }',
- message: messages.rejectedBeforeSingleLine(),
- line: 2,
- column: 4,
- },
- {
- code: '@media print\r\n{ a\r\n{ color: pink; } }',
- fixed: '@media print{ a{ color: pink; } }',
- description: 'CRLF',
- message: messages.rejectedBeforeSingleLine(),
- line: 2,
- column: 4,
- },
- {
- code: '@media print { a\n{ color: pink; } }',
- fixed: '@media print{ a{ color: pink; } }',
- message: messages.rejectedBeforeSingleLine(),
- line: 1,
- column: 17,
- },
- {
- code: '@media print/*comment*/ { a/*comment*/\n{ color: pink; } }',
- fixed: '@media print/*comment*/{ a/*comment*/{ color: pink; } }',
- message: messages.rejectedBeforeSingleLine(),
- line: 1,
- column: 39,
- },
- {
- code: '@media print /*comment*/ { a /*comment*/\n{ color: pink; } }',
- fixed: '@media print /*comment*/{ a /*comment*/{ color: pink; } }',
- message: messages.rejectedBeforeSingleLine(),
- line: 1,
- column: 41,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['always-multi-line'],
- fix: true,
-
- accept: [
- {
- code: 'a\n{ color: pink;\nbackground: orange; }',
- },
- {
- code: 'a\r\n{ color: pink;\nbackground: orange; }',
- description: 'CRLF',
- },
- {
- code: '@media print\n{\na\n{ color: pink;\nbackground: orange } }',
- },
- {
- code: 'a { color: pink; }',
- },
- {
- code: '@media print { a { color: pink; } }',
- },
- {
- code: 'a{ color: pink; }',
- },
- {
- code: 'a { color: pink; }',
- },
- {
- code: 'a\t{ color: pink; }',
- },
- {
- code: 'a /* foo */\n {\n color: pink;\n }',
- },
- ],
-
- reject: [
- {
- code: 'a{ color: pink;\nbackground: orange; }',
- fixed: 'a\n{ color: pink;\nbackground: orange; }',
- message: messages.expectedBeforeMultiLine(),
- line: 1,
- column: 1,
- },
- {
- code: 'a { color: pink;\nbackground: orange; }',
- fixed: 'a\n { color: pink;\nbackground: orange; }',
- message: messages.expectedBeforeMultiLine(),
- line: 1,
- column: 3,
- },
- {
- code: 'a\t{ color: pink;\nbackground: orange; }',
- fixed: 'a\n\t{ color: pink;\nbackground: orange; }',
- message: messages.expectedBeforeMultiLine(),
- line: 1,
- column: 2,
- },
- {
- code: 'a { color: pink;\nbackground: orange; }',
- fixed: 'a\n { color: pink;\nbackground: orange; }',
- message: messages.expectedBeforeMultiLine(),
- line: 1,
- column: 2,
- },
- {
- code: 'a { color: pink;\r\nbackground: orange; }',
- fixed: 'a\r\n { color: pink;\r\nbackground: orange; }',
- description: 'CRLF',
- message: messages.expectedBeforeMultiLine(),
- line: 1,
- column: 2,
- },
- {
- code: '@media print\n{\na { color: pink;\nbackground: orange; } }',
- fixed: '@media print\n{\na\n { color: pink;\nbackground: orange; } }',
- message: messages.expectedBeforeMultiLine(),
- line: 3,
- column: 2,
- },
- {
- code: '@media print { a\n{ color: pink;\nbackground: orange; } }',
- fixed: '@media print\n { a\n{ color: pink;\nbackground: orange; } }',
- message: messages.expectedBeforeMultiLine(),
- line: 1,
- column: 13,
- },
- {
- code: '@media print { a\r\n{ color: pink;\r\nbackground: orange; } }',
- fixed: '@media print\r\n { a\r\n{ color: pink;\r\nbackground: orange; } }',
- description: 'CRLF',
- message: messages.expectedBeforeMultiLine(),
- line: 1,
- column: 13,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['never-multi-line'],
- fix: true,
-
- accept: [
- {
- code: 'a{ color: pink;\nbackground: orange; }',
- },
- {
- code: 'a{ color: pink;\r\nbackground: orange; }',
- description: 'CRLF',
- },
- {
- code: '@media print{\na{ color: pink;\nbackground: orange } }',
- },
- {
- code: 'a { color: pink; }',
- },
- {
- code: '@media print { a { color: pink; } }',
- },
- {
- code: 'a{ color: pink; }',
- },
- {
- code: 'a { color: pink; }',
- },
- {
- code: 'a\t{ color: pink; }',
- },
- ],
-
- reject: [
- {
- code: 'a { color: pink;\nbackground: orange; }',
- fixed: 'a{ color: pink;\nbackground: orange; }',
- message: messages.rejectedBeforeMultiLine(),
- line: 1,
- column: 2,
- },
- {
- code: 'a { color: pink;\r\nbackground: orange; }',
- fixed: 'a{ color: pink;\r\nbackground: orange; }',
- description: 'CRLF',
- message: messages.rejectedBeforeMultiLine(),
- line: 1,
- column: 2,
- },
- {
- code: 'a { color: pink;\nbackground: orange; }',
- fixed: 'a{ color: pink;\nbackground: orange; }',
- message: messages.rejectedBeforeMultiLine(),
- line: 1,
- column: 3,
- },
- {
- code: 'a\t{ color: pink;\nbackground: orange; }',
- fixed: 'a{ color: pink;\nbackground: orange; }',
- message: messages.rejectedBeforeMultiLine(),
- line: 1,
- column: 2,
- },
- {
- code: 'a\n{ color: pink;\nbackground: orange; }',
- fixed: 'a{ color: pink;\nbackground: orange; }',
- message: messages.rejectedBeforeMultiLine(),
- line: 1,
- column: 2,
- },
- {
- code: '@media print\n{\na{ color: pink;\nbackground: orange; } }',
- fixed: '@media print{\na{ color: pink;\nbackground: orange; } }',
- message: messages.rejectedBeforeMultiLine(),
- line: 1,
- column: 13,
- },
- {
- code: '@media print{ a\n{ color: pink;\nbackground: orange; } }',
- fixed: '@media print{ a{ color: pink;\nbackground: orange; } }',
- message: messages.rejectedBeforeMultiLine(),
- line: 1,
- column: 16,
- },
- {
- code: '@media print{ a\r\n{ color: pink;\r\nbackground: orange; } }',
- fixed: '@media print{ a{ color: pink;\r\nbackground: orange; } }',
- message: messages.rejectedBeforeMultiLine(),
- line: 1,
- column: 16,
- },
- ],
-});
diff --git a/lib/rules/block-opening-brace-newline-before/index.js b/lib/rules/block-opening-brace-newline-before/index.js
deleted file mode 100644
index 1bc9aa8d4f..0000000000
--- a/lib/rules/block-opening-brace-newline-before/index.js
+++ /dev/null
@@ -1,120 +0,0 @@
-'use strict';
-
-const beforeBlockString = require('../../utils/beforeBlockString');
-const blockString = require('../../utils/blockString');
-const hasBlock = require('../../utils/hasBlock');
-const hasEmptyBlock = require('../../utils/hasEmptyBlock');
-const report = require('../../utils/report');
-const ruleMessages = require('../../utils/ruleMessages');
-const validateOptions = require('../../utils/validateOptions');
-const whitespaceChecker = require('../../utils/whitespaceChecker');
-
-const ruleName = 'block-opening-brace-newline-before';
-
-const messages = ruleMessages(ruleName, {
- expectedBefore: () => 'Expected newline before "{"',
- expectedBeforeSingleLine: () => 'Expected newline before "{" of a single-line block',
- rejectedBeforeSingleLine: () => 'Unexpected whitespace before "{" of a single-line block',
- expectedBeforeMultiLine: () => 'Expected newline before "{" of a multi-line block',
- rejectedBeforeMultiLine: () => 'Unexpected whitespace before "{" of a multi-line block',
-});
-
-const meta = {
- url: 'https://stylelint.io/user-guide/rules/block-opening-brace-newline-before',
- fixable: true,
- deprecated: true,
-};
-
-/** @type {import('stylelint').Rule} */
-const rule = (primary, _secondaryOptions, context) => {
- const checker = whitespaceChecker('newline', primary, messages);
-
- return (root, result) => {
- const validOptions = validateOptions(result, ruleName, {
- actual: primary,
- possible: [
- 'always',
- 'always-single-line',
- 'never-single-line',
- 'always-multi-line',
- 'never-multi-line',
- ],
- });
-
- if (!validOptions) {
- return;
- }
-
- // Check both kinds of statement: rules and at-rules
- root.walkRules(check);
- root.walkAtRules(check);
-
- /**
- * @param {import('postcss').Rule | import('postcss').AtRule} statement
- */
- function check(statement) {
- // Return early if blockless or has an empty block
- if (!hasBlock(statement) || hasEmptyBlock(statement)) {
- return;
- }
-
- const source = beforeBlockString(statement);
- const beforeBraceNoRaw = beforeBlockString(statement, {
- noRawBefore: true,
- });
-
- let index = beforeBraceNoRaw.length - 1;
-
- if (beforeBraceNoRaw[index - 1] === '\r') {
- index -= 1;
- }
-
- checker.beforeAllowingIndentation({
- lineCheckStr: blockString(statement),
- source,
- index: source.length,
- err: (m) => {
- if (context.fix) {
- const statementRaws = statement.raws;
-
- if (typeof statementRaws.between !== 'string') return;
-
- if (primary.startsWith('always')) {
- const spaceIndex = statementRaws.between.search(/\s+$/);
-
- if (spaceIndex >= 0) {
- statement.raws.between =
- statementRaws.between.slice(0, spaceIndex) +
- context.newline +
- statementRaws.between.slice(spaceIndex);
- } else {
- statementRaws.between += context.newline;
- }
-
- return;
- }
-
- if (primary.startsWith('never')) {
- statementRaws.between = statementRaws.between.replace(/\s*$/, '');
-
- return;
- }
- }
-
- report({
- message: m,
- node: statement,
- index,
- result,
- ruleName,
- });
- },
- });
- }
- };
-};
-
-rule.ruleName = ruleName;
-rule.messages = messages;
-rule.meta = meta;
-module.exports = rule;
diff --git a/lib/rules/block-opening-brace-space-after/README.md b/lib/rules/block-opening-brace-space-after/README.md
deleted file mode 100644
index 946219f5a9..0000000000
--- a/lib/rules/block-opening-brace-space-after/README.md
+++ /dev/null
@@ -1,193 +0,0 @@
-# block-opening-brace-space-after
-
-> **Warning** This rule is deprecated and will be removed in the future. See [the migration guide](../../../docs/migration-guide/to-15.md).
-
-Require a single space or disallow whitespace after the opening brace of blocks.
-
-
-```css
- a { color: pink; }
-/** ↑
- * The space after this brace */
-```
-
-The [`fix` option](../../../docs/user-guide/options.md#fix) can automatically fix all of the problems reported by this rule.
-
-## Options
-
-`string`: `"always"|"never"|"always-single-line"|"never-single-line"|"always-multi-line"|"never-multi-line"`
-
-### `"always"`
-
-There _must always_ be a single space after the opening brace.
-
-The following patterns are considered problems:
-
-
-```css
-a {color: pink; }
-```
-
-
-```css
-a {
-color: pink; }
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { color: pink; }
-```
-
-
-```css
-a { color: pink;
-}
-```
-
-### `"never"`
-
-There _must never_ be whitespace after the opening brace.
-
-The following patterns are considered problems:
-
-
-```css
-a { color: pink; }
-```
-
-
-```css
-a {
-color: pink; }
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a {color: pink; }
-```
-
-
-```css
-a
-{color: pink; }
-```
-
-### `"always-single-line"`
-
-There _must always_ be a single space after the opening brace in single-line blocks.
-
-The following patterns are considered problems:
-
-
-```css
-a {color: pink; }
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { color: pink; }
-```
-
-
-```css
-a {color: pink;
-}
-```
-
-### `"never-single-line"`
-
-There _must never_ be whitespace after the opening brace in single-line blocks.
-
-The following patterns are considered problems:
-
-
-```css
-a { color: pink; }
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a {color: pink; }
-```
-
-
-```css
-a { color: pink;
-}
-```
-
-### `"always-multi-line"`
-
-There _must always_ be a single space after the opening brace in multi-line blocks.
-
-The following patterns are considered problems:
-
-
-```css
-a {color: pink;
-}
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a {color: pink; }
-```
-
-
-```css
-a { color: pink;
-}
-```
-
-### `"never-multi-line"`
-
-There _must never_ be whitespace after the opening brace in multi-line blocks.
-
-The following patterns are considered problems:
-
-
-```css
-a { color: pink;
-}
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { color: pink; }
-```
-
-
-```css
-a {color: pink;
-}
-```
-
-## Optional secondary options
-
-### `ignore: ["at-rules"]`
-
-Ignore the opening brace of at-rules.
-
-For example, with `"always"`:
-
-The following pattern is _not_ considered a problem:
-
-
-```css
-@media print {
- a { color: pink; }
-}
-```
diff --git a/lib/rules/block-opening-brace-space-after/__tests__/index.js b/lib/rules/block-opening-brace-space-after/__tests__/index.js
deleted file mode 100644
index 25b14243c9..0000000000
--- a/lib/rules/block-opening-brace-space-after/__tests__/index.js
+++ /dev/null
@@ -1,495 +0,0 @@
-'use strict';
-
-const { messages, ruleName } = require('..');
-
-testRule({
- ruleName,
- config: ['always'],
- fix: true,
-
- accept: [
- {
- code: '@import url(x.css)',
- },
- {
- code: 'a { color: pink; }',
- },
- {
- code: '@media print { a { color: pink; } }',
- },
- ],
-
- reject: [
- {
- code: 'a {color: pink; }',
- fixed: 'a { color: pink; }',
- message: messages.expectedAfter(),
- line: 1,
- column: 4,
- },
- {
- code: 'a { color: pink; }',
- fixed: 'a { color: pink; }',
- message: messages.expectedAfter(),
- line: 1,
- column: 4,
- },
- {
- code: 'a {\tcolor: pink; }',
- fixed: 'a { color: pink; }',
- message: messages.expectedAfter(),
- line: 1,
- column: 4,
- },
- {
- code: 'a {\ncolor: pink; }',
- fixed: 'a { color: pink; }',
- message: messages.expectedAfter(),
- line: 1,
- column: 4,
- },
- {
- code: 'a {\r\ncolor: pink; }',
- fixed: 'a { color: pink; }',
- description: 'CRLF',
- message: messages.expectedAfter(),
- line: 1,
- column: 4,
- },
- {
- code: '@media print {\na { color: pink; } }',
- fixed: '@media print { a { color: pink; } }',
- message: messages.expectedAfter(),
- line: 1,
- column: 15,
- },
- {
- code: '@media print { a {\ncolor: pink; } }',
- fixed: '@media print { a { color: pink; } }',
- message: messages.expectedAfter(),
- line: 1,
- column: 19,
- },
- {
- code: '@media print { a {\r\ncolor: pink; } }',
- fixed: '@media print { a { color: pink; } }',
- description: 'CRLF',
- message: messages.expectedAfter(),
- line: 1,
- column: 19,
- },
- {
- code: 'a {/*comment*/ color: pink; }',
- fixed: 'a { /*comment*/ color: pink; }',
- message: messages.expectedAfter(),
- line: 1,
- column: 4,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['never'],
- fix: true,
-
- accept: [
- {
- code: 'a {color: pink; }',
- },
- {
- code: '@media print {a {color: pink; } }',
- },
- ],
-
- reject: [
- {
- code: 'a { color: pink; }',
- fixed: 'a {color: pink; }',
- message: messages.rejectedAfter(),
- line: 1,
- column: 4,
- },
- {
- code: 'a { color: pink; }',
- fixed: 'a {color: pink; }',
- message: messages.rejectedAfter(),
- line: 1,
- column: 4,
- },
- {
- code: 'a {\tcolor: pink; }',
- fixed: 'a {color: pink; }',
- message: messages.rejectedAfter(),
- line: 1,
- column: 4,
- },
- {
- code: 'a {\ncolor: pink; }',
- fixed: 'a {color: pink; }',
- message: messages.rejectedAfter(),
- line: 1,
- column: 4,
- },
- {
- code: 'a {\r\ncolor: pink; }',
- fixed: 'a {color: pink; }',
- description: 'CRLF',
- message: messages.rejectedAfter(),
- line: 1,
- column: 4,
- },
- {
- code: '@media print {\na {color: pink; } }',
- fixed: '@media print {a {color: pink; } }',
- message: messages.rejectedAfter(),
- line: 1,
- column: 15,
- },
- {
- code: '@media print {a {\ncolor: pink; } }',
- fixed: '@media print {a {color: pink; } }',
- message: messages.rejectedAfter(),
- line: 1,
- column: 18,
- },
- {
- code: 'a { /*comment*/ color: pink; }',
- fixed: 'a {/*comment*/ color: pink; }',
- message: messages.rejectedAfter(),
- line: 1,
- column: 4,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['always-single-line'],
- fix: true,
-
- accept: [
- {
- code: 'a { color: pink; }',
- },
- {
- code: '@media print { a { color: pink; } }',
- },
- {
- code: 'a {\ncolor: pink; }',
- },
- {
- code: 'a {\r\ncolor: pink; }',
- description: 'CRLF',
- },
- {
- code: 'a {color:\npink; }',
- },
- {
- code: '@media print {a {color:\npink; } }',
- },
- {
- code: '@media print{a {color:\npink; } }',
- },
- ],
-
- reject: [
- {
- code: 'a {color: pink; }',
- fixed: 'a { color: pink; }',
- message: messages.expectedAfterSingleLine(),
- line: 1,
- column: 4,
- },
- {
- code: 'a { color: pink; }',
- fixed: 'a { color: pink; }',
- message: messages.expectedAfterSingleLine(),
- line: 1,
- column: 4,
- },
- {
- code: 'a {\tcolor: pink; }',
- fixed: 'a { color: pink; }',
- message: messages.expectedAfterSingleLine(),
- line: 1,
- column: 4,
- },
- {
- code: '@media print {\ta { color: pink; } }',
- fixed: '@media print { a { color: pink; } }',
- message: messages.expectedAfterSingleLine(),
- line: 1,
- column: 15,
- },
- {
- code: '@media print { a {\tcolor: pink; } }',
- fixed: '@media print { a { color: pink; } }',
- message: messages.expectedAfterSingleLine(),
- line: 1,
- column: 19,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['never-single-line'],
- fix: true,
-
- accept: [
- {
- code: 'a {color: pink; }',
- },
- {
- code: '@media print {a {color: pink; } }',
- },
- {
- code: 'a { color:\npink; }',
- },
- {
- code: '@media print { a { color:\npink; } }',
- },
- {
- code: '@media print { a\n{color: pink; } }',
- },
- {
- code: '@media print { a\r\n{color: pink; } }',
- description: 'CRLF',
- },
- ],
-
- reject: [
- {
- code: 'a { color: pink; }',
- fixed: 'a {color: pink; }',
- message: messages.rejectedAfterSingleLine(),
- line: 1,
- column: 4,
- },
- {
- code: 'a { color: pink; }',
- fixed: 'a {color: pink; }',
- message: messages.rejectedAfterSingleLine(),
- line: 1,
- column: 4,
- },
- {
- code: 'a {\tcolor: pink; }',
- fixed: 'a {color: pink; }',
- message: messages.rejectedAfterSingleLine(),
- line: 1,
- column: 4,
- },
- {
- code: '@media print { a {color: pink; } }',
- fixed: '@media print {a {color: pink; } }',
- message: messages.rejectedAfterSingleLine(),
- line: 1,
- column: 15,
- },
- {
- code: '@media print {a { color: pink; } }',
- fixed: '@media print {a {color: pink; } }',
- message: messages.rejectedAfterSingleLine(),
- line: 1,
- column: 18,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['always-multi-line'],
- fix: true,
-
- accept: [
- {
- code: 'a { color: pink;\nbackground: orange; }',
- },
- {
- code: '@media print { a { color: pink;\nbackground: orange } }',
- },
- {
- code: 'a {color: pink; }',
- },
- {
- code: '@media print {a {color: pink; } }',
- },
- {
- code: 'a { color: pink; }',
- },
- {
- code: 'a { color: pink; }',
- },
- {
- code: 'a {\tcolor: pink; }',
- },
- ],
-
- reject: [
- {
- code: 'a {color: pink;\nbackground: orange; }',
- fixed: 'a { color: pink;\nbackground: orange; }',
- message: messages.expectedAfterMultiLine(),
- line: 1,
- column: 4,
- },
- {
- code: 'a { color: pink;\nbackground: orange; }',
- fixed: 'a { color: pink;\nbackground: orange; }',
- message: messages.expectedAfterMultiLine(),
- line: 1,
- column: 4,
- },
- {
- code: 'a {\tcolor: pink;\nbackground: orange; }',
- fixed: 'a { color: pink;\nbackground: orange; }',
- message: messages.expectedAfterMultiLine(),
- line: 1,
- column: 4,
- },
- {
- code: 'a {\ncolor: pink;\nbackground: orange; }',
- fixed: 'a { color: pink;\nbackground: orange; }',
- message: messages.expectedAfterMultiLine(),
- line: 1,
- column: 4,
- },
- {
- code: 'a {\r\ncolor: pink;\r\nbackground: orange; }',
- fixed: 'a { color: pink;\r\nbackground: orange; }',
- description: 'CRLF',
- message: messages.expectedAfterMultiLine(),
- line: 1,
- column: 4,
- },
- {
- code: '@media print\n{a { color: pink;\nbackground: orange; } }',
- fixed: '@media print\n{ a { color: pink;\nbackground: orange; } }',
- message: messages.expectedAfterMultiLine(),
- line: 2,
- column: 2,
- },
- {
- code: '@media print { a\n{color: pink;\nbackground: orange; } }',
- fixed: '@media print { a\n{ color: pink;\nbackground: orange; } }',
- message: messages.expectedAfterMultiLine(),
- line: 2,
- column: 2,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['never-multi-line'],
- fix: true,
-
- accept: [
- {
- code: 'a {color: pink;\nbackground: orange; }',
- },
- {
- code: '@media print {a\n{color: pink;\nbackground: orange } }',
- },
- {
- code: '@media print {a\r\n{color: pink;\r\nbackground: orange } }',
- description: 'CRLF',
- },
- {
- code: 'a { color: pink; }',
- },
- {
- code: '@media print { a { color: pink; } }',
- },
- {
- code: 'a { color: pink; }',
- },
- {
- code: 'a { color: pink; }',
- },
- {
- code: 'a {\tcolor: pink; }',
- },
- ],
-
- reject: [
- {
- code: 'a { color: pink;\nbackground: orange; }',
- fixed: 'a {color: pink;\nbackground: orange; }',
- message: messages.rejectedAfterMultiLine(),
- line: 1,
- column: 4,
- },
- {
- code: 'a { color: pink;\nbackground: orange; }',
- fixed: 'a {color: pink;\nbackground: orange; }',
- message: messages.rejectedAfterMultiLine(),
- line: 1,
- column: 4,
- },
- {
- code: 'a {\tcolor: pink;\nbackground: orange; }',
- fixed: 'a {color: pink;\nbackground: orange; }',
- message: messages.rejectedAfterMultiLine(),
- line: 1,
- column: 4,
- },
- {
- code: 'a {\tcolor: pink;\r\nbackground: orange; }',
- fixed: 'a {color: pink;\r\nbackground: orange; }',
- description: 'CRLF',
- message: messages.rejectedAfterMultiLine(),
- line: 1,
- column: 4,
- },
- {
- code: 'a {\ncolor: pink;\nbackground: orange; }',
- fixed: 'a {color: pink;\nbackground: orange; }',
- message: messages.rejectedAfterMultiLine(),
- line: 1,
- column: 4,
- },
- {
- code: '@media print\n{ a {color: pink;\nbackground: orange; } }',
- fixed: '@media print\n{a {color: pink;\nbackground: orange; } }',
- message: messages.rejectedAfterMultiLine(),
- line: 2,
- column: 2,
- },
- {
- code: '@media print{a\n{ color: pink;\nbackground: orange; } }',
- fixed: '@media print{a\n{color: pink;\nbackground: orange; } }',
- message: messages.rejectedAfterMultiLine(),
- line: 2,
- column: 2,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['always', { ignore: ['at-rules'] }],
- fix: true,
- accept: [
- {
- code: 'a { color: pink; }',
- },
- {
- code: '@media print { a { color: pink; } }',
- },
- {
- code: '@media print {\na { color: pink; } }',
- },
- ],
- reject: [
- {
- code: '@media print {\n a {color: pink; } }',
- fixed: '@media print {\n a { color: pink; } }',
- message: messages.expectedAfter(),
- line: 2,
- column: 6,
- },
- ],
-});
diff --git a/lib/rules/block-opening-brace-space-after/index.js b/lib/rules/block-opening-brace-space-after/index.js
deleted file mode 100644
index 02fc149ead..0000000000
--- a/lib/rules/block-opening-brace-space-after/index.js
+++ /dev/null
@@ -1,116 +0,0 @@
-'use strict';
-
-const beforeBlockString = require('../../utils/beforeBlockString');
-const blockString = require('../../utils/blockString');
-const hasBlock = require('../../utils/hasBlock');
-const hasEmptyBlock = require('../../utils/hasEmptyBlock');
-const optionsMatches = require('../../utils/optionsMatches');
-const report = require('../../utils/report');
-const ruleMessages = require('../../utils/ruleMessages');
-const validateOptions = require('../../utils/validateOptions');
-const whitespaceChecker = require('../../utils/whitespaceChecker');
-
-const ruleName = 'block-opening-brace-space-after';
-
-const messages = ruleMessages(ruleName, {
- expectedAfter: () => 'Expected single space after "{"',
- rejectedAfter: () => 'Unexpected whitespace after "{"',
- expectedAfterSingleLine: () => 'Expected single space after "{" of a single-line block',
- rejectedAfterSingleLine: () => 'Unexpected whitespace after "{" of a single-line block',
- expectedAfterMultiLine: () => 'Expected single space after "{" of a multi-line block',
- rejectedAfterMultiLine: () => 'Unexpected whitespace after "{" of a multi-line block',
-});
-
-const meta = {
- url: 'https://stylelint.io/user-guide/rules/block-opening-brace-space-after',
- fixable: true,
- deprecated: true,
-};
-
-/** @type {import('stylelint').Rule} */
-const rule = (primary, secondaryOptions, context) => {
- const checker = whitespaceChecker('space', primary, messages);
-
- return (root, result) => {
- const validOptions = validateOptions(
- result,
- ruleName,
- {
- actual: primary,
- possible: [
- 'always',
- 'never',
- 'always-single-line',
- 'never-single-line',
- 'always-multi-line',
- 'never-multi-line',
- ],
- },
- {
- actual: secondaryOptions,
- possible: {
- ignore: ['at-rules'],
- },
- optional: true,
- },
- );
-
- if (!validOptions) {
- return;
- }
-
- // Check both kinds of statements: rules and at-rules
- root.walkRules(check);
-
- if (!optionsMatches(secondaryOptions, 'ignore', 'at-rules')) {
- root.walkAtRules(check);
- }
-
- /**
- * @param {import('postcss').Rule | import('postcss').AtRule} statement
- */
- function check(statement) {
- // Return early if blockless or has an empty block
- if (!hasBlock(statement) || hasEmptyBlock(statement)) {
- return;
- }
-
- checker.after({
- source: blockString(statement),
- index: 0,
- err: (m) => {
- if (context.fix) {
- const statementFirst = statement.first;
-
- if (statementFirst == null) return;
-
- if (primary.startsWith('always')) {
- statementFirst.raws.before = ' ';
-
- return;
- }
-
- if (primary.startsWith('never')) {
- statementFirst.raws.before = '';
-
- return;
- }
- }
-
- report({
- message: m,
- node: statement,
- index: beforeBlockString(statement, { noRawBefore: true }).length + 1,
- result,
- ruleName,
- });
- },
- });
- }
- };
-};
-
-rule.ruleName = ruleName;
-rule.messages = messages;
-rule.meta = meta;
-module.exports = rule;
diff --git a/lib/rules/block-opening-brace-space-before/README.md b/lib/rules/block-opening-brace-space-before/README.md
deleted file mode 100644
index 82bccdc1a1..0000000000
--- a/lib/rules/block-opening-brace-space-before/README.md
+++ /dev/null
@@ -1,220 +0,0 @@
-# block-opening-brace-space-before
-
-> **Warning** This rule is deprecated and will be removed in the future. See [the migration guide](../../../docs/migration-guide/to-15.md).
-
-Require a single space or disallow whitespace before the opening brace of blocks.
-
-
-```css
- a { color: pink; }
-/** ↑
- * The space before this brace */
-```
-
-The [`fix` option](../../../docs/user-guide/options.md#fix) can automatically fix all of the problems reported by this rule.
-
-## Options
-
-`string`: `"always"|"never"|"always-single-line"|"never-single-line"|"always-multi-line"|"never-multi-line"`
-
-### `"always"`
-
-There _must always_ be a single space before the opening brace.
-
-The following patterns are considered problems:
-
-
-```css
-a{ color: pink; }
-```
-
-
-```css
-a
-{ color: pink; }
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { color: pink; }
-```
-
-
-```css
-a {
-color: pink; }
-```
-
-### `"never"`
-
-There _must never_ be whitespace before the opening brace.
-
-The following patterns are considered problems:
-
-
-```css
-a { color: pink; }
-```
-
-
-```css
-a
-{ color: pink; }
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a{ color: pink; }
-```
-
-
-```css
-a{
-color: pink; }
-```
-
-### `"always-single-line"`
-
-There _must always_ be a single space before the opening brace in single-line blocks.
-
-The following patterns are considered problems:
-
-
-```css
-a{ color: pink; }
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { color: pink; }
-```
-
-
-```css
-a{
-color: pink; }
-```
-
-### `"never-single-line"`
-
-There _must never_ be whitespace before the opening brace in single-line blocks.
-
-The following patterns are considered problems:
-
-
-```css
-a { color: pink; }
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a{ color: pink; }
-```
-
-
-```css
-a {
-color: pink; }
-```
-
-### `"always-multi-line"`
-
-There _must always_ be a single space before the opening brace in multi-line blocks.
-
-The following patterns are considered problems:
-
-
-```css
-a{
-color: pink; }
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a{ color: pink; }
-```
-
-
-```css
-a {
-color: pink; }
-```
-
-### `"never-multi-line"`
-
-There _must never_ be whitespace before the opening brace in multi-line blocks.
-
-The following patterns are considered problems:
-
-
-```css
-a {
-color: pink; }
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { color: pink; }
-```
-
-
-```css
-a{
-color: pink;}
-```
-
-## Optional secondary options
-
-### `ignoreAtRules: ["/regex/", /regex/, "non-regex"]`
-
-Given:
-
-```json
-["/for/i"]
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-@for ...
-{}
-```
-
-
-```css
-@for ...{}
-```
-
-### `ignoreSelectors: ["/regex/", /regex/, "non-regex"]`
-
-Given:
-
-```json
-[":root"]
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-:root
-{}
-```
-
-
-```css
-:root{}
-```
diff --git a/lib/rules/block-opening-brace-space-before/__tests__/index.js b/lib/rules/block-opening-brace-space-before/__tests__/index.js
deleted file mode 100644
index df07c7621b..0000000000
--- a/lib/rules/block-opening-brace-space-before/__tests__/index.js
+++ /dev/null
@@ -1,552 +0,0 @@
-'use strict';
-
-const { messages, ruleName } = require('..');
-
-testRule({
- ruleName,
- config: ['always'],
- fix: true,
-
- accept: [
- {
- code: '@import url(x.css)',
- },
- {
- code: 'a { color: pink; }',
- },
- {
- code: '@media print { a { color: pink; } }',
- },
- {
- code: 'a {{ &:hover { color: pink; }}}',
- },
- {
- code: 'a {\n&:hover { color: pink; }}',
- },
- ],
-
- reject: [
- {
- code: 'a{ color: pink; }',
- fixed: 'a { color: pink; }',
- message: messages.expectedBefore(),
- line: 1,
- column: 1,
- },
- {
- code: 'a { color: pink; }',
- fixed: 'a { color: pink; }',
- message: messages.expectedBefore(),
- line: 1,
- column: 3,
- },
- {
- code: 'a\t{ color: pink; }',
- fixed: 'a { color: pink; }',
- message: messages.expectedBefore(),
- line: 1,
- column: 2,
- },
- {
- code: 'a\n{ color: pink; }',
- fixed: 'a { color: pink; }',
- message: messages.expectedBefore(),
- line: 1,
- column: 2,
- },
- {
- code: 'a\r\n{ color: pink; }',
- fixed: 'a { color: pink; }',
- description: 'CRLF',
- message: messages.expectedBefore(),
- line: 1,
- column: 2,
- },
- {
- code: '@media print\n{ a { color: pink; } }',
- fixed: '@media print { a { color: pink; } }',
- message: messages.expectedBefore(),
- line: 1,
- column: 13,
- },
- {
- code: '@media print { a\n{ color: pink; } }',
- fixed: '@media print { a { color: pink; } }',
- message: messages.expectedBefore(),
- line: 1,
- column: 17,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['always', { ignoreAtRules: ['for', '/for/i', /for/i] }],
- fix: true,
-
- accept: [
- {
- code: 'a { color: pink; }',
- },
- {
- code: '@for ...\n{ color: pink; }',
- },
- {
- code: '@for ...\r\n{ color: pink; }',
- },
- ],
-
- reject: [
- {
- code: 'a{ color: pink; }',
- fixed: 'a { color: pink; }',
- message: messages.expectedBefore(),
- line: 1,
- column: 1,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['always', { ignoreSelectors: ['a', '/a/', /a/] }],
- fix: true,
-
- accept: [
- {
- code: 'a { color: pink; }',
- },
- {
- code: 'a{ color: pink; }',
- },
- {
- code: 'a\n{ color: pink; }',
- },
- {
- code: 'a\r\n{ color: pink; }',
- },
- ],
-
- reject: [
- {
- code: 'b{ color: pink; }',
- fixed: 'b { color: pink; }',
- message: messages.expectedBefore(),
- line: 1,
- column: 1,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['never'],
- fix: true,
-
- accept: [
- {
- code: 'a{ color: pink; }',
- },
- {
- code: '@media print{ a{ color: pink; } }',
- },
- ],
-
- reject: [
- {
- code: 'a { color: pink; }',
- fixed: 'a{ color: pink; }',
- message: messages.rejectedBefore(),
- line: 1,
- column: 2,
- },
- {
- code: 'a { color: pink; }',
- fixed: 'a{ color: pink; }',
- message: messages.rejectedBefore(),
- line: 1,
- column: 3,
- },
- {
- code: 'a\t{ color: pink; }',
- fixed: 'a{ color: pink; }',
- message: messages.rejectedBefore(),
- line: 1,
- column: 2,
- },
- {
- code: 'a\n{ color: pink; }',
- fixed: 'a{ color: pink; }',
- message: messages.rejectedBefore(),
- line: 1,
- column: 2,
- },
- {
- code: 'a\r\n{ color: pink; }',
- fixed: 'a{ color: pink; }',
- description: 'CRLF',
- message: messages.rejectedBefore(),
- line: 1,
- column: 2,
- },
- {
- code: '@media print { a{ color: pink; } }',
- fixed: '@media print{ a{ color: pink; } }',
- message: messages.rejectedBefore(),
- line: 1,
- column: 13,
- },
- {
- code: '@media print{ a { color: pink; } }',
- fixed: '@media print{ a{ color: pink; } }',
- message: messages.rejectedBefore(),
- line: 1,
- column: 16,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['always-single-line'],
- fix: true,
-
- accept: [
- {
- code: 'a { color: pink; }',
- },
- {
- code: '@media print { a { color: pink; } }',
- },
- {
- code: 'a{ color:\npink; }',
- },
- {
- code: '@media print { a{ color:\npink; } }',
- },
- {
- code: '@media print{ a { color:\npink; } }',
- },
- {
- code: '@media print{\na { color: pink; } }',
- },
- ],
-
- reject: [
- {
- code: 'a{ color: pink; }',
- fixed: 'a { color: pink; }',
- message: messages.expectedBeforeSingleLine(),
- line: 1,
- column: 1,
- },
- {
- code: 'a { color: pink; }',
- fixed: 'a { color: pink; }',
- message: messages.expectedBeforeSingleLine(),
- line: 1,
- column: 3,
- },
- {
- code: 'a\t{ color: pink; }',
- fixed: 'a { color: pink; }',
- message: messages.expectedBeforeSingleLine(),
- line: 1,
- column: 2,
- },
- {
- code: 'a\n{ color: pink; }',
- fixed: 'a { color: pink; }',
- message: messages.expectedBeforeSingleLine(),
- line: 1,
- column: 2,
- },
- {
- code: 'a\r\n{ color: pink; }',
- fixed: 'a { color: pink; }',
- description: 'CRLF',
- message: messages.expectedBeforeSingleLine(),
- line: 1,
- column: 2,
- },
- {
- code: '@media print\n{ a { color: pink; } }',
- fixed: '@media print { a { color: pink; } }',
- message: messages.expectedBeforeSingleLine(),
- line: 1,
- column: 13,
- },
- {
- code: '@media print { a\n{ color: pink; } }',
- fixed: '@media print { a { color: pink; } }',
- message: messages.expectedBeforeSingleLine(),
- line: 1,
- column: 17,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['never-single-line'],
- fix: true,
-
- accept: [
- {
- code: 'a{ color: pink; }',
- },
- {
- code: '@media print{ a{ color: pink; } }',
- },
- {
- code: 'a { color:\npink; }',
- },
- {
- code: 'a { color:\r\npink; }',
- description: 'CRLF',
- },
- {
- code: '@media print { a { color:\npink; } }',
- },
- {
- code: '@media print{ a{ color:\npink; } }',
- },
- {
- code: '@media print {\na{ color: pink; } }',
- },
- {
- code: '@media print{\na{ color: pink; } }',
- },
- {
- code: '@media print{\r\na{ color: pink; } }',
- description: 'CRLF',
- },
- ],
-
- reject: [
- {
- code: 'a { color: pink; }',
- fixed: 'a{ color: pink; }',
- message: messages.rejectedBeforeSingleLine(),
- line: 1,
- column: 2,
- },
- {
- code: 'a { color: pink; }',
- fixed: 'a{ color: pink; }',
- message: messages.rejectedBeforeSingleLine(),
- line: 1,
- column: 3,
- },
- {
- code: 'a\t{ color: pink; }',
- fixed: 'a{ color: pink; }',
- message: messages.rejectedBeforeSingleLine(),
- line: 1,
- column: 2,
- },
- {
- code: 'a\n{ color: pink; }',
- fixed: 'a{ color: pink; }',
- message: messages.rejectedBeforeSingleLine(),
- line: 1,
- column: 2,
- },
- {
- code: 'a\r\n{ color: pink; }',
- fixed: 'a{ color: pink; }',
- description: 'CRLF',
- message: messages.rejectedBeforeSingleLine(),
- line: 1,
- column: 2,
- },
- {
- code: '@media print { a{ color: pink; } }',
- fixed: '@media print{ a{ color: pink; } }',
- message: messages.rejectedBeforeSingleLine(),
- line: 1,
- column: 13,
- },
- {
- code: '@media print{ a { color: pink; } }',
- fixed: '@media print{ a{ color: pink; } }',
- message: messages.rejectedBeforeSingleLine(),
- line: 1,
- column: 16,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['always-multi-line'],
- fix: true,
-
- accept: [
- {
- code: 'a { color: pink;\nbackground: orange; }',
- },
- {
- code: '@media print {\na { color: pink;\nbackground: orange } }',
- },
- {
- code: '@media print {\r\na { color: pink;\r\nbackground: orange } }',
- description: 'CRLF',
- },
- {
- code: 'a { color: pink; }',
- },
- {
- code: '@media print { a { color: pink; } }',
- },
- {
- code: 'a{ color: pink; }',
- },
- {
- code: 'a { color: pink; }',
- },
- {
- code: 'a\t{ color: pink; }',
- },
- ],
-
- reject: [
- {
- code: 'a{ color: pink;\nbackground: orange; }',
- fixed: 'a { color: pink;\nbackground: orange; }',
- message: messages.expectedBeforeMultiLine(),
- line: 1,
- column: 1,
- },
- {
- code: 'a { color: pink;\nbackground: orange; }',
- fixed: 'a { color: pink;\nbackground: orange; }',
- message: messages.expectedBeforeMultiLine(),
- line: 1,
- column: 3,
- },
- {
- code: 'a\t{ color: pink;\nbackground: orange; }',
- fixed: 'a { color: pink;\nbackground: orange; }',
- message: messages.expectedBeforeMultiLine(),
- line: 1,
- column: 2,
- },
- {
- code: 'a\n{ color: pink;\nbackground: orange; }',
- fixed: 'a { color: pink;\nbackground: orange; }',
- message: messages.expectedBeforeMultiLine(),
- line: 1,
- column: 2,
- },
- {
- code: 'a\r\n{ color: pink;\r\nbackground: orange; }',
- fixed: 'a { color: pink;\r\nbackground: orange; }',
- description: 'CRLF',
- message: messages.expectedBeforeMultiLine(),
- line: 1,
- column: 2,
- },
- {
- code: '@media print\n{\na { color: pink;\nbackground: orange; } }',
- fixed: '@media print {\na { color: pink;\nbackground: orange; } }',
- message: messages.expectedBeforeMultiLine(),
- line: 1,
- column: 13,
- },
- {
- code: '@media print { a\n{ color: pink;\nbackground: orange; } }',
- fixed: '@media print { a { color: pink;\nbackground: orange; } }',
- message: messages.expectedBeforeMultiLine(),
- line: 1,
- column: 17,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['never-multi-line'],
- fix: true,
-
- accept: [
- {
- code: 'a{ color: pink;\nbackground: orange; }',
- },
- {
- code: '@media print{\na{ color: pink;\nbackground: orange } }',
- },
- {
- code: '@media print{\r\na{ color: pink;\r\nbackground: orange } }',
- description: 'CRLF',
- },
- {
- code: 'a { color: pink; }',
- },
- {
- code: '@media print { a { color: pink; } }',
- },
- {
- code: 'a{ color: pink; }',
- },
- {
- code: 'a { color: pink; }',
- },
- {
- code: 'a\t{ color: pink; }',
- },
- ],
-
- reject: [
- {
- code: 'a { color: pink;\nbackground: orange; }',
- fixed: 'a{ color: pink;\nbackground: orange; }',
- message: messages.rejectedBeforeMultiLine(),
- line: 1,
- column: 2,
- },
- {
- code: 'a { color: pink;\nbackground: orange; }',
- fixed: 'a{ color: pink;\nbackground: orange; }',
- message: messages.rejectedBeforeMultiLine(),
- line: 1,
- column: 3,
- },
- {
- code: 'a\t{ color: pink;\nbackground: orange; }',
- fixed: 'a{ color: pink;\nbackground: orange; }',
- message: messages.rejectedBeforeMultiLine(),
- line: 1,
- column: 2,
- },
- {
- code: 'a\n{ color: pink;\nbackground: orange; }',
- fixed: 'a{ color: pink;\nbackground: orange; }',
- message: messages.rejectedBeforeMultiLine(),
- line: 1,
- column: 2,
- },
- {
- code: '@media print\n{\na{ color: pink;\nbackground: orange; } }',
- fixed: '@media print{\na{ color: pink;\nbackground: orange; } }',
- message: messages.rejectedBeforeMultiLine(),
- line: 1,
- column: 13,
- },
- {
- code: '@media print{ a\n{ color: pink;\nbackground: orange; } }',
- fixed: '@media print{ a{ color: pink;\nbackground: orange; } }',
- message: messages.rejectedBeforeMultiLine(),
- line: 1,
- column: 16,
- },
- {
- code: '@media print{ a\r\n{ color: pink;\r\nbackground: orange; } }',
- fixed: '@media print{ a{ color: pink;\r\nbackground: orange; } }',
- description: 'CRLF',
- message: messages.rejectedBeforeMultiLine(),
- line: 1,
- column: 16,
- },
- ],
-});
diff --git a/lib/rules/block-opening-brace-space-before/index.js b/lib/rules/block-opening-brace-space-before/index.js
deleted file mode 100644
index fcde4e48d0..0000000000
--- a/lib/rules/block-opening-brace-space-before/index.js
+++ /dev/null
@@ -1,139 +0,0 @@
-'use strict';
-
-const beforeBlockString = require('../../utils/beforeBlockString');
-const blockString = require('../../utils/blockString');
-const hasBlock = require('../../utils/hasBlock');
-const hasEmptyBlock = require('../../utils/hasEmptyBlock');
-const optionsMatches = require('../../utils/optionsMatches');
-const report = require('../../utils/report');
-const ruleMessages = require('../../utils/ruleMessages');
-const validateOptions = require('../../utils/validateOptions');
-const whitespaceChecker = require('../../utils/whitespaceChecker');
-const { isRegExp, isString } = require('../../utils/validateTypes');
-
-const ruleName = 'block-opening-brace-space-before';
-
-const messages = ruleMessages(ruleName, {
- expectedBefore: () => 'Expected single space before "{"',
- rejectedBefore: () => 'Unexpected whitespace before "{"',
- expectedBeforeSingleLine: () => 'Expected single space before "{" of a single-line block',
- rejectedBeforeSingleLine: () => 'Unexpected whitespace before "{" of a single-line block',
- expectedBeforeMultiLine: () => 'Expected single space before "{" of a multi-line block',
- rejectedBeforeMultiLine: () => 'Unexpected whitespace before "{" of a multi-line block',
-});
-
-const meta = {
- url: 'https://stylelint.io/user-guide/rules/block-opening-brace-space-before',
- fixable: true,
- deprecated: true,
-};
-
-/** @type {import('stylelint').Rule} */
-const rule = (primary, secondaryOptions, context) => {
- const checker = whitespaceChecker('space', primary, messages);
-
- return (root, result) => {
- const validOptions = validateOptions(
- result,
- ruleName,
- {
- actual: primary,
- possible: [
- 'always',
- 'never',
- 'always-single-line',
- 'never-single-line',
- 'always-multi-line',
- 'never-multi-line',
- ],
- },
- {
- actual: secondaryOptions,
- possible: {
- ignoreAtRules: [isString, isRegExp],
- ignoreSelectors: [isString, isRegExp],
- },
- optional: true,
- },
- );
-
- if (!validOptions) {
- return;
- }
-
- // Check both kinds of statements: rules and at-rules
- root.walkRules(check);
- root.walkAtRules(check);
-
- /**
- * @param {import('postcss').Rule | import('postcss').AtRule} statement
- */
- function check(statement) {
- // Return early if blockless or has an empty block
- if (!hasBlock(statement) || hasEmptyBlock(statement)) {
- return;
- }
-
- // Return early if at-rule is to be ignored
- if (
- statement.type === 'atrule' &&
- optionsMatches(secondaryOptions, 'ignoreAtRules', statement.name)
- ) {
- return;
- }
-
- // Return early if selector is to be ignored
- if (
- statement.type === 'rule' &&
- optionsMatches(secondaryOptions, 'ignoreSelectors', statement.selector)
- ) {
- return;
- }
-
- const source = beforeBlockString(statement);
- const beforeBraceNoRaw = beforeBlockString(statement, {
- noRawBefore: true,
- });
-
- let index = beforeBraceNoRaw.length - 1;
-
- if (beforeBraceNoRaw[index - 1] === '\r') {
- index -= 1;
- }
-
- checker.before({
- source,
- index: source.length,
- lineCheckStr: blockString(statement),
- err: (m) => {
- if (context.fix) {
- if (primary.startsWith('always')) {
- statement.raws.between = ' ';
-
- return;
- }
-
- if (primary.startsWith('never')) {
- statement.raws.between = '';
-
- return;
- }
- }
-
- report({
- message: m,
- node: statement,
- index,
- result,
- ruleName,
- });
- },
- });
- }
- };
-};
-
-rule.ruleName = ruleName;
-rule.messages = messages;
-rule.meta = meta;
-module.exports = rule;
diff --git a/lib/rules/color-hex-case/README.md b/lib/rules/color-hex-case/README.md
deleted file mode 100644
index 27fc375baf..0000000000
--- a/lib/rules/color-hex-case/README.md
+++ /dev/null
@@ -1,60 +0,0 @@
-# color-hex-case
-
-> **Warning** This rule is deprecated and will be removed in the future. See [the migration guide](../../../docs/migration-guide/to-15.md).
-
-Specify lowercase or uppercase for hex colors.
-
-
-```css
-a { color: #fff }
-/** ↑
- * This hex color */
-```
-
-The [`fix` option](../../../docs/user-guide/options.md#fix) can automatically fix all of the problems reported by this rule.
-
-## Options
-
-`string`: `"lower"|"upper"`
-
-### `"lower"`
-
-The following patterns are considered problems:
-
-
-```css
-a { color: #FFF; }
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { color: #000; }
-```
-
-
-```css
-a { color: #fff; }
-```
-
-### `"upper"`
-
-The following patterns are considered problems:
-
-
-```css
-a { color: #fff; }
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { color: #000; }
-```
-
-
-```css
-a { color: #FFF; }
-```
diff --git a/lib/rules/color-hex-case/__tests__/index.js b/lib/rules/color-hex-case/__tests__/index.js
deleted file mode 100644
index af5572a3f8..0000000000
--- a/lib/rules/color-hex-case/__tests__/index.js
+++ /dev/null
@@ -1,166 +0,0 @@
-'use strict';
-
-const mergeTestDescriptions = require('../../../testUtils/mergeTestDescriptions');
-
-const { messages, ruleName } = require('..');
-
-const sharedTests = {
- accept: [
- {
- code: 'a { border-#$side: 0; }',
- description: 'ignore sass-like interpolation',
- },
- {
- code: 'a { box-sizing: #$type-box; }',
- description: 'ignore sass-like interpolation',
- },
- {
- code: 'a { stroke: url(#gradientA) }',
- description: 'SVG reference interaction',
- },
- ],
-};
-
-testRule(
- mergeTestDescriptions(sharedTests, {
- ruleName,
- config: ['lower'],
- fix: true,
-
- accept: [
- {
- code: 'a { color: pink; }',
- },
- {
- code: 'a { color: #000; }',
- },
- {
- code: 'a { something: #000, #fff, #ababab; }',
- },
- {
- code: 'a { color: #0000ffcc; }',
- description: 'eight digits',
- },
- {
- code: 'a { color: #00fc; }',
- description: 'four digits',
- },
- {
- code: 'a { padding: 000; }',
- },
- {
- code: 'a::before { content: "#ABABA"; }',
- },
- {
- code: 'a { color: white /* #FFF */; }',
- },
- ],
-
- reject: [
- {
- code: 'a { color: #Ababa; }',
- fixed: 'a { color: #ababa; }',
-
- message: messages.expected('#Ababa', '#ababa'),
- line: 1,
- column: 12,
- },
- {
- code: 'a { something: #000F, #fff, #ababab; }',
- fixed: 'a { something: #000f, #fff, #ababab; }',
-
- message: messages.expected('#000F', '#000f'),
- line: 1,
- column: 16,
- },
- {
- code: 'a { something: #000, #FFFFAZ, #ababab; }',
- fixed: 'a { something: #000, #ffffaz, #ababab; }',
-
- message: messages.expected('#FFFFAZ', '#ffffaz'),
- line: 1,
- column: 22,
- },
- {
- code: 'a { something: #000, #fff, #12345AA; }',
- fixed: 'a { something: #000, #fff, #12345aa; }',
-
- message: messages.expected('#12345AA', '#12345aa'),
- line: 1,
- column: 28,
- },
- ],
- }),
-);
-
-testRule(
- mergeTestDescriptions(sharedTests, {
- ruleName,
- config: ['upper'],
- fix: true,
-
- accept: [
- {
- code: 'a { color: pink; }',
- },
- {
- code: 'a { color: #000; }',
- },
- {
- code: 'a { something: #000, #FFF, #ABABAB; }',
- },
- {
- code: 'a { color: #0000FFCC; }',
- description: 'eight digits',
- },
- {
- code: 'a { color: #00FC; }',
- description: 'four digits',
- },
- {
- code: 'a { padding: 000; }',
- },
- {
- code: 'a::before { content: "#ababa"; }',
- },
- {
- code: 'a { color: white /* #fff */; }',
- },
- ],
-
- reject: [
- {
- code: 'a { color: #aBABA; }',
- fixed: 'a { color: #ABABA; }',
-
- message: messages.expected('#aBABA', '#ABABA'),
- line: 1,
- column: 12,
- },
- {
- code: 'a { something: #000f, #FFF, #ABABAB; }',
- fixed: 'a { something: #000F, #FFF, #ABABAB; }',
-
- message: messages.expected('#000f', '#000F'),
- line: 1,
- column: 16,
- },
- {
- code: 'a { something: #000, #ffffaz, #ABABAB; }',
- fixed: 'a { something: #000, #FFFFAZ, #ABABAB; }',
-
- message: messages.expected('#ffffaz', '#FFFFAZ'),
- line: 1,
- column: 22,
- },
- {
- code: 'a { something: #000, #FFF, #12345aa; }',
- fixed: 'a { something: #000, #FFF, #12345AA; }',
-
- message: messages.expected('#12345aa', '#12345AA'),
- line: 1,
- column: 28,
- },
- ],
- }),
-);
diff --git a/lib/rules/color-hex-case/index.js b/lib/rules/color-hex-case/index.js
deleted file mode 100644
index 662a14f18c..0000000000
--- a/lib/rules/color-hex-case/index.js
+++ /dev/null
@@ -1,97 +0,0 @@
-'use strict';
-
-const valueParser = require('postcss-value-parser');
-
-const declarationValueIndex = require('../../utils/declarationValueIndex');
-const getDeclarationValue = require('../../utils/getDeclarationValue');
-const report = require('../../utils/report');
-const ruleMessages = require('../../utils/ruleMessages');
-const setDeclarationValue = require('../../utils/setDeclarationValue');
-const validateOptions = require('../../utils/validateOptions');
-
-const ruleName = 'color-hex-case';
-
-const messages = ruleMessages(ruleName, {
- expected: (actual, expected) => `Expected "${actual}" to be "${expected}"`,
-});
-
-const meta = {
- url: 'https://stylelint.io/user-guide/rules/color-hex-case',
- fixable: true,
- deprecated: true,
-};
-
-const HEX = /^#[\da-z]+/i;
-const CONTAINS_HEX = /#[\da-z]+/i;
-const IGNORED_FUNCTIONS = new Set(['url']);
-
-/** @type {import('stylelint').Rule} */
-const rule = (primary, _secondaryOptions, context) => {
- return (root, result) => {
- const validOptions = validateOptions(result, ruleName, {
- actual: primary,
- possible: ['lower', 'upper'],
- });
-
- if (!validOptions) {
- return;
- }
-
- root.walkDecls((decl) => {
- if (!CONTAINS_HEX.test(decl.value)) return;
-
- const parsedValue = valueParser(getDeclarationValue(decl));
- let needsFix = false;
-
- parsedValue.walk((node) => {
- const { value } = node;
-
- if (isIgnoredFunction(node)) return false;
-
- if (!isHexColor(node)) return;
-
- const expected = primary === 'lower' ? value.toLowerCase() : value.toUpperCase();
-
- if (value === expected) return;
-
- if (context.fix) {
- node.value = expected;
- needsFix = true;
-
- return;
- }
-
- report({
- message: messages.expected(value, expected),
- node: decl,
- index: declarationValueIndex(decl) + node.sourceIndex,
- result,
- ruleName,
- });
- });
-
- if (needsFix) {
- setDeclarationValue(decl, parsedValue.toString());
- }
- });
- };
-};
-
-/**
- * @param {import('postcss-value-parser').Node} node
- */
-function isIgnoredFunction({ type, value }) {
- return type === 'function' && IGNORED_FUNCTIONS.has(value.toLowerCase());
-}
-
-/**
- * @param {import('postcss-value-parser').Node} node
- */
-function isHexColor({ type, value }) {
- return type === 'word' && HEX.test(value);
-}
-
-rule.ruleName = ruleName;
-rule.messages = messages;
-rule.meta = meta;
-module.exports = rule;
diff --git a/lib/rules/comment-empty-line-before/README.md b/lib/rules/comment-empty-line-before/README.md
index 6cc7b69a80..726cd460dd 100644
--- a/lib/rules/comment-empty-line-before/README.md
+++ b/lib/rules/comment-empty-line-before/README.md
@@ -18,7 +18,7 @@ This rule ignores:
- single-line comments with `//` (when you're using a custom syntax that supports them)
- comments within selector and value lists
-The [`fix` option](../../../docs/user-guide/options.md#fix) can automatically fix all of the problems reported by this rule. We recommend to enable [`indentation`](../indentation/README.md) rule for better autofixing results with this rule.
+The [`fix` option](../../../docs/user-guide/options.md#fix) can automatically fix all of the problems reported by this rule.
## Options
diff --git a/lib/rules/custom-property-empty-line-before/README.md b/lib/rules/custom-property-empty-line-before/README.md
index 127fbc2227..d608226430 100644
--- a/lib/rules/custom-property-empty-line-before/README.md
+++ b/lib/rules/custom-property-empty-line-before/README.md
@@ -13,7 +13,7 @@ a {
* This line */
```
-The [`fix` option](../../../docs/user-guide/options.md#fix) can automatically fix all of the problems reported by this rule. We recommend to enable [`indentation`](../indentation/README.md) rule for better autofixing results with this rule.
+The [`fix` option](../../../docs/user-guide/options.md#fix) can automatically fix all of the problems reported by this rule.
## Options
diff --git a/lib/rules/declaration-bang-space-after/README.md b/lib/rules/declaration-bang-space-after/README.md
deleted file mode 100644
index 599c731a47..0000000000
--- a/lib/rules/declaration-bang-space-after/README.md
+++ /dev/null
@@ -1,74 +0,0 @@
-# declaration-bang-space-after
-
-> **Warning** This rule is deprecated and will be removed in the future. See [the migration guide](../../../docs/migration-guide/to-15.md).
-
-Require a single space or disallow whitespace after the bang of declarations.
-
-
-```css
-a { color: pink !important; }
-/** ↑
- * The space after this exclamation mark */
-```
-
-The [`fix` option](../../../docs/user-guide/options.md#fix) can automatically fix all of the problems reported by this rule.
-
-## Options
-
-`string`: `"always"|"never"`
-
-### `"always"`
-
-There _must always_ be a single space after the bang.
-
-The following patterns are considered problems:
-
-
-```css
-a { color: pink !important; }
-```
-
-
-```css
-a { color: pink !important; }
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { color: pink ! important; }
-```
-
-
-```css
-a { color: pink! important; }
-```
-
-### `"never"`
-
-There _must never_ be whitespace after the bang.
-
-The following patterns are considered problems:
-
-
-```css
-a { color: pink ! important; }
-```
-
-
-```css
-a { color: pink! important; }
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { color: pink !important; }
-```
-
-
-```css
-a { color:pink!important; }
-```
diff --git a/lib/rules/declaration-bang-space-after/__tests__/index.js b/lib/rules/declaration-bang-space-after/__tests__/index.js
deleted file mode 100644
index 0ead24fa07..0000000000
--- a/lib/rules/declaration-bang-space-after/__tests__/index.js
+++ /dev/null
@@ -1,163 +0,0 @@
-'use strict';
-
-const { messages, ruleName } = require('..');
-
-testRule({
- ruleName,
- config: ['always'],
- fix: true,
-
- accept: [
- {
- code: 'a { color: pink; }',
- description: 'no !important',
- },
- {
- code: 'a { color: pink! important; }',
- description: 'space only after',
- },
- {
- code: 'a { color: pink ! default; }',
- description: 'space before and after',
- },
- {
- code: 'a { color: pink\n! important; }',
- description: 'newline before and space after',
- },
- {
- code: 'a { color: pink\r\n! optional; }',
- description: 'CRLF before and space after',
- },
- {
- code: 'a::before { content: "!!!" ! important; }',
- description: 'ignores string',
- },
- {
- code: 'a { color: pink /* !important */;}',
- description: 'violating comment',
- },
- ],
-
- reject: [
- {
- code: 'a { color: pink!important; }',
- fixed: 'a { color: pink! important; }',
- description: 'no space after',
- message: messages.expectedAfter(),
- line: 1,
- column: 16,
- },
- {
- code: 'a { color: pink! global; }',
- fixed: 'a { color: pink! global; }',
- description: 'two spaces after',
- message: messages.expectedAfter(),
- line: 1,
- column: 16,
- },
- {
- code: 'a { color: pink!\nimportant; }',
- fixed: 'a { color: pink! important; }',
- description: 'newline after',
- message: messages.expectedAfter(),
- line: 1,
- column: 16,
- },
- {
- code: 'a { color: pink!\r\nexciting; }',
- fixed: 'a { color: pink! exciting; }',
- description: 'CRLF after',
- message: messages.expectedAfter(),
- line: 1,
- column: 16,
- },
- {
- code: 'a { color: pink !/*comment*/important; }',
- fixed: 'a { color: pink ! /*comment*/important; }',
- description: 'comment after',
- message: messages.expectedAfter(),
- line: 1,
- column: 17,
- },
- {
- code: 'a { color: pink !/*comment*/global; }',
- fixed: 'a { color: pink ! /*comment*/global; }',
- description: 'comment after',
- message: messages.expectedAfter(),
- line: 1,
- column: 17,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['never'],
- fix: true,
-
- accept: [
- {
- code: 'a { color: pink; }',
- description: 'no !important',
- },
- {
- code: 'a { color: pink!important; }',
- description: 'no space before or after',
- },
- {
- code: 'a { color: pink !important; }',
- description: 'space before and none after',
- },
- {
- code: 'a { color: pink\n!important; }',
- description: 'newline before and none after',
- },
- {
- code: 'a { color: pink\r\n!important; }',
- description: 'CRLF before and none after',
- },
- ],
-
- reject: [
- {
- code: 'a { color: pink! important; }',
- fixed: 'a { color: pink!important; }',
- description: 'space after',
- message: messages.rejectedAfter(),
- line: 1,
- column: 16,
- },
- {
- code: 'a { color: pink!\nimportant; }',
- fixed: 'a { color: pink!important; }',
- description: 'newline after',
- message: messages.rejectedAfter(),
- line: 1,
- column: 16,
- },
- {
- code: 'a { color: pink!\r\nimportant; }',
- fixed: 'a { color: pink!important; }',
- description: 'CRLF after',
- message: messages.rejectedAfter(),
- line: 1,
- column: 16,
- },
- {
- code: 'a { color: pink ! /*comment*/important; }',
- fixed: 'a { color: pink !/*comment*/important; }',
- description: 'comment after',
- message: messages.rejectedAfter(),
- line: 1,
- column: 17,
- },
- {
- code: 'a { color: pink ! /*comment*/global; }',
- fixed: 'a { color: pink !/*comment*/global; }',
- description: 'comment after',
- message: messages.rejectedAfter(),
- line: 1,
- column: 17,
- },
- ],
-});
diff --git a/lib/rules/declaration-bang-space-after/index.js b/lib/rules/declaration-bang-space-after/index.js
deleted file mode 100644
index 6ce8334333..0000000000
--- a/lib/rules/declaration-bang-space-after/index.js
+++ /dev/null
@@ -1,91 +0,0 @@
-'use strict';
-
-const declarationBangSpaceChecker = require('../declarationBangSpaceChecker');
-const declarationValueIndex = require('../../utils/declarationValueIndex');
-const getDeclarationValue = require('../../utils/getDeclarationValue');
-const ruleMessages = require('../../utils/ruleMessages');
-const setDeclarationValue = require('../../utils/setDeclarationValue');
-const validateOptions = require('../../utils/validateOptions');
-const whitespaceChecker = require('../../utils/whitespaceChecker');
-
-const ruleName = 'declaration-bang-space-after';
-
-const messages = ruleMessages(ruleName, {
- expectedAfter: () => 'Expected single space after "!"',
- rejectedAfter: () => 'Unexpected whitespace after "!"',
-});
-
-const meta = {
- url: 'https://stylelint.io/user-guide/rules/declaration-bang-space-after',
- fixable: true,
- deprecated: true,
-};
-
-/** @type {import('stylelint').Rule} */
-const rule = (primary, _secondaryOptions, context) => {
- const checker = whitespaceChecker('space', primary, messages);
-
- return (root, result) => {
- const validOptions = validateOptions(result, ruleName, {
- actual: primary,
- possible: ['always', 'never'],
- });
-
- if (!validOptions) {
- return;
- }
-
- declarationBangSpaceChecker({
- root,
- result,
- locationChecker: checker.after,
- checkedRuleName: ruleName,
- fix: context.fix
- ? (decl, index) => {
- let bangIndex = index - declarationValueIndex(decl);
- const declValue = getDeclarationValue(decl);
- let target;
- /** @type {(value: string) => void} */
- let setFixed;
-
- if (bangIndex < declValue.length) {
- target = declValue;
- setFixed = (value) => {
- setDeclarationValue(decl, value);
- };
- } else if (decl.important) {
- target = decl.raws.important || ' !important';
- bangIndex -= declValue.length;
- setFixed = (value) => {
- decl.raws.important = value;
- };
- } else {
- return false; // not standard
- }
-
- const targetBefore = target.slice(0, bangIndex + 1);
- const targetAfter = target.slice(bangIndex + 1);
-
- if (primary === 'always') {
- setFixed(targetBefore + targetAfter.replace(/^\s*/, ' '));
-
- return true;
- }
-
- if (primary === 'never') {
- setFixed(targetBefore + targetAfter.replace(/^\s*/, ''));
-
- return true;
- }
-
- return false;
- }
- : null,
- });
- };
-};
-
-rule.ruleName = ruleName;
-rule.messages = messages;
-rule.meta = meta;
-module.exports = rule;
diff --git a/lib/rules/declaration-bang-space-before/README.md b/lib/rules/declaration-bang-space-before/README.md
deleted file mode 100644
index 6947bff328..0000000000
--- a/lib/rules/declaration-bang-space-before/README.md
+++ /dev/null
@@ -1,69 +0,0 @@
-# declaration-bang-space-before
-
-> **Warning** This rule is deprecated and will be removed in the future. See [the migration guide](../../../docs/migration-guide/to-15.md).
-
-Require a single space or disallow whitespace before the bang of declarations.
-
-
-```css
-a { color: pink !important; }
-/** ↑
- * The space before this exclamation mark */
-```
-
-The [`fix` option](../../../docs/user-guide/options.md#fix) can automatically fix all of the problems reported by this rule.
-
-## Options
-
-`string`: `"always"|"never"`
-
-### `"always"`
-
-There _must always_ be a single space before the bang.
-
-The following patterns are considered problems:
-
-
-```css
-a { color: pink!important; }
-```
-
-
-```css
-a { color: pink ! important; }
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { color: pink !important; }
-```
-
-
-```css
-a { color:pink ! important; }
-```
-
-### `"never"`
-
-There _must never_ be whitespace before the bang.
-
-The following patterns are considered problems:
-
-
-```css
-a { color : pink !important; }
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { color: pink!important; }
-```
-
-
-```css
-a { color: pink! important; }
-```
diff --git a/lib/rules/declaration-bang-space-before/__tests__/index.js b/lib/rules/declaration-bang-space-before/__tests__/index.js
deleted file mode 100644
index f98458d60e..0000000000
--- a/lib/rules/declaration-bang-space-before/__tests__/index.js
+++ /dev/null
@@ -1,229 +0,0 @@
-'use strict';
-
-const { messages, ruleName } = require('..');
-
-testRule({
- ruleName,
- config: ['always'],
- fix: true,
-
- accept: [
- {
- code: 'a { color: pink; }',
- description: 'no !important',
- },
- {
- code: 'a { color: pink !important; }',
- description: 'space only before',
- },
- {
- code: 'a { color: pink ! important; }',
- description: 'space before and after',
- },
- {
- code: 'a { color: pink !\noptional; }',
- description: 'space before and newline after',
- },
- {
- code: 'a { color: pink !\r\nimportant; }',
- description: 'space before and CRLF after',
- },
- {
- code: 'a::before { content: "!!!" !default; }',
- description: 'ignores string',
- },
- {
- code: 'a { color: pink/*!important */;}',
- description: 'violating comment',
- },
- ],
-
- reject: [
- {
- code: 'a { color: pink !important; }',
- fixed: 'a { color: pink !important; }',
- description: 'two spaces before',
- message: messages.expectedBefore(),
- line: 1,
- column: 18,
- },
- {
- code: 'a { color: pink!default; }',
- fixed: 'a { color: pink !default; }',
- description: 'no space before',
- message: messages.expectedBefore(),
- line: 1,
- column: 16,
- },
- {
- code: 'a { color: pink\n!important; }',
- fixed: 'a { color: pink !important; }',
- description: 'newline before',
- message: messages.expectedBefore(),
- line: 2,
- column: 1,
- },
- {
- code: 'a { color: pink\r\n!something; }',
- fixed: 'a { color: pink !something; }',
- description: 'CRLF before',
- message: messages.expectedBefore(),
- line: 2,
- column: 1,
- },
- {
- code: 'a { color: pink/*comment*/!important; }',
- fixed: 'a { color: pink/*comment*/ !important; }',
- description: 'comment before',
- message: messages.expectedBefore(),
- line: 1,
- column: 27,
- },
- {
- code: 'a { color: pink/*comment*/!something; }',
- fixed: 'a { color: pink/*comment*/ !something; }',
- description: 'comment before',
- message: messages.expectedBefore(),
- line: 1,
- column: 27,
- },
- {
- code: 'a { color: pink\n/*comment*/!important; }',
- fixed: 'a { color: pink\n/*comment*/ !important; }',
- description: 'comment before',
- message: messages.expectedBefore(),
- line: 2,
- column: 12,
- },
- {
- code: 'a { color: pink\n/*comment*/!something; }',
- fixed: 'a { color: pink\n/*comment*/ !something; }',
- description: 'comment before',
- message: messages.expectedBefore(),
- line: 2,
- column: 12,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['never'],
- fix: true,
-
- accept: [
- {
- code: 'a { color: pink; }',
- description: 'no !important',
- },
- {
- code: 'a { color: pink!important; }',
- description: 'no spaces',
- },
- {
- code: 'a { color: pink! important; }',
- description: 'no space before and after',
- },
- {
- code: 'a { color: pink!\nimportant; }',
- description: 'no space before and newline after',
- },
- {
- code: 'a { color: pink!\r\nimportant; }',
- description: 'no space before and CRLF after',
- },
- ],
-
- reject: [
- {
- code: 'a { color: pink !important; }',
- fixed: 'a { color: pink!important; }',
- description: 'space before',
- message: messages.rejectedBefore(),
- line: 1,
- column: 17,
- },
- {
- code: 'a { color: pink\n!important; }',
- fixed: 'a { color: pink!important; }',
- description: 'newline before',
- message: messages.rejectedBefore(),
- line: 2,
- column: 1,
- },
- {
- code: 'a { color: pink\r\n!important; }',
- fixed: 'a { color: pink!important; }',
- description: 'CRLF before',
- message: messages.rejectedBefore(),
- line: 2,
- column: 1,
- },
- {
- code: 'a { color: pink/*comment*/ !important; }',
- fixed: 'a { color: pink/*comment*/!important; }',
- description: 'comment before',
- message: messages.rejectedBefore(),
- line: 1,
- column: 28,
- },
- {
- code: 'a { color: pink/*comment*/ !something; }',
- fixed: 'a { color: pink/*comment*/!something; }',
- description: 'comment before',
- message: messages.rejectedBefore(),
- line: 1,
- column: 28,
- },
- {
- code: 'a { color: pink\n/*comment*/\n!important; }',
- fixed: 'a { color: pink\n/*comment*/!important; }',
- description: 'comment before',
- message: messages.rejectedBefore(),
- line: 3,
- column: 1,
- },
- {
- code: 'a { color: pink\n/*comment*/\n!something; }',
- fixed: 'a { color: pink\n/*comment*/!something; }',
- description: 'comment before',
- message: messages.rejectedBefore(),
- line: 3,
- column: 1,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['always'],
- customSyntax: 'postcss-sass',
- fix: true,
-
- reject: [
- {
- code: '$color: pink!default',
- fixed: '$color: pink !default',
- message: messages.expectedBefore(),
- line: 1,
- column: 13,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['never'],
- customSyntax: 'postcss-sass',
- fix: true,
-
- reject: [
- {
- code: '$color: pink !default',
- fixed: '$color: pink!default',
- message: messages.rejectedBefore(),
- line: 1,
- column: 14,
- },
- ],
-});
diff --git a/lib/rules/declaration-bang-space-before/index.js b/lib/rules/declaration-bang-space-before/index.js
deleted file mode 100644
index 3d6216f485..0000000000
--- a/lib/rules/declaration-bang-space-before/index.js
+++ /dev/null
@@ -1,92 +0,0 @@
-'use strict';
-
-const declarationBangSpaceChecker = require('../declarationBangSpaceChecker');
-const declarationValueIndex = require('../../utils/declarationValueIndex');
-const getDeclarationValue = require('../../utils/getDeclarationValue');
-const ruleMessages = require('../../utils/ruleMessages');
-const setDeclarationValue = require('../../utils/setDeclarationValue');
-const validateOptions = require('../../utils/validateOptions');
-const whitespaceChecker = require('../../utils/whitespaceChecker');
-
-const ruleName = 'declaration-bang-space-before';
-
-const messages = ruleMessages(ruleName, {
- expectedBefore: () => 'Expected single space before "!"',
- rejectedBefore: () => 'Unexpected whitespace before "!"',
-});
-
-const meta = {
- url: 'https://stylelint.io/user-guide/rules/declaration-bang-space-before',
- fixable: true,
- deprecated: true,
-};
-
-/** @type {import('stylelint').Rule} */
-const rule = (primary, _secondaryOptions, context) => {
- const checker = whitespaceChecker('space', primary, messages);
-
- return (root, result) => {
- const validOptions = validateOptions(result, ruleName, {
- actual: primary,
- possible: ['always', 'never'],
- });
-
- if (!validOptions) {
- return;
- }
-
- declarationBangSpaceChecker({
- root,
- result,
- locationChecker: checker.before,
- checkedRuleName: ruleName,
- fix: context.fix
- ? (decl, index) => {
- let bangIndex = index - declarationValueIndex(decl);
- const value = getDeclarationValue(decl);
- let target;
- /** @type {(val: string) => void} */
- let setFixed;
-
- if (bangIndex < value.length) {
- target = value;
- setFixed = (val) => {
- setDeclarationValue(decl, val);
- };
- } else if (decl.important) {
- target = decl.raws.important || ' !important';
- bangIndex -= value.length;
- setFixed = (val) => {
- decl.raws.important = val;
- };
- } else {
- return false; // not standard
- }
-
- const targetBefore = target.slice(0, bangIndex);
- const targetAfter = target.slice(bangIndex);
-
- if (primary === 'always') {
- // eslint-disable-next-line prefer-template
- setFixed(targetBefore.replace(/\s*$/, '') + ' ' + targetAfter);
-
- return true;
- }
-
- if (primary === 'never') {
- setFixed(targetBefore.replace(/\s*$/, '') + targetAfter);
-
- return true;
- }
-
- return false;
- }
- : null,
- });
- };
-};
-
-rule.ruleName = ruleName;
-rule.messages = messages;
-rule.meta = meta;
-module.exports = rule;
diff --git a/lib/rules/declaration-block-semicolon-newline-after/README.md b/lib/rules/declaration-block-semicolon-newline-after/README.md
deleted file mode 100644
index 2466458bea..0000000000
--- a/lib/rules/declaration-block-semicolon-newline-after/README.md
+++ /dev/null
@@ -1,143 +0,0 @@
-# declaration-block-semicolon-newline-after
-
-> **Warning** This rule is deprecated and will be removed in the future. See [the migration guide](../../../docs/migration-guide/to-15.md).
-
-Require a newline or disallow whitespace after the semicolons of declaration blocks.
-
-
-```css
-a {
- color: pink;
- top: 0; ↑
-} ↑
-/** ↑
- * The newline after this semicolon */
-```
-
-This rule ignores:
-
-- semicolons that are preceded by Less mixins
-- the last semicolon of declaration blocks
-
-Use the `block-closing-brace-*-before` rules to control the whitespace between the last semicolon and the closing brace instead.
-
-This rule allows an end-of-line comment followed by a newline. For example,
-
-
-```css
-a {
- color: pink; /* end-of-line comment */
- top: 0;
-}
-```
-
-The [`fix` option](../../../docs/user-guide/options.md#fix) can automatically fix all of the problems reported by this rule.
-
-## Options
-
-`string`: `"always"|"always-multi-line"|"never-multi-line"`
-
-### `"always"`
-
-There _must always_ be a newline after the semicolon.
-
-The following patterns are considered problems:
-
-
-```css
-a { color: pink; top: 0; }
-```
-
-
-```css
-a {
- color: pink; /* end-of-line comment
- containing a newline */
- top: 0;
-}
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a {
- color: pink;
- top: 0;
-}
-```
-
-
-```css
-a {
- color: pink; /* end-of-line comment */
- top: 0;
-}
-```
-
-### `"always-multi-line"`
-
-There _must always_ be a newline after the semicolon in multi-line rules.
-
-The following patterns are considered problems:
-
-
-```css
-a {
- color: pink; top: 0;
-}
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { color: pink; }
-```
-
-
-```css
-a { color: pink; top: 0; }
-```
-
-
-```css
-a {
- color: pink;
- top: 0;
-}
-```
-
-### `"never-multi-line"`
-
-There _must never_ be whitespace after the semicolon in multi-line rules.
-
-The following patterns are considered problems:
-
-
-```css
-a {
- color: pink;
- top: 0;
-}
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { color: pink; }
-```
-
-
-```css
-a { color: pink; top: 0; }
-```
-
-
-```css
-a {
- color: pink
- ; top: 0;
-}
-```
diff --git a/lib/rules/declaration-block-semicolon-newline-after/__tests__/index.js b/lib/rules/declaration-block-semicolon-newline-after/__tests__/index.js
deleted file mode 100644
index 11427abf22..0000000000
--- a/lib/rules/declaration-block-semicolon-newline-after/__tests__/index.js
+++ /dev/null
@@ -1,346 +0,0 @@
-'use strict';
-
-const { messages, ruleName } = require('..');
-
-testRule({
- ruleName,
- config: ['always'],
- fix: true,
-
- accept: [
- {
- code: 'a { color: pink;\n}',
- },
- {
- code: 'a { color: pink;\r\n}',
- description: 'CRLF',
- },
- {
- code: 'a { color: pink;\n\n}',
- },
- {
- code: 'a { color: pink;\r\n\r\n}',
- description: 'CRLF',
- },
- {
- code: 'a::before { content: ";a";\n}',
- },
- {
- code: 'a {\ncolor: pink;\n top:0;\n}',
- },
- {
- code: 'a {\ncolor: pink;\n top:0;\n}',
- },
- {
- code: 'a {\ncolor: pink;\n\ttop:0;\n}',
- },
- {
- code: 'a {\r\ncolor: pink;\r\n\ttop:0;\r\n}',
- description: 'CRLF',
- },
- {
- code: 'a { color: pink;\ntop: 0; }',
- description: 'space between trailing semicolon and closing brace',
- },
- {
- code: 'a { color: pink;\ntop: 0;}',
- description: 'no space between trailing semicolon and closing brace',
- },
- {
- code: 'a { color: pink;\r\ntop: 0;}',
- description: 'no space between trailing semicolon and closing brace and CRLF',
- },
- {
- code: 'a { color: pink;\ntop: 0}',
- },
- {
- code: 'a {\n color: pink; /* 1 */\n top: 0\n}',
- description: 'end-of-line comment',
- },
- {
- code: 'a {\n color: pink; /* 1 */\n top: 0\n}',
- description: 'end-of-line comment a few spaces after',
- },
- {
- code: 'a {\r\n color: pink;\t/* 1 */\r\n top: 0\r\n}',
- description: 'end-of-line comment and CRLF',
- },
- {
- code: 'a {\n color: pink;\n /* 1 */\n top: 0\n}',
- description: 'next-line comment',
- },
- {
- code: 'a,\nb { color: pink;\ntop: 0}',
- description: 'multi-line rule, multi-line declaration-block',
- },
- {
- code: 'a,\r\nb { color: pink;\r\ntop: 0}',
- description: 'multi-line rule, multi-line declaration-block and CRLF',
- },
- ],
-
- reject: [
- {
- code: 'a { color: pink;top: 0; }',
- fixed: 'a { color: pink;\ntop: 0; }',
- message: messages.expectedAfter(),
- line: 1,
- column: 17,
- },
- {
- code: 'a { color: pink; top: 0; }',
- fixed: 'a { color: pink;\n top: 0; }',
- message: messages.expectedAfter(),
- line: 1,
- column: 17,
- },
- {
- code: 'a { color: pink; top: 0; }',
- fixed: 'a { color: pink;\n top: 0; }',
- message: messages.expectedAfter(),
- line: 1,
- column: 17,
- },
- {
- code: 'a { color: pink;\ttop: 0; }',
- fixed: 'a { color: pink;\n\ttop: 0; }',
- message: messages.expectedAfter(),
- line: 1,
- column: 17,
- },
- {
- code: 'a {\n color: pink; /* 1 */ top: 0\n}',
- fixed: 'a {\n color: pink; /* 1 */\n top: 0\n}',
- description: 'next node is comment without newline after',
- message: messages.expectedAfter(),
- line: 2,
- column: 15,
- },
- {
- code: 'a {\r\n color: pink; /* 1 */ top: 0\r\n}',
- fixed: 'a {\r\n color: pink; /* 1 */\r\n top: 0\r\n}',
- description: 'CRLF and next node is comment without newline after',
- message: messages.expectedAfter(),
- line: 2,
- column: 15,
- },
- {
- code: 'a { color: pink; \n top: 0; }',
- fixed: 'a { color: pink;\n top: 0; }',
- message: messages.expectedAfter(),
- line: 1,
- column: 17,
- },
- {
- code: 'a {\n color: pink; /* 1 */ /* 2 */ top: 0\n}',
- fixed: 'a {\n color: pink; /* 1 */ /* 2 */\n top: 0\n}',
- description: 'next*2 node is comment',
- message: messages.expectedAfter(),
- line: 2,
- column: 15,
- },
- {
- code: 'a {\n color: pink; /* 1 */ \n top: 0\n}',
- fixed: 'a {\n color: pink; /* 1 */\n top: 0\n}',
- message: messages.expectedAfter(),
- line: 2,
- column: 15,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['always-multi-line'],
- fix: true,
-
- accept: [
- {
- code: 'a {\ncolor: pink;\n}',
- },
- {
- code: 'a::before {\ncontent: ";a";\n}',
- },
- {
- code: 'a::before {\r\ncontent: ";a";\r\n}',
- description: 'CRLF',
- },
- {
- code: 'a {\ncolor: pink;\n top:0;\n}',
- },
- {
- code: 'a {\ncolor: pink;\n top:0;\n}',
- },
- {
- code: 'a {\r\ncolor: pink;\r\n top:0;\r\n}',
- description: 'CRLF',
- },
- {
- code: 'a {\ncolor: pink;\n\ttop:0;\n}',
- },
- {
- code: 'a {\ncolor: pink;\ntop: 0; }',
- description: 'space between trailing semicolon and closing brace',
- },
- {
- code: 'a {\ncolor: pink;\ntop: 0;}',
- description: 'no space between trailing semicolon and closing brace',
- },
- {
- code: 'a { color: pink; top: 0; }',
- },
- {
- code: 'a { color: pink; /* 1 */ top: 0; }',
- },
- {
- code: 'a,\nb { color: pink; top: 0}',
- description: 'multi-line rule, single-line declaration-block',
- },
- {
- code: 'a,\r\nb { color: pink; top: 0}',
- description: 'multi-line rule, single-line declaration-block and CRLF',
- },
- ],
-
- reject: [
- {
- code: 'a {\ncolor: pink;top: 0;\n}',
- fixed: 'a {\ncolor: pink;\ntop: 0;\n}',
- message: messages.expectedAfterMultiLine(),
- line: 2,
- column: 13,
- },
- {
- code: 'a {\ncolor: pink; top: 0;\n}',
- fixed: 'a {\ncolor: pink;\n top: 0;\n}',
- message: messages.expectedAfterMultiLine(),
- line: 2,
- column: 13,
- },
- {
- code: 'a {\r\ncolor: pink; top: 0;\r\n}',
- fixed: 'a {\r\ncolor: pink;\r\n top: 0;\r\n}',
- description: 'CRLF',
- message: messages.expectedAfterMultiLine(),
- line: 2,
- column: 13,
- },
- {
- code: 'a {\ncolor: pink; top: 0;\n}',
- fixed: 'a {\ncolor: pink;\n top: 0;\n}',
- message: messages.expectedAfterMultiLine(),
- line: 2,
- column: 13,
- },
- {
- code: 'a {\ncolor: pink;\ttop: 0;\n}',
- fixed: 'a {\ncolor: pink;\n\ttop: 0;\n}',
- message: messages.expectedAfterMultiLine(),
- line: 2,
- column: 13,
- },
- {
- code: 'a {\r\ncolor: pink;\ttop: 0;\r\n}',
- fixed: 'a {\r\ncolor: pink;\r\n\ttop: 0;\r\n}',
- description: 'CRLF',
- message: messages.expectedAfterMultiLine(),
- line: 2,
- column: 13,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['never-multi-line'],
- fix: true,
-
- accept: [
- {
- code: 'a {\ncolor: pink;\n}',
- },
- {
- code: 'a {\r\ncolor: pink;\r\n}',
- description: 'CRLF',
- },
- {
- code: 'a::before {\ncontent: ";\na";\n}',
- },
- {
- code: 'a {\ncolor: pink;top: 0; }',
- description: 'space between trailing semicolon and closing brace',
- },
- {
- code: 'a {\ncolor: pink;top: 0;}',
- description: 'no space between trailing semicolon and closing brace',
- },
- {
- code: 'a { color: pink; top: 0; }',
- },
- {
- code: 'a,\nb { color: pink; top: 0}',
- description: 'multi-line rule, single-line declaration-block',
- },
- ],
-
- reject: [
- {
- code: 'a {\ncolor: pink; top: 0;\n}',
- fixed: 'a {\ncolor: pink;top: 0;\n}',
- message: messages.rejectedAfterMultiLine(),
- line: 2,
- column: 13,
- },
- {
- code: 'a {\ncolor: pink; top: 0;\n}',
- fixed: 'a {\ncolor: pink;top: 0;\n}',
- message: messages.rejectedAfterMultiLine(),
- line: 2,
- column: 13,
- },
- {
- code: 'a {\ncolor: pink;\ntop: 0;\n}',
- fixed: 'a {\ncolor: pink;top: 0;\n}',
- message: messages.rejectedAfterMultiLine(),
- line: 2,
- column: 13,
- },
- {
- code: 'a {\r\ncolor: pink;\r\ntop: 0;\r\n}',
- fixed: 'a {\r\ncolor: pink;top: 0;\r\n}',
- description: 'CRLF',
- message: messages.rejectedAfterMultiLine(),
- line: 2,
- column: 13,
- },
- {
- code: 'a {\ncolor: pink;\ttop: 0;\n}',
- fixed: 'a {\ncolor: pink;top: 0;\n}',
- message: messages.rejectedAfterMultiLine(),
- line: 2,
- column: 13,
- },
- {
- code: 'a {\ncolor: pink; /*comment*/ top: 0;\n}',
- fixed: 'a {\ncolor: pink; /*comment*/top: 0;\n}',
- message: messages.rejectedAfterMultiLine(),
- line: 2,
- column: 13,
- },
- {
- code: 'a {\n color: pink; /* 1 */ /* 2 */\ntop: 0\n}',
- fixed: 'a {\n color: pink; /* 1 */ /* 2 */top: 0\n}',
- description: 'next*2 node is comment',
- message: messages.rejectedAfterMultiLine(),
- line: 2,
- column: 15,
- },
- {
- code: 'a {\n color: pink; /* 1 */ \n top: 0\n}',
- fixed: 'a {\n color: pink; /* 1 */top: 0\n}',
- message: messages.rejectedAfterMultiLine(),
- line: 2,
- column: 15,
- },
- ],
-});
diff --git a/lib/rules/declaration-block-semicolon-newline-after/index.js b/lib/rules/declaration-block-semicolon-newline-after/index.js
deleted file mode 100644
index fa218039bb..0000000000
--- a/lib/rules/declaration-block-semicolon-newline-after/index.js
+++ /dev/null
@@ -1,107 +0,0 @@
-'use strict';
-
-const blockString = require('../../utils/blockString');
-const nextNonCommentNode = require('../../utils/nextNonCommentNode');
-const rawNodeString = require('../../utils/rawNodeString');
-const report = require('../../utils/report');
-const ruleMessages = require('../../utils/ruleMessages');
-const validateOptions = require('../../utils/validateOptions');
-const whitespaceChecker = require('../../utils/whitespaceChecker');
-const { isAtRule, isRule } = require('../../utils/typeGuards');
-
-const ruleName = 'declaration-block-semicolon-newline-after';
-
-const messages = ruleMessages(ruleName, {
- expectedAfter: () => 'Expected newline after ";"',
- expectedAfterMultiLine: () => 'Expected newline after ";" in a multi-line declaration block',
- rejectedAfterMultiLine: () => 'Unexpected newline after ";" in a multi-line declaration block',
-});
-
-const meta = {
- url: 'https://stylelint.io/user-guide/rules/declaration-block-semicolon-newline-after',
- fixable: true,
- deprecated: true,
-};
-
-/** @type {import('stylelint').Rule} */
-const rule = (primary, _secondaryOptions, context) => {
- const checker = whitespaceChecker('newline', primary, messages);
-
- return (root, result) => {
- const validOptions = validateOptions(result, ruleName, {
- actual: primary,
- possible: ['always', 'always-multi-line', 'never-multi-line'],
- });
-
- if (!validOptions) {
- return;
- }
-
- root.walkDecls((decl) => {
- // Ignore last declaration if there's no trailing semicolon
- const parentRule = decl.parent;
-
- if (!parentRule) throw new Error('A parent node must be present');
-
- if (!isAtRule(parentRule) && !isRule(parentRule)) {
- return;
- }
-
- if (!parentRule.raws.semicolon && parentRule.last === decl) {
- return;
- }
-
- const nextNode = decl.next();
-
- if (!nextNode) {
- return;
- }
-
- // Allow end-of-line comment
- const nodeToCheck = nextNonCommentNode(nextNode);
-
- if (!nodeToCheck) {
- return;
- }
-
- checker.afterOneOnly({
- source: rawNodeString(nodeToCheck),
- index: -1,
- lineCheckStr: blockString(parentRule),
- err: (m) => {
- if (context.fix) {
- if (primary.startsWith('always')) {
- const index = nodeToCheck.raws.before.search(/\r?\n/);
-
- nodeToCheck.raws.before =
- index >= 0
- ? nodeToCheck.raws.before.slice(index)
- : context.newline + nodeToCheck.raws.before;
-
- return;
- }
-
- if (primary === 'never-multi-line') {
- nodeToCheck.raws.before = '';
-
- return;
- }
- }
-
- report({
- message: m,
- node: decl,
- index: decl.toString().length + 1,
- result,
- ruleName,
- });
- },
- });
- });
- };
-};
-
-rule.ruleName = ruleName;
-rule.messages = messages;
-rule.meta = meta;
-module.exports = rule;
diff --git a/lib/rules/declaration-block-semicolon-newline-before/README.md b/lib/rules/declaration-block-semicolon-newline-before/README.md
deleted file mode 100644
index 4b66fdc2a4..0000000000
--- a/lib/rules/declaration-block-semicolon-newline-before/README.md
+++ /dev/null
@@ -1,122 +0,0 @@
-# declaration-block-semicolon-newline-before
-
-> **Warning** This rule is deprecated and will be removed in the future. See [the migration guide](../../../docs/migration-guide/to-15.md).
-
-Require a newline or disallow whitespace before the semicolons of declaration blocks.
-
-
-```css
- a {
- color: pink
- ; top: 0;
- } ↑
-/** ↑
- * The newline before this semicolon */
-```
-
-This rule ignores semicolons that are preceded by Less mixins.
-
-## Options
-
-`string`: `"always"|"always-multi-line"|"never-multi-line"`
-
-### `"always"`
-
-There _must always_ be a newline before the semicolons.
-
-The following patterns are considered problems:
-
-
-```css
-a { color: pink; }
-```
-
-
-```css
-a {
- color: pink; top: 0;
-}
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { color: pink
-; }
-```
-
-
-```css
-a {
- color: pink
- ; top: 0;
-}
-```
-
-### `"always-multi-line"`
-
-There _must always_ be a newline before the semicolons in multi-line rules.
-
-The following patterns are considered problems:
-
-
-```css
-a {
- color: pink; top: 0;
-}
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { color: pink; }
-```
-
-
-```css
-a { color: pink; top: 0; }
-```
-
-
-```css
-a {
- color: pink
- ; top: 0;
-}
-```
-
-### `"never-multi-line"`
-
-There _must never_ be whitespace before the semicolons in multi-line rules.
-
-The following patterns are considered problems:
-
-
-```css
-a {
- color: pink
- ; top: 0;
-}
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { color: pink; }
-```
-
-
-```css
-a { color: pink; top: 0; }
-```
-
-
-```css
-a {
- color: pink;
- top: 0;
-}
-```
diff --git a/lib/rules/declaration-block-semicolon-newline-before/__tests__/index.js b/lib/rules/declaration-block-semicolon-newline-before/__tests__/index.js
deleted file mode 100644
index fcad0f5b79..0000000000
--- a/lib/rules/declaration-block-semicolon-newline-before/__tests__/index.js
+++ /dev/null
@@ -1,226 +0,0 @@
-'use strict';
-
-const { messages, ruleName } = require('..');
-
-testRule({
- ruleName,
- config: ['always'],
-
- accept: [
- {
- code: 'color: pink\n;',
- description: 'declaration on root',
- },
- {
- code: 'a { color: pink\n; }',
- },
- {
- code: 'a { color: pink\n\n; }',
- },
- {
- code: 'a::before { content: ";a"\n; }',
- },
- {
- code: 'a { color: pink\n;top: 0 }',
- },
- {
- code: 'a { color: pink\n;top: 0}',
- },
- {
- code: 'a { color: pink\r\n;top: 0}',
- description: 'CRLF',
- },
- {
- code: 'a { color: pink\r\n\r\n;top: 0}',
- description: 'CRLF',
- },
- {
- code: 'a,\nb { color: pink\n;top: 0}',
- description: 'multi-line rule, multi-line declaration-block',
- },
- ],
-
- reject: [
- {
- code: 'a { color: pink;top: 0 }',
- message: messages.expectedBefore(),
- line: 1,
- column: 15,
- },
- {
- code: 'a { color: pink ;top: 0 }',
- message: messages.expectedBefore(),
- line: 1,
- column: 16,
- },
- {
- code: 'a { color: pink ;top: 0 }',
- message: messages.expectedBefore(),
- line: 1,
- column: 17,
- },
- {
- code: 'a { color: pink\t;top: 0 }',
- message: messages.expectedBefore(),
- line: 1,
- column: 16,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['always-multi-line'],
-
- accept: [
- {
- code: 'color: pink\n;',
- description: 'declaration on root',
- },
- {
- code: 'a {\ncolor: pink\n; }',
- },
- {
- code: 'a::before {\ncontent: ";a"\n; }',
- },
- {
- code: 'a::before {\r\ncontent: ";a"\r\n; }',
- description: 'CRLF',
- },
- {
- code: 'a {\ncolor: pink\n;top: 0 }',
- },
- {
- code: 'a {\ncolor: pink\n;top: 0}',
- },
- {
- code: 'a {\r\ncolor: pink\r\n;top: 0}',
- description: 'CRLF',
- },
- {
- code: 'a { color: pink;top: 0; }',
- },
- {
- code: 'a,\nb { color: pink; top: 0}',
- description: 'multi-line rule, single-line declaration-block',
- },
- {
- code: 'a,\r\nb { color: pink; top: 0}',
- description: 'multi-line rule, single-line declaration-block and CRLF',
- },
- ],
-
- reject: [
- {
- code: 'a {\ncolor: pink;top: 0\n}',
- message: messages.expectedBeforeMultiLine(),
- line: 2,
- column: 11,
- },
- {
- code: 'a {\ncolor: pink ;top: 0\n}',
- message: messages.expectedBeforeMultiLine(),
- line: 2,
- column: 12,
- },
- {
- code: 'a {\ncolor: pink ;top: 0\n}',
- message: messages.expectedBeforeMultiLine(),
- line: 2,
- column: 13,
- },
- {
- code: 'a {\r\ncolor: pink ;top: 0\r\n}',
- description: 'CRLF',
- message: messages.expectedBeforeMultiLine(),
- line: 2,
- column: 13,
- },
- {
- code: 'a {\ncolor: pink\t;top: 0\n}',
- message: messages.expectedBeforeMultiLine(),
- line: 2,
- column: 12,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['never-multi-line'],
-
- accept: [
- {
- code: 'color: pink;',
- description: 'declaration on root',
- },
- {
- code: 'a {\ncolor: pink;\n}',
- },
- {
- code: 'a {\r\ncolor: pink;\r\n}',
- description: 'CRLF',
- },
- {
- code: 'a::before {\ncontent: ";a";\n}',
- },
- {
- code: 'a {\ncolor: pink;\ntop: 0 }',
- },
- {
- code: 'a {\ncolor: pink;\ntop: 0}',
- },
- {
- code: 'a {\r\ncolor: pink;\r\ntop: 0}',
- description: 'CRLF',
- },
- {
- code: 'a { color: pink; top: 0; }',
- },
- {
- code: 'a,\nb { color: pink ;top: 0}',
- description: 'multi-line rule, single-line declaration-block',
- },
- ],
-
- reject: [
- {
- code: 'a {\ncolor: pink\n;top: 0\n}',
- message: messages.rejectedBeforeMultiLine(),
- line: 2,
- column: 12,
- },
- {
- code: 'a {\ncolor: pink ;top: 0\n}',
- message: messages.rejectedBeforeMultiLine(),
- line: 2,
- column: 12,
- },
- {
- code: 'a {\r\ncolor: pink ;top: 0\r\n}',
- description: 'CRLF',
- message: messages.rejectedBeforeMultiLine(),
- line: 2,
- column: 12,
- },
- {
- code: 'a {\ncolor: pink ;top: 0\n}',
- message: messages.rejectedBeforeMultiLine(),
- line: 2,
- column: 13,
- },
- {
- code: 'a {\ncolor: pink\t;top: 0\n}',
- message: messages.rejectedBeforeMultiLine(),
- line: 2,
- column: 12,
- },
- {
- code: 'a {\r\ncolor: pink\t;top: 0\r\n}',
- description: 'CRLF',
- message: messages.rejectedBeforeMultiLine(),
- line: 2,
- column: 12,
- },
- ],
-});
diff --git a/lib/rules/declaration-block-semicolon-newline-before/index.js b/lib/rules/declaration-block-semicolon-newline-before/index.js
deleted file mode 100644
index 9e75fb2935..0000000000
--- a/lib/rules/declaration-block-semicolon-newline-before/index.js
+++ /dev/null
@@ -1,74 +0,0 @@
-'use strict';
-
-const blockString = require('../../utils/blockString');
-const report = require('../../utils/report');
-const ruleMessages = require('../../utils/ruleMessages');
-const validateOptions = require('../../utils/validateOptions');
-const whitespaceChecker = require('../../utils/whitespaceChecker');
-const { isAtRule, isRule } = require('../../utils/typeGuards');
-
-const ruleName = 'declaration-block-semicolon-newline-before';
-
-const messages = ruleMessages(ruleName, {
- expectedBefore: () => 'Expected newline before ";"',
- expectedBeforeMultiLine: () => 'Expected newline before ";" in a multi-line declaration block',
- rejectedBeforeMultiLine: () =>
- 'Unexpected whitespace before ";" in a multi-line declaration block',
-});
-
-const meta = {
- url: 'https://stylelint.io/user-guide/rules/declaration-block-semicolon-newline-before',
- deprecated: true,
-};
-
-/** @type {import('stylelint').Rule} */
-const rule = (primary) => {
- const checker = whitespaceChecker('newline', primary, messages);
-
- return (root, result) => {
- const validOptions = validateOptions(result, ruleName, {
- actual: primary,
- possible: ['always', 'always-multi-line', 'never-multi-line'],
- });
-
- if (!validOptions) {
- return;
- }
-
- root.walkDecls((decl) => {
- const parentRule = decl.parent;
-
- if (!parentRule) throw new Error('A parent node must be present');
-
- if (!isAtRule(parentRule) && !isRule(parentRule)) {
- return;
- }
-
- if (!parentRule.raws.semicolon && parentRule.last === decl) {
- return;
- }
-
- const declString = decl.toString();
-
- checker.beforeAllowingIndentation({
- source: declString,
- index: declString.length,
- lineCheckStr: blockString(parentRule),
- err: (m) => {
- report({
- message: m,
- node: decl,
- index: decl.toString().length - 1,
- result,
- ruleName,
- });
- },
- });
- });
- };
-};
-
-rule.ruleName = ruleName;
-rule.messages = messages;
-rule.meta = meta;
-module.exports = rule;
diff --git a/lib/rules/declaration-block-semicolon-space-after/README.md b/lib/rules/declaration-block-semicolon-space-after/README.md
deleted file mode 100644
index 70ec855575..0000000000
--- a/lib/rules/declaration-block-semicolon-space-after/README.md
+++ /dev/null
@@ -1,149 +0,0 @@
-# declaration-block-semicolon-space-after
-
-> **Warning** This rule is deprecated and will be removed in the future. See [the migration guide](../../../docs/migration-guide/to-15.md).
-
-Require a single space or disallow whitespace after the semicolons of declaration blocks.
-
-
-```css
-a { color: pink; top: 0; }
-/** ↑
- * The space after this semicolon */
-```
-
-This rule ignores:
-
-- semicolons that are preceded by Less mixins
-- the last semicolon of declaration blocks
-
-Use the `block-closing-brace-*-before` rules to control the whitespace between the last semicolon and the closing brace instead.
-
-The [`fix` option](../../../docs/user-guide/options.md#fix) can automatically fix all of the problems reported by this rule.
-
-## Options
-
-`string`: `"always"|"never"|"always-single-line"|"never-single-line"`
-
-### `"always"`
-
-There _must always_ be a single space after the semicolon.
-
-The following patterns are considered problems:
-
-
-```css
-a { color: pink;top: 0; }
-```
-
-
-```css
-a {
- color: pink;
- top: 0;
-}
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { color: pink;}
-```
-
-
-```css
-a { color: pink; }
-```
-
-
-```css
-a { color: pink; top: 0; }
-```
-
-### `"never"`
-
-There _must never_ be whitespace after the semicolon.
-
-The following patterns are considered problems:
-
-
-```css
-a { color: pink; top: 0; }
-```
-
-
-```css
-a {
- color: pink;
- top: 0;
-}
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { color: pink;}
-```
-
-
-```css
-a { color: pink; }
-```
-
-
-```css
-a { color: pink;top: 0; }
-```
-
-### `"always-single-line"`
-
-There _must always_ be a single space after the semicolon in single-line declaration blocks.
-
-The following patterns are considered problems:
-
-
-```css
-a { color: pink;top: 0; }
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { color: pink; top: 0; }
-```
-
-
-```css
-a {
- color: pink;
- top: 0;
-}
-```
-
-### `"never-single-line"`
-
-There _must never_ be whitespace after the semicolon in single-line declaration blocks.
-
-The following patterns are considered problems:
-
-
-```css
-a { color: pink; top: 0; }
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { color: pink;top: 0; }
-```
-
-
-```css
-a {
- color: pink;
- top: 0;
-}
-```
diff --git a/lib/rules/declaration-block-semicolon-space-after/__tests__/index.js b/lib/rules/declaration-block-semicolon-space-after/__tests__/index.js
deleted file mode 100644
index 0d57bff353..0000000000
--- a/lib/rules/declaration-block-semicolon-space-after/__tests__/index.js
+++ /dev/null
@@ -1,248 +0,0 @@
-'use strict';
-
-const { messages, ruleName } = require('..');
-
-testRule({
- ruleName,
- config: ['always'],
- fix: true,
-
- accept: [
- {
- code: 'a { color: pink; }',
- },
- {
- code: 'a { color: pink; }',
- },
- {
- code: 'a::before { content: ";a"; }',
- },
- {
- code: 'a { color: pink; top: 0;}',
- description: 'no space between trailing semicolon and closing brace',
- },
- {
- code: 'a { color: pink; top: 0}',
- },
- ],
-
- reject: [
- {
- code: 'a { color: pink;top: 0; }',
- fixed: 'a { color: pink; top: 0; }',
- message: messages.expectedAfter(),
- line: 1,
- column: 17,
- },
- {
- code: 'a { color: pink; top: 0; }',
- fixed: 'a { color: pink; top: 0; }',
- message: messages.expectedAfter(),
- line: 1,
- column: 17,
- },
- {
- code: 'a { color: pink;\ntop: 0; }',
- fixed: 'a { color: pink; top: 0; }',
- message: messages.expectedAfter(),
- line: 1,
- column: 17,
- },
- {
- code: 'a { color: pink;\r\ntop: 0; }',
- fixed: 'a { color: pink; top: 0; }',
- description: 'CRLF',
- message: messages.expectedAfter(),
- line: 1,
- column: 17,
- },
- {
- code: 'a { color: pink;\ttop: 0; }',
- fixed: 'a { color: pink; top: 0; }',
- message: messages.expectedAfter(),
- line: 1,
- column: 17,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['never'],
- fix: true,
-
- accept: [
- {
- code: 'color: pink;',
- description: 'declaration on root',
- },
- {
- code: 'a { color: pink;}',
- },
- {
- code: 'a::before { content: ";a";}',
- },
- {
- code: 'a { color: pink;top: 0;}',
- },
- ],
-
- reject: [
- {
- code: 'a { color: pink;\n top: 0; }',
- fixed: 'a { color: pink;top: 0; }',
- message: messages.rejectedAfter(),
- line: 1,
- column: 17,
- },
- {
- code: 'a { color: pink; top: 0; }',
- fixed: 'a { color: pink;top: 0; }',
- message: messages.rejectedAfter(),
- line: 1,
- column: 17,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['always-single-line'],
- fix: true,
-
- accept: [
- {
- code: 'a { color: pink; }',
- },
- {
- code: 'a::before { content: ";a"; }',
- },
- {
- code: 'a { color: pink; top: 0;}',
- description: 'no space between trailing semicolon and closing brace',
- },
- {
- code: 'a,\nb { color: pink; top: 0; }',
- description: 'multi-line rule, single-line declaration-block',
- },
- {
- code: 'a,\r\nb { color: pink; top: 0; }',
- description: 'multi-line rule, single-line declaration-block and CRLF',
- },
- {
- code: 'a {\n color: pink;\n top: 0;\n}',
- },
- {
- code: 'a {\r\n color: pink;\r\n top: 0;\r\n}',
- description: 'CRLF',
- },
- ],
-
- reject: [
- {
- code: 'a { color: pink;top: 0; }',
- fixed: 'a { color: pink; top: 0; }',
- message: messages.expectedAfterSingleLine(),
- line: 1,
- column: 17,
- },
- {
- code: 'a,\nb { color: pink;top: 0; }',
- fixed: 'a,\nb { color: pink; top: 0; }',
- message: messages.expectedAfterSingleLine(),
- line: 2,
- column: 17,
- },
- {
- code: 'a,\r\nb { color: pink;top: 0; }',
- fixed: 'a,\r\nb { color: pink; top: 0; }',
- description: 'CRLF',
- message: messages.expectedAfterSingleLine(),
- line: 2,
- column: 17,
- },
- {
- code: 'a { color: pink; top: 0; }',
- fixed: 'a { color: pink; top: 0; }',
- message: messages.expectedAfterSingleLine(),
- line: 1,
- column: 17,
- },
- {
- code: 'a { color: pink;\ttop: 0; }',
- fixed: 'a { color: pink; top: 0; }',
- message: messages.expectedAfterSingleLine(),
- line: 1,
- column: 17,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['never-single-line'],
- fix: true,
-
- accept: [
- {
- code: 'a { color: pink; }',
- },
- {
- code: 'a::before { content: "; a"; }',
- },
- {
- code: 'a { color: pink;top: 0; }',
- description: 'space between trailing semicolon and closing brace',
- },
- {
- code: 'a,\nb { color: pink;top: 0; }',
- description: 'multi-line rule, single-line declaration-block',
- },
- {
- code: 'a {\n color: pink; top: 0;\n}',
- },
- {
- code: 'a {\r\n color: pink; top: 0;\r\n}',
- description: 'CRLF',
- },
- ],
-
- reject: [
- {
- code: 'a { color: pink; top: 0; }',
- fixed: 'a { color: pink;top: 0; }',
- message: messages.rejectedAfterSingleLine(),
- line: 1,
- column: 17,
- },
- {
- code: 'a,\nb { color: pink; top: 0; }',
- fixed: 'a,\nb { color: pink;top: 0; }',
- message: messages.rejectedAfterSingleLine(),
- line: 2,
- column: 17,
- },
- {
- code: 'a,\r\nb { color: pink; top: 0; }',
- fixed: 'a,\r\nb { color: pink;top: 0; }',
- description: 'CRLF',
- message: messages.rejectedAfterSingleLine(),
- line: 2,
- column: 17,
- },
- {
- code: 'a { color: pink; top: 0; }',
- fixed: 'a { color: pink;top: 0; }',
- message: messages.rejectedAfterSingleLine(),
- line: 1,
- column: 17,
- },
- {
- code: 'a { color: pink;\ttop: 0; }',
- fixed: 'a { color: pink;top: 0; }',
- message: messages.rejectedAfterSingleLine(),
- line: 1,
- column: 17,
- },
- ],
-});
diff --git a/lib/rules/declaration-block-semicolon-space-after/index.js b/lib/rules/declaration-block-semicolon-space-after/index.js
deleted file mode 100644
index 97a16bdc2e..0000000000
--- a/lib/rules/declaration-block-semicolon-space-after/index.js
+++ /dev/null
@@ -1,97 +0,0 @@
-'use strict';
-
-const blockString = require('../../utils/blockString');
-const rawNodeString = require('../../utils/rawNodeString');
-const report = require('../../utils/report');
-const ruleMessages = require('../../utils/ruleMessages');
-const validateOptions = require('../../utils/validateOptions');
-const whitespaceChecker = require('../../utils/whitespaceChecker');
-const { isAtRule, isRule } = require('../../utils/typeGuards');
-
-const ruleName = 'declaration-block-semicolon-space-after';
-
-const messages = ruleMessages(ruleName, {
- expectedAfter: () => 'Expected single space after ";"',
- rejectedAfter: () => 'Unexpected whitespace after ";"',
- expectedAfterSingleLine: () =>
- 'Expected single space after ";" in a single-line declaration block',
- rejectedAfterSingleLine: () =>
- 'Unexpected whitespace after ";" in a single-line declaration block',
-});
-
-const meta = {
- url: 'https://stylelint.io/user-guide/rules/declaration-block-semicolon-space-after',
- fixable: true,
- deprecated: true,
-};
-
-/** @type {import('stylelint').Rule} */
-const rule = (primary, _secondaryOptions, context) => {
- const checker = whitespaceChecker('space', primary, messages);
-
- return (root, result) => {
- const validOptions = validateOptions(result, ruleName, {
- actual: primary,
- possible: ['always', 'never', 'always-single-line', 'never-single-line'],
- });
-
- if (!validOptions) {
- return;
- }
-
- root.walkDecls((decl) => {
- // Ignore last declaration if there's no trailing semicolon
- const parentRule = decl.parent;
-
- if (!parentRule) throw new Error('A parent node must be present');
-
- if (!isAtRule(parentRule) && !isRule(parentRule)) {
- return;
- }
-
- if (!parentRule.raws.semicolon && parentRule.last === decl) {
- return;
- }
-
- const nextDecl = decl.next();
-
- if (!nextDecl) {
- return;
- }
-
- checker.after({
- source: rawNodeString(nextDecl),
- index: -1,
- lineCheckStr: blockString(parentRule),
- err: (m) => {
- if (context.fix) {
- if (primary.startsWith('always')) {
- nextDecl.raws.before = ' ';
-
- return;
- }
-
- if (primary.startsWith('never')) {
- nextDecl.raws.before = '';
-
- return;
- }
- }
-
- report({
- message: m,
- node: decl,
- index: decl.toString().length + 1,
- result,
- ruleName,
- });
- },
- });
- });
- };
-};
-
-rule.ruleName = ruleName;
-rule.messages = messages;
-rule.meta = meta;
-module.exports = rule;
diff --git a/lib/rules/declaration-block-semicolon-space-before/README.md b/lib/rules/declaration-block-semicolon-space-before/README.md
deleted file mode 100644
index 2f6e064287..0000000000
--- a/lib/rules/declaration-block-semicolon-space-before/README.md
+++ /dev/null
@@ -1,132 +0,0 @@
-# declaration-block-semicolon-space-before
-
-> **Warning** This rule is deprecated and will be removed in the future. See [the migration guide](../../../docs/migration-guide/to-15.md).
-
-Require a single space or disallow whitespace before the semicolons of declaration blocks.
-
-
-```css
-a { color: pink; }
-/** ↑
- * The space before this semicolon */
-```
-
-This rule ignores semicolons that are preceded by Less mixins.
-
-The [`fix` option](../../../docs/user-guide/options.md#fix) can automatically fix all of the problems reported by this rule.
-
-## Options
-
-`string`: `"always"|"never"|"always-single-line"|"never-single-line"`
-
-### `"always"`
-
-There _must always_ be a single space before the semicolons.
-
-The following patterns are considered problems:
-
-
-```css
-a { color: pink; }
-```
-
-
-```css
-a { color: pink; top: 0; }
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { color: pink ; }
-```
-
-
-```css
-a { color: pink ; top: 0 ; }
-```
-
-### `"never"`
-
-There _must never_ be whitespace before the semicolons.
-
-The following patterns are considered problems:
-
-
-```css
-a { color: pink ; }
-```
-
-
-```css
-a { color: pink ; top: 0 ; }
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { color: pink; }
-```
-
-
-```css
-a { color: pink; top: 0; }
-```
-
-### `"always-single-line"`
-
-There _must always_ be a single space before the semicolons in single-line declaration blocks.
-
-The following patterns are considered problems:
-
-
-```css
-a { color: pink; }
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { color: pink ; }
-```
-
-
-```css
-a { color: pink; top: 0; }
-```
-
-
-```css
-a { color: pink ; top: 0 ; }
-```
-
-### `"never-single-line"`
-
-There _must never_ be whitespace before the semicolons in single-line declaration blocks.
-
-The following patterns are considered problems:
-
-
-```css
-a { color: pink ; }
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { color: pink; }
-```
-
-
-```css
-a { color: pink; top: 0; }
-```
-
-
-```css
-a { color: pink ; top: 0 ; }
-```
diff --git a/lib/rules/declaration-block-semicolon-space-before/__tests__/index.js b/lib/rules/declaration-block-semicolon-space-before/__tests__/index.js
deleted file mode 100644
index a8c69cce13..0000000000
--- a/lib/rules/declaration-block-semicolon-space-before/__tests__/index.js
+++ /dev/null
@@ -1,394 +0,0 @@
-'use strict';
-
-const { messages, ruleName } = require('..');
-
-testRule({
- ruleName,
- config: ['always'],
- fix: true,
-
- accept: [
- {
- code: 'color: pink ;',
- description: 'declaration on root',
- },
- {
- code: 'a { color: pink ; }',
- },
- {
- code: 'a::before { content: ";a" ; }',
- },
- {
- code: 'a { color: pink ; top: 0 ; }',
- },
- {
- code: 'a { color: pink ; top: 0}',
- },
- {
- code: 'a { width: 50% !important ;}',
- },
- ],
-
- reject: [
- {
- code: 'a { color: pink; }',
- fixed: 'a { color: pink ; }',
- message: messages.expectedBefore(),
- line: 1,
- column: 15,
- },
- {
- code: 'a { color: pink ; }',
- fixed: 'a { color: pink ; }',
- message: messages.expectedBefore(),
- line: 1,
- column: 17,
- },
- {
- code: 'a { color: pink\t; }',
- fixed: 'a { color: pink ; }',
- message: messages.expectedBefore(),
- line: 1,
- column: 16,
- },
- {
- code: 'a { color: pink\n; }',
- fixed: 'a { color: pink ; }',
- message: messages.expectedBefore(),
- line: 1,
- column: 16,
- },
- {
- code: 'a { color: pink\r\n; }',
- fixed: 'a { color: pink ; }',
- description: 'CRLF',
- message: messages.expectedBefore(),
- line: 1,
- column: 17,
- },
- {
- code: 'a { color: pink ; top: 0; }',
- fixed: 'a { color: pink ; top: 0 ; }',
- message: messages.expectedBefore(),
- line: 1,
- column: 24,
- },
- {
- code: 'a { color: pink/*comment*/; }',
- fixed: 'a { color: pink/*comment*/ ; }',
- description: 'comment',
- message: messages.expectedBefore(),
- line: 1,
- column: 26,
- },
- {
- code: 'a { color: pink /*comment*/; }',
- fixed: 'a { color: pink /*comment*/ ; }',
- description: 'comment',
- message: messages.expectedBefore(),
- line: 1,
- column: 27,
- },
- {
- code: 'a { width: 50% !important; }',
- fixed: 'a { width: 50% !important ; }',
- description: 'important',
- message: messages.expectedBefore(),
- line: 1,
- column: 25,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['never'],
- fix: true,
-
- accept: [
- {
- code: 'color: pink;',
- description: 'declaration on root',
- },
- {
- code: 'a { color: pink; }',
- },
- {
- code: 'a::before { content: ";a"; }',
- },
- {
- code: 'a { color: pink; top: 0; }',
- },
- {
- code: 'a { width: 50% !important;}',
- },
- ],
-
- reject: [
- {
- code: 'a { color: pink ; }',
- fixed: 'a { color: pink; }',
- message: messages.rejectedBefore(),
- line: 1,
- column: 16,
- },
- {
- code: 'a { color: pink ; }',
- fixed: 'a { color: pink; }',
- message: messages.rejectedBefore(),
- line: 1,
- column: 17,
- },
- {
- code: 'a { color: pink\t; }',
- fixed: 'a { color: pink; }',
- message: messages.rejectedBefore(),
- line: 1,
- column: 16,
- },
- {
- code: 'a { color: pink\n; }',
- fixed: 'a { color: pink; }',
- message: messages.rejectedBefore(),
- line: 1,
- column: 16,
- },
- {
- code: 'a { color: pink\r\n; }',
- fixed: 'a { color: pink; }',
- description: 'CRLF',
- message: messages.rejectedBefore(),
- line: 1,
- column: 17,
- },
- {
- code: 'a { color: pink; top: 0 ; }',
- fixed: 'a { color: pink; top: 0; }',
- message: messages.rejectedBefore(),
- line: 1,
- column: 24,
- },
- {
- code: 'a { color: pink/*comment*/ ; }',
- fixed: 'a { color: pink/*comment*/; }',
- description: 'comment',
- message: messages.rejectedBefore(),
- line: 1,
- column: 27,
- },
- {
- code: 'a { color: pink /*comment*/ ; }',
- fixed: 'a { color: pink /*comment*/; }',
- description: 'comment',
- message: messages.rejectedBefore(),
- line: 1,
- column: 28,
- },
- {
- code: 'a { width: 50% !important ; }',
- fixed: 'a { width: 50% !important; }',
- description: 'important',
- message: messages.rejectedBefore(),
- line: 1,
- column: 26,
- },
- {
- code: 'a { width: 50% !important ; }',
- fixed: 'a { width: 50% !important; }',
- description: 'important',
- message: messages.rejectedBefore(),
- line: 1,
- column: 30,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['always-single-line'],
- fix: true,
-
- accept: [
- {
- code: 'color: pink ;',
- description: 'declaration on root',
- },
- {
- code: 'a { color: pink ; }',
- },
- {
- code: 'a::before { content: ";a" ; }',
- },
- {
- code: 'a { color: pink ; top: 0 ; }',
- },
- {
- code: 'a,\nb { color: pink ; top: 0 ; }',
- description: 'multi-line rule, single-line declaration-block',
- },
- {
- code: 'a {\n color: pink;\n top: 0;\n}',
- },
- {
- code: 'a {\r\n color: pink;\r\n top: 0;\r\n}',
- description: 'CRLF',
- },
- {
- code: 'a { width: 50% !important ; }',
- },
- {
- code: 'a {\n width: 50% !important;\n}',
- },
- ],
-
- reject: [
- {
- code: 'a { color: pink; }',
- fixed: 'a { color: pink ; }',
- message: messages.expectedBeforeSingleLine(),
- line: 1,
- column: 15,
- },
- {
- code: 'a,\nb { color: pink; }',
- fixed: 'a,\nb { color: pink ; }',
- message: messages.expectedBeforeSingleLine(),
- line: 2,
- column: 15,
- },
- {
- code: 'a,\r\nb { color: pink; }',
- fixed: 'a,\r\nb { color: pink ; }',
- description: 'CRLF',
- message: messages.expectedBeforeSingleLine(),
- line: 2,
- column: 15,
- },
- {
- code: 'a { color: pink ; }',
- fixed: 'a { color: pink ; }',
- message: messages.expectedBeforeSingleLine(),
- line: 1,
- column: 17,
- },
- {
- code: 'a { color: pink\t; }',
- fixed: 'a { color: pink ; }',
- message: messages.expectedBeforeSingleLine(),
- line: 1,
- column: 16,
- },
- {
- code: 'a { color: pink ; top: 0; }',
- fixed: 'a { color: pink ; top: 0 ; }',
- message: messages.expectedBeforeSingleLine(),
- line: 1,
- column: 24,
- },
- {
- code: 'a { width: 50% !important; }',
- fixed: 'a { width: 50% !important ; }',
- description: 'important',
- message: messages.expectedBeforeSingleLine(),
- line: 1,
- column: 25,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['never-single-line'],
- fix: true,
-
- accept: [
- {
- code: 'color: pink;',
- description: 'declaration on root',
- },
- {
- code: 'a { color: pink; }',
- },
- {
- code: 'a::before { content: ";a"; }',
- },
- {
- code: 'a { color: pink; top: 0; }',
- },
- {
- code: 'a,\nb { color: pink; top: 0; }',
- description: 'multi-line rule, single-line declaration-block',
- },
- {
- code: 'a {\n color: pink ;\n top: 0 ;\n}',
- },
- {
- code: 'a { width: 50% !important; }',
- },
- {
- code: 'a {\n width: 50% !important ;\n}',
- },
- ],
-
- reject: [
- {
- code: 'a { color: pink ; }',
- fixed: 'a { color: pink; }',
- message: messages.rejectedBeforeSingleLine(),
- line: 1,
- column: 16,
- },
- {
- code: 'a,\nb { color: pink ; }',
- fixed: 'a,\nb { color: pink; }',
- message: messages.rejectedBeforeSingleLine(),
- line: 2,
- column: 16,
- },
- {
- code: 'a,\r\nb { color: pink ; }',
- fixed: 'a,\r\nb { color: pink; }',
- description: 'CRLF',
- message: messages.rejectedBeforeSingleLine(),
- line: 2,
- column: 16,
- },
- {
- code: 'a { color: pink ; }',
- fixed: 'a { color: pink; }',
- message: messages.rejectedBeforeSingleLine(),
- line: 1,
- column: 17,
- },
- {
- code: 'a { color: pink\t; }',
- fixed: 'a { color: pink; }',
- message: messages.rejectedBeforeSingleLine(),
- line: 1,
- column: 16,
- },
- {
- code: 'a { color: pink; top: 0 ; }',
- fixed: 'a { color: pink; top: 0; }',
- message: messages.rejectedBeforeSingleLine(),
- line: 1,
- column: 24,
- },
- {
- code: 'a { width: 50% !important ; }',
- fixed: 'a { width: 50% !important; }',
- description: 'important',
- message: messages.rejectedBeforeSingleLine(),
- line: 1,
- column: 26,
- },
- {
- code: 'a { width: 50% !important ; }',
- fixed: 'a { width: 50% !important; }',
- description: 'important',
- message: messages.rejectedBeforeSingleLine(),
- line: 1,
- column: 30,
- },
- ],
-});
diff --git a/lib/rules/declaration-block-semicolon-space-before/index.js b/lib/rules/declaration-block-semicolon-space-before/index.js
deleted file mode 100644
index 56426dc3b3..0000000000
--- a/lib/rules/declaration-block-semicolon-space-before/index.js
+++ /dev/null
@@ -1,104 +0,0 @@
-'use strict';
-
-const blockString = require('../../utils/blockString');
-const getDeclarationValue = require('../../utils/getDeclarationValue');
-const report = require('../../utils/report');
-const ruleMessages = require('../../utils/ruleMessages');
-const setDeclarationValue = require('../../utils/setDeclarationValue');
-const validateOptions = require('../../utils/validateOptions');
-const whitespaceChecker = require('../../utils/whitespaceChecker');
-const { isAtRule, isRule } = require('../../utils/typeGuards');
-
-const ruleName = 'declaration-block-semicolon-space-before';
-
-const messages = ruleMessages(ruleName, {
- expectedBefore: () => 'Expected single space before ";"',
- rejectedBefore: () => 'Unexpected whitespace before ";"',
- expectedBeforeSingleLine: () =>
- 'Expected single space before ";" in a single-line declaration block',
- rejectedBeforeSingleLine: () =>
- 'Unexpected whitespace before ";" in a single-line declaration block',
-});
-
-const meta = {
- url: 'https://stylelint.io/user-guide/rules/declaration-block-semicolon-space-before',
- fixable: true,
- deprecated: true,
-};
-
-/** @type {import('stylelint').Rule} */
-const rule = (primary, _secondaryOptions, context) => {
- const checker = whitespaceChecker('space', primary, messages);
-
- return (root, result) => {
- const validOptions = validateOptions(result, ruleName, {
- actual: primary,
- possible: ['always', 'never', 'always-single-line', 'never-single-line'],
- });
-
- if (!validOptions) {
- return;
- }
-
- root.walkDecls((decl) => {
- // Ignore last declaration if there's no trailing semicolon
- const parentRule = decl.parent;
-
- if (!parentRule) throw new Error('A parent node must be present');
-
- if (!isAtRule(parentRule) && !isRule(parentRule)) {
- return;
- }
-
- if (!parentRule.raws.semicolon && parentRule.last === decl) {
- return;
- }
-
- const declString = decl.toString();
-
- checker.before({
- source: declString,
- index: declString.length,
- lineCheckStr: blockString(parentRule),
- err: (m) => {
- if (context.fix) {
- const value = getDeclarationValue(decl);
-
- if (primary.startsWith('always')) {
- if (decl.important) {
- decl.raws.important = ' !important ';
- } else {
- setDeclarationValue(decl, value.replace(/\s*$/, ' '));
- }
-
- return;
- }
-
- if (primary.startsWith('never')) {
- if (decl.raws.important) {
- decl.raws.important = decl.raws.important.replace(/\s*$/, '');
- } else {
- setDeclarationValue(decl, value.replace(/\s*$/, ''));
- }
-
- return;
- }
- }
-
- report({
- message: m,
- node: decl,
- index: decl.toString().length - 1,
- result,
- ruleName,
- });
- },
- });
- });
- };
-};
-
-rule.ruleName = ruleName;
-rule.messages = messages;
-rule.meta = meta;
-module.exports = rule;
diff --git a/lib/rules/declaration-block-trailing-semicolon/README.md b/lib/rules/declaration-block-trailing-semicolon/README.md
deleted file mode 100644
index 22caa75631..0000000000
--- a/lib/rules/declaration-block-trailing-semicolon/README.md
+++ /dev/null
@@ -1,110 +0,0 @@
-# declaration-block-trailing-semicolon
-
-> **Warning** This rule is deprecated and will be removed in the future. See [the migration guide](../../../docs/migration-guide/to-15.md).
-
-Require or disallow a trailing semicolon within declaration blocks.
-
-
-```css
-a { background: orange; color: pink; }
-/** ↑
- * This semicolon */
-```
-
-The trailing semicolon is the _last_ semicolon in a declaration block and it is optional.
-
-This rule ignores:
-
-- Less mixins
-- trailing `//` comments
-- declaration blocks containing nested (at-)rules
-
-The [`fix` option](../../../docs/user-guide/options.md#fix) can automatically fix all of the problems reported by this rule.
-
-## Options
-
-`string`: `"always"|"never"`
-
-### `"always"`
-
-There _must always_ be a trailing semicolon.
-
-The following patterns are considered problems:
-
-
-```css
-a { color: pink }
-```
-
-
-```css
-a { background: orange; color: pink }
-```
-
-
-```css
-a { @include foo }
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { color: pink; }
-```
-
-
-```css
-a { background: orange; color: pink; }
-```
-
-
-```css
-a { @include foo; }
-```
-
-### `"never"`
-
-There _must never_ be a trailing semicolon.
-
-The following patterns are considered problems:
-
-
-```css
-a { color: pink; }
-```
-
-
-```css
-a { background: orange; color: pink; }
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { color: pink }
-```
-
-
-```css
-a { background: orange; color: pink }
-```
-
-## Optional secondary options
-
-### `ignore: ["single-declaration"]`
-
-Ignore declaration blocks that contain a single declaration.
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { color: pink }
-```
-
-
-```css
-a { color: pink; }
-```
diff --git a/lib/rules/declaration-block-trailing-semicolon/__tests__/index.js b/lib/rules/declaration-block-trailing-semicolon/__tests__/index.js
deleted file mode 100644
index 413e286ed5..0000000000
--- a/lib/rules/declaration-block-trailing-semicolon/__tests__/index.js
+++ /dev/null
@@ -1,225 +0,0 @@
-'use strict';
-
-const { messages, ruleName } = require('..');
-
-testRule({
- ruleName,
- config: ['always'],
- fix: true,
-
- accept: [
- {
- code: 'a { color: pink; }',
- description: 'single declaration block with trailing semicolon',
- },
- {
- code: 'a { background: orange; color: pink; }',
- description: 'multi declaration block with trailing semicolon',
- },
- {
- code: 'a { &:hover { color: pink; }}',
- description: 'nesting without first-level decl',
- },
- {
- code: 'a { color: red; &:hover { color: pink; }}',
- description: 'nesting with first-level decl',
- },
- ],
-
- reject: [
- {
- code: 'a { color: pink }',
- fixed: 'a { color: pink; }',
- description: 'single declaration block without trailing semicolon',
- message: messages.expected,
- line: 1,
- column: 15,
- },
- {
- code: 'a { background: orange; color: pink }',
- fixed: 'a { background: orange; color: pink; }',
- description: 'multi declaration block without trailing semicolon',
- message: messages.expected,
- line: 1,
- column: 35,
- },
- {
- code: 'a { &:hover { color: pink }}',
- fixed: 'a { &:hover { color: pink; }}',
- description: 'nesting without first-level decl',
- message: messages.expected,
- line: 1,
- column: 25,
- },
- {
- code: 'a { color: red; &:hover { color: pink }}',
- fixed: 'a { color: red; &:hover { color: pink; }}',
- description: 'nesting with first-level decl',
- message: messages.expected,
- line: 1,
- column: 37,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['always', { ignore: 'single-declaration' }],
- fix: true,
-
- accept: [
- {
- code: 'a { color: pink }',
- description: 'single declaration without trailing semicolon',
- },
- {
- code: 'a { color: pink; }',
- description: 'single declaration with trailing semicolon',
- },
- {
- code: '@keyframes foo { from { top: 0px } to { top: 1px; } }',
- description: 'inconsistent case (with and without)',
- },
- ],
-
- reject: [
- {
- code: 'a { background: orange; color: pink }',
- fixed: 'a { background: orange; color: pink; }',
- description: 'multi declaration block without trailing semicolon',
- message: messages.expected,
- line: 1,
- column: 35,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['never', { ignore: ['single-declaration'] }],
-
- accept: [
- {
- code: 'a { color: pink }',
- description: 'single declaration without trailing semicolon',
- },
- {
- code: 'a { color: pink; }',
- description: 'single declaration with trailing semicolon',
- },
- {
- code: '@keyframes foo { from { top: 0px } to { top: 1px; } }',
- description: 'inconsistent case (with and without)',
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['never'],
- fix: true,
-
- accept: [
- {
- code: 'a { color: pink }',
- description: 'single-line declaration block without trailing semicolon',
- },
- {
- code: 'a { background: orange; color: pink }',
- description: 'multi-line declaration block without trailing semicolon',
- },
- ],
-
- reject: [
- {
- code: 'a { color: pink; }',
- fixed: 'a { color: pink }',
- description: 'single-line declaration block with trailing semicolon',
- message: messages.rejected,
- line: 1,
- column: 15,
- },
- {
- code: 'a { background: orange; color: pink; }',
- fixed: 'a { background: orange; color: pink }',
- description: 'multi-line declaration block with trailing semicolon',
- message: messages.rejected,
- line: 1,
- column: 35,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['always'],
- customSyntax: 'postcss-scss',
- fix: true,
-
- accept: [
- {
- code: 'a { @includes foo; }',
- description: 'at-rule with trailing semicolon',
- },
- {
- code: 'a { @foo { color: pink; } }',
- description: 'at-rule with decl block with trailing semicolon',
- },
- ],
-
- reject: [
- {
- code: 'a { @includes foo }',
- fixed: 'a { @includes foo; }',
- description: 'at-rule without trailing semicolon',
- message: messages.expected,
- line: 1,
- column: 17,
- },
- {
- code: 'a { @foo { color: pink } }',
- fixed: 'a { @foo { color: pink; } }',
- description: 'at-rule with decl block without trailing semicolon',
- message: messages.expected,
- line: 1,
- column: 22,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['never'],
- customSyntax: 'postcss-scss',
- fix: true,
-
- accept: [
- {
- code: 'a { @includes foo }',
- description: 'at-rule without trailing semicolon',
- },
- {
- code: 'a { @foo { color: pink } }',
- description: 'at-rule with decl block without trailing semicolon',
- },
- ],
-
- reject: [
- {
- code: 'a { @includes foo; }',
- fixed: 'a { @includes foo }',
- description: 'at-rule with trailing semicolon',
- message: messages.rejected,
- line: 1,
- column: 17,
- },
- {
- code: 'a { @foo { color: pink; } }',
- fixed: 'a { @foo { color: pink } }',
- description: 'at-rule with decl block with trailing semicolon',
- message: messages.rejected,
- line: 1,
- column: 22,
- },
- ],
-});
diff --git a/lib/rules/declaration-block-trailing-semicolon/index.js b/lib/rules/declaration-block-trailing-semicolon/index.js
deleted file mode 100644
index acc45e646f..0000000000
--- a/lib/rules/declaration-block-trailing-semicolon/index.js
+++ /dev/null
@@ -1,146 +0,0 @@
-'use strict';
-
-const hasBlock = require('../../utils/hasBlock');
-const optionsMatches = require('../../utils/optionsMatches');
-const report = require('../../utils/report');
-const ruleMessages = require('../../utils/ruleMessages');
-const { isAtRule } = require('../../utils/typeGuards');
-const validateOptions = require('../../utils/validateOptions');
-
-const ruleName = 'declaration-block-trailing-semicolon';
-
-const messages = ruleMessages(ruleName, {
- expected: 'Expected a trailing semicolon',
- rejected: 'Unexpected trailing semicolon',
-});
-
-const meta = {
- url: 'https://stylelint.io/user-guide/rules/declaration-block-trailing-semicolon',
- fixable: true,
- deprecated: true,
-};
-
-/** @type {import('stylelint').Rule} */
-const rule = (primary, secondaryOptions, context) => {
- return (root, result) => {
- const validOptions = validateOptions(
- result,
- ruleName,
- {
- actual: primary,
- possible: ['always', 'never'],
- },
- {
- actual: secondaryOptions,
- possible: {
- ignore: ['single-declaration'],
- },
- optional: true,
- },
- );
-
- if (!validOptions) {
- return;
- }
-
- root.walkAtRules((atRule) => {
- if (!atRule.parent) throw new Error('A parent node must be present');
-
- if (atRule.parent === root) {
- return;
- }
-
- if (atRule !== atRule.parent.last) {
- return;
- }
-
- if (hasBlock(atRule)) {
- return;
- }
-
- checkLastNode(atRule);
- });
-
- root.walkDecls((decl) => {
- if (!decl.parent) throw new Error('A parent node must be present');
-
- if (decl.parent.type === 'object') {
- return;
- }
-
- if (decl !== decl.parent.last) {
- return;
- }
-
- checkLastNode(decl);
- });
-
- /**
- * @param {import('postcss').Node} node
- */
- function checkLastNode(node) {
- if (!node.parent) throw new Error('A parent node must be present');
-
- const hasSemicolon = node.parent.raws.semicolon;
- const ignoreSingleDeclaration = optionsMatches(
- secondaryOptions,
- 'ignore',
- 'single-declaration',
- );
-
- if (ignoreSingleDeclaration && node.parent.first === node) {
- return;
- }
-
- let message;
-
- if (primary === 'always') {
- if (hasSemicolon) {
- return;
- }
-
- // auto-fix
- if (context.fix) {
- node.parent.raws.semicolon = true;
-
- if (isAtRule(node)) {
- node.raws.between = '';
- node.parent.raws.after = ' ';
- }
-
- return;
- }
-
- message = messages.expected;
- } else if (primary === 'never') {
- if (!hasSemicolon) {
- return;
- }
-
- // auto-fix
- if (context.fix) {
- node.parent.raws.semicolon = false;
-
- return;
- }
-
- message = messages.rejected;
- } else {
- throw new Error(`Unexpected primary option: "${primary}"`);
- }
-
- report({
- message,
- node,
- index: node.toString().trim().length - 1,
- result,
- ruleName,
- });
- }
- };
-};
-
-rule.ruleName = ruleName;
-rule.messages = messages;
-rule.meta = meta;
-module.exports = rule;
diff --git a/lib/rules/declaration-colon-newline-after/README.md b/lib/rules/declaration-colon-newline-after/README.md
deleted file mode 100644
index dde51452d2..0000000000
--- a/lib/rules/declaration-colon-newline-after/README.md
+++ /dev/null
@@ -1,80 +0,0 @@
-# declaration-colon-newline-after
-
-> **Warning** This rule is deprecated and will be removed in the future. See [the migration guide](../../../docs/migration-guide/to-15.md).
-
-Require a newline or disallow whitespace after the colon of declarations.
-
-
-```css
-a {
- box-shadow:
- 0 0 0 1px #5b9dd9,
- 0 0 2px 1px rgba(30, 140, 190, 0.8);
-} /* ↑ */
-/** ↑
- * The newline after this colon */
-```
-
-The [`fix` option](../../../docs/user-guide/options.md#fix) can automatically fix all of the problems reported by this rule.
-
-## Options
-
-`string`: `"always"|"always-multi-line"`
-
-### `"always"`
-
-There _must always_ be a newline after the colon.
-
-The following patterns are considered problems:
-
-
-```css
-a { color:pink; }
-```
-
-
-```css
-a { color: pink; }
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a {
- color:
- pink;
-}
-```
-
-### `"always-multi-line"`
-
-There _must always_ be a newline after the colon _if the declaration's value is multi-line_.
-
-The following patterns are considered problems:
-
-
-```css
-a {
- box-shadow: 0 0 0 1px #5b9dd9,
- 0 0 2px 1px rgba(30, 140, 190, 0.8);
-}
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a {
- box-shadow:
- 0 0 0 1px #5b9dd9,
- 0 0 2px 1px rgba(30, 140, 190, 0.8);
-}
-```
-
-
-```css
-a {
- color: pink;
-}
-```
diff --git a/lib/rules/declaration-colon-newline-after/__tests__/index.js b/lib/rules/declaration-colon-newline-after/__tests__/index.js
deleted file mode 100644
index b87b8f6ada..0000000000
--- a/lib/rules/declaration-colon-newline-after/__tests__/index.js
+++ /dev/null
@@ -1,211 +0,0 @@
-'use strict';
-
-const { messages, ruleName } = require('..');
-
-testRule({
- ruleName,
- config: ['always'],
- fix: true,
-
- accept: [
- {
- code: 'a {\n' + ' color:\n' + ' pink\n' + '}',
-
- description: 'newline and spaces after',
- },
- {
- code: 'a { color :\npink }',
- description: 'space before and newline after',
- },
- {
- code: 'a { color\n:\npink }',
- description: 'newline before after',
- },
- {
- code: 'a { color\r\n:\r\npink }',
- description: 'CRLF before and after',
- },
- {
- code: 'a { color\n\n:\n\npink }',
- description: 'double newline before after',
- },
- {
- code: 'a { color\r\n\r\n:\r\n\r\npink }',
- description: 'double CRLF before and after',
- },
- {
- code: '$map: (key: value)',
- description: 'SCSS map with no newlines',
- },
- {
- code: 'a { background:\n url(data:application/font-woff;...); }',
- description: 'data URI',
- },
- ],
-
- reject: [
- {
- code: 'a { color :pink; }',
- fixed: 'a { color :\npink; }',
- description: 'no newline after',
- message: messages.expectedAfter(),
- line: 1,
- column: 11,
- },
- {
- code: 'a { color : pink; }',
- fixed: 'a { color :\n pink; }',
- description: 'two spaces after',
- message: messages.expectedAfter(),
- line: 1,
- column: 11,
- },
- {
- code: 'a { color :\tpink; }',
- fixed: 'a { color :\n\tpink; }',
- description: 'tab after',
- message: messages.expectedAfter(),
- line: 1,
- column: 11,
- },
- {
- code: 'a { color : pink; }',
- fixed: 'a { color :\n pink; }',
- description: 'space after',
- message: messages.expectedAfter(),
- line: 1,
- column: 11,
- },
- {
- code: 'a { color : \npink; }',
- fixed: 'a { color :\npink; }',
- description: 'space and newline after',
- message: messages.expectedAfter(),
- line: 1,
- column: 11,
- },
- {
- code: 'a { color : \r\npink; }',
- fixed: 'a { color :\r\npink; }',
- description: 'space and CRLF after',
- message: messages.expectedAfter(),
- line: 1,
- column: 11,
- },
- {
- code: 'a { color : \t\n\t\npink; }',
- fixed: 'a { color :\n\t\npink; }',
- description: 'space and newline tab after',
- message: messages.expectedAfter(),
- line: 1,
- column: 11,
- },
- {
- code: 'a { color :/*comment*/pink; }',
- fixed: 'a { color :/*comment*/\npink; }',
- description: 'comment',
- message: messages.expectedAfter(),
- line: 1,
- column: 22,
- },
- {
- code: 'a { color : /*comment*/ pink; }',
- fixed: 'a { color : /*comment*/\n pink; }',
- description: 'comment',
- message: messages.expectedAfter(),
- line: 1,
- column: 23,
- },
- {
- code: 'a { color : \n/*comment*/ pink; }',
- fixed: 'a { color :\n/*comment*/ pink; }',
- description: 'comment before newline',
- message: messages.expectedAfter(),
- line: 1,
- column: 11,
- },
- {
- code: 'a { color : pink; }',
- fixed: 'a { color :\n pink; }',
- description: 'multi space',
- message: messages.expectedAfter(),
- line: 1,
- column: 18,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['always-multi-line'],
- fix: true,
-
- accept: [
- {
- code: 'a {\n' + ' color: pink\n' + '}',
- },
- {
- code:
- 'a {\n' +
- ' box-shadow:\n' +
- ' 0 0 0 1px #5b9dd9\n' +
- ' 0 0 2px 1px rgba(30, 140, 190, 0.8);\n' +
- '}',
- },
- {
- code: '$map\n: (\nkey: value,\nkey2 :value2)',
- description: 'SCSS map with newlines',
- },
- {
- code: "$list: (\n'value1',\n'value2',\n)",
- description: 'SCSS list with newlines',
- },
- {
- code: 'a { color:pink }',
- },
- {
- code: 'a { color :\tpink }',
- },
- {
- code: 'a { color\n: pink }',
- },
- {
- code: 'a { color\r\n: pink }',
- },
- ],
-
- reject: [
- {
- code:
- 'a {\n' +
- ' box-shadow: 0 0 0 1px #5b9dd9\n' +
- ' 0 0 2px 1px rgba(30, 140, 190, 0.8);\n' +
- '}',
- fixed:
- 'a {\n' +
- ' box-shadow:\n' +
- ' 0 0 0 1px #5b9dd9\n' +
- ' 0 0 2px 1px rgba(30, 140, 190, 0.8);\n' +
- '}',
- message: messages.expectedAfterMultiLine(),
- line: 2,
- column: 13,
- },
- {
- code:
- 'a {\n' +
- ' box-shadow:0 0 0 1px #5b9dd9\n' +
- ' 0 0 2px 1px rgba(30, 140, 190, 0.8);\n' +
- '}',
- fixed:
- 'a {\n' +
- ' box-shadow:\n' +
- '0 0 0 1px #5b9dd9\n' +
- ' 0 0 2px 1px rgba(30, 140, 190, 0.8);\n' +
- '}',
- message: messages.expectedAfterMultiLine(),
- line: 2,
- column: 13,
- },
- ],
-});
diff --git a/lib/rules/declaration-colon-newline-after/index.js b/lib/rules/declaration-colon-newline-after/index.js
deleted file mode 100644
index acfa40465b..0000000000
--- a/lib/rules/declaration-colon-newline-after/index.js
+++ /dev/null
@@ -1,97 +0,0 @@
-'use strict';
-
-const declarationValueIndex = require('../../utils/declarationValueIndex');
-const isStandardSyntaxDeclaration = require('../../utils/isStandardSyntaxDeclaration');
-const report = require('../../utils/report');
-const ruleMessages = require('../../utils/ruleMessages');
-const validateOptions = require('../../utils/validateOptions');
-const whitespaceChecker = require('../../utils/whitespaceChecker');
-
-const ruleName = 'declaration-colon-newline-after';
-
-const messages = ruleMessages(ruleName, {
- expectedAfter: () => 'Expected newline after ":"',
- expectedAfterMultiLine: () => 'Expected newline after ":" with a multi-line declaration',
-});
-
-const meta = {
- url: 'https://stylelint.io/user-guide/rules/declaration-colon-newline-after',
- fixable: true,
- deprecated: true,
-};
-
-/** @type {import('stylelint').Rule} */
-const rule = (primary, _secondaryOptions, context) => {
- const checker = whitespaceChecker('newline', primary, messages);
-
- return (root, result) => {
- const validOptions = validateOptions(result, ruleName, {
- actual: primary,
- possible: ['always', 'always-multi-line'],
- });
-
- if (!validOptions) {
- return;
- }
-
- root.walkDecls((decl) => {
- if (!isStandardSyntaxDeclaration(decl)) {
- return;
- }
-
- // Get the raw prop, and only the prop
- const endOfPropIndex = declarationValueIndex(decl) + (decl.raws.between || '').length - 1;
-
- // The extra characters tacked onto the end ensure that there is a character to check
- // after the colon. Otherwise, with `background:pink` the character after the
- const propPlusColon = `${decl.toString().slice(0, endOfPropIndex)}xxx`;
-
- for (let i = 0, l = propPlusColon.length; i < l; i++) {
- if (propPlusColon[i] !== ':') {
- continue;
- }
-
- const indexToCheck = /^[^\S\r\n]*\/\*/.test(propPlusColon.slice(i + 1))
- ? propPlusColon.indexOf('*/', i) + 1
- : i;
-
- checker.afterOneOnly({
- source: propPlusColon,
- index: indexToCheck,
- lineCheckStr: decl.value,
- err: (m) => {
- if (context.fix) {
- const between = decl.raws.between;
-
- if (between == null) throw new Error('`between` must be present');
-
- const betweenStart = declarationValueIndex(decl) - between.length;
- const sliceIndex = indexToCheck - betweenStart + 1;
- const betweenBefore = between.slice(0, sliceIndex);
- const betweenAfter = between.slice(sliceIndex);
-
- decl.raws.between = /^\s*\n/.test(betweenAfter)
- ? betweenBefore + betweenAfter.replace(/^[^\S\r\n]*/, '')
- : betweenBefore + context.newline + betweenAfter;
-
- return;
- }
-
- report({
- message: m,
- node: decl,
- index: indexToCheck,
- result,
- ruleName,
- });
- },
- });
- }
- });
- };
-};
-
-rule.ruleName = ruleName;
-rule.messages = messages;
-rule.meta = meta;
-module.exports = rule;
diff --git a/lib/rules/declaration-colon-space-after/README.md b/lib/rules/declaration-colon-space-after/README.md
deleted file mode 100644
index d8918bcb3e..0000000000
--- a/lib/rules/declaration-colon-space-after/README.md
+++ /dev/null
@@ -1,113 +0,0 @@
-# declaration-colon-space-after
-
-> **Warning** This rule is deprecated and will be removed in the future. See [the migration guide](../../../docs/migration-guide/to-15.md).
-
-Require a single space or disallow whitespace after the colon of declarations.
-
-
-```css
-a { color: pink }
-/** ↑
- * The space after this colon */
-```
-
-The [`fix` option](../../../docs/user-guide/options.md#fix) can automatically fix all of the problems reported by this rule.
-
-## Options
-
-`string`: `"always"|"never"|"always-single-line"`
-
-### `"always"`
-
-There _must always_ be a single space after the colon.
-
-The following patterns are considered problems:
-
-
-```css
-a { color :pink }
-```
-
-
-```css
-a { color:pink }
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { color : pink }
-```
-
-
-```css
-a { color: pink }
-```
-
-### `"never"`
-
-There _must never_ be whitespace after the colon.
-
-The following patterns are considered problems:
-
-
-```css
-a { color : pink }
-```
-
-
-```css
-a { color: pink }
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { color :pink }
-```
-
-
-```css
-a { color:pink }
-```
-
-### `"always-single-line"`
-
-There _must always_ be a single space after the colon _if the declaration's value is single-line_.
-
-The following patterns are considered problems:
-
-
-```css
-a {
- box-shadow:0 0 0 1px #5b9dd9, 0 0 2px 1px rgba(30, 140, 190, 0.8);
-}
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a {
- box-shadow: 0 0 0 1px #5b9dd9, 0 0 2px 1px rgba(30, 140, 190, 0.8);
-}
-```
-
-
-```css
-a {
- box-shadow:
- 0 0 0 1px #5b9dd9,
- 0 0 2px 1px rgba(30, 140, 190, 0.8);
-}
-```
-
-
-```css
-a {
- box-shadow:0 0 0 1px #5b9dd9,
- 0 0 2px 1px rgba(30, 140, 190, 0.8);
-}
-```
diff --git a/lib/rules/declaration-colon-space-after/__tests__/index.js b/lib/rules/declaration-colon-space-after/__tests__/index.js
deleted file mode 100644
index 7b1bd81467..0000000000
--- a/lib/rules/declaration-colon-space-after/__tests__/index.js
+++ /dev/null
@@ -1,267 +0,0 @@
-'use strict';
-
-const { messages, ruleName } = require('..');
-
-testRule({
- ruleName,
- config: ['always'],
- fix: true,
-
- accept: [
- {
- code: 'a { color: pink }',
- description: 'space only after',
- },
- {
- code: 'a { color : pink }',
- description: 'space before and after',
- },
- {
- code: 'a { color\n: pink }',
- description: 'newline before and space after',
- },
- {
- code: 'a { color\r\n: pink }',
- description: 'CRLF before and space after',
- },
- {
- code: '$map:(key:value)',
- description: 'SCSS map with no newlines',
- },
- {
- code: "$list:('value1', 'value2')",
- description: 'SCSS lst with no newlines',
- },
- {
- code: 'a { background: url(data:application/font-woff;...); }',
- description: 'data URI',
- },
- ],
-
- reject: [
- {
- code: 'a { color :pink; }',
- fixed: 'a { color : pink; }',
- description: 'no space after',
- message: messages.expectedAfter(),
- line: 1,
- column: 11,
- },
- {
- code: 'a { color : pink; }',
- fixed: 'a { color : pink; }',
- description: 'two spaces after',
- message: messages.expectedAfter(),
- line: 1,
- column: 11,
- },
- {
- code: 'a { color :\tpink; }',
- fixed: 'a { color : pink; }',
- description: 'tab after',
- message: messages.expectedAfter(),
- line: 1,
- column: 11,
- },
- {
- code: 'a { color :\npink; }',
- fixed: 'a { color : pink; }',
- description: 'newline after',
- message: messages.expectedAfter(),
- line: 1,
- column: 11,
- },
- {
- code: 'a { color :\r\npink; }',
- fixed: 'a { color : pink; }',
- description: 'CRLF after',
- message: messages.expectedAfter(),
- line: 1,
- column: 11,
- },
- {
- code: 'a { color:pink; }',
- fixed: 'a { color: pink; }',
- description: 'no space after',
- message: messages.expectedAfter(),
- line: 1,
- column: 11,
- },
- {
- code: 'a { color/*comment*/:/*comment*/pink; }',
- fixed: 'a { color/*comment*/: /*comment*/pink; }',
- description: 'comment',
- message: messages.expectedAfter(),
- line: 1,
- column: 11,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['never'],
- fix: true,
-
- accept: [
- {
- code: 'a { color:pink }',
- description: 'no space before and after',
- },
- {
- code: 'a { color :pink }',
- description: 'space before and no space after',
- },
- {
- code: 'a { color\n:pink }',
- description: 'newline before and no space after',
- },
- {
- code: 'a { color\r\n:pink }',
- description: 'CRLF before and no space after',
- },
- {
- code: '$map: (key: value)',
- description: 'SCSS map with no newlines',
- },
- ],
-
- reject: [
- {
- code: 'a { color : pink; }',
- fixed: 'a { color :pink; }',
- description: 'space after',
- message: messages.rejectedAfter(),
- line: 1,
- column: 11,
- },
- {
- code: 'a { color: pink; }',
- fixed: 'a { color:pink; }',
- description: 'two spaces after',
- message: messages.rejectedAfter(),
- line: 1,
- column: 11,
- },
- {
- code: 'a { color :\tpink; }',
- fixed: 'a { color :pink; }',
- description: 'tab after',
- message: messages.rejectedAfter(),
- line: 1,
- column: 11,
- },
- {
- code: 'a { color :\npink; }',
- fixed: 'a { color :pink; }',
- description: 'newline after',
- message: messages.rejectedAfter(),
- line: 1,
- column: 11,
- },
- {
- code: 'a { color :\r\npink; }',
- fixed: 'a { color :pink; }',
- description: 'CRLF after',
- message: messages.rejectedAfter(),
- line: 1,
- column: 11,
- },
- {
- code: 'a { color/*comment*/ : /*comment*/pink; }',
- fixed: 'a { color/*comment*/ :/*comment*/pink; }',
- description: 'comment',
- message: messages.rejectedAfter(),
- line: 1,
- column: 11,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['always-single-line'],
- fix: true,
-
- accept: [
- {
- code: 'a { color: pink }',
- description: 'space only after single-line',
- },
- {
- code: 'a { transition: color 1s,\n\twidth 2s; }',
- description: 'space after mult-line',
- },
- {
- code: 'a { transition:color 1s,\n\twidth 2s; }',
- description: 'no space after mult-line',
- },
- {
- code: 'a { transition:color 1s,\r\n\twidth 2s; }',
- description: 'no space after mult-line CRLF',
- },
- {
- code: 'a { transition:\tcolor 1s,\n\twidth 2s; }',
- description: 'tab after mult-line',
- },
- ],
-
- reject: [
- {
- code: 'a { color :pink; }',
- fixed: 'a { color : pink; }',
- description: 'no space after single-line',
- message: messages.expectedAfterSingleLine(),
- line: 1,
- column: 11,
- },
- {
- code: 'a { color : pink; }',
- fixed: 'a { color : pink; }',
- description: 'two spaces after single-line',
- message: messages.expectedAfterSingleLine(),
- line: 1,
- column: 11,
- },
- {
- code: 'a { color :\tpink; }',
- fixed: 'a { color : pink; }',
- description: 'tab after single-line',
- message: messages.expectedAfterSingleLine(),
- line: 1,
- column: 11,
- },
- {
- code: 'a { color :\npink; }',
- fixed: 'a { color : pink; }',
- description: 'newline after single-line',
- message: messages.expectedAfterSingleLine(),
- line: 1,
- column: 11,
- },
- {
- code: 'a { color :\r\npink; }',
- fixed: 'a { color : pink; }',
- description: 'CRLF after single-line',
- message: messages.expectedAfterSingleLine(),
- line: 1,
- column: 11,
- },
- {
- code: 'a { color:pink; }',
- fixed: 'a { color: pink; }',
- description: 'no space after',
- message: messages.expectedAfterSingleLine(),
- line: 1,
- column: 11,
- },
- {
- code: 'a { color/*comment*/:/*comment*/pink; }',
- fixed: 'a { color/*comment*/: /*comment*/pink; }',
- description: 'comment',
- message: messages.expectedAfterSingleLine(),
- line: 1,
- column: 11,
- },
- ],
-});
diff --git a/lib/rules/declaration-colon-space-after/index.js b/lib/rules/declaration-colon-space-after/index.js
deleted file mode 100644
index 93bda5ffc2..0000000000
--- a/lib/rules/declaration-colon-space-after/index.js
+++ /dev/null
@@ -1,73 +0,0 @@
-'use strict';
-
-const declarationColonSpaceChecker = require('../declarationColonSpaceChecker');
-const declarationValueIndex = require('../../utils/declarationValueIndex');
-const ruleMessages = require('../../utils/ruleMessages');
-const validateOptions = require('../../utils/validateOptions');
-const whitespaceChecker = require('../../utils/whitespaceChecker');
-
-const ruleName = 'declaration-colon-space-after';
-
-const messages = ruleMessages(ruleName, {
- expectedAfter: () => 'Expected single space after ":"',
- rejectedAfter: () => 'Unexpected whitespace after ":"',
- expectedAfterSingleLine: () => 'Expected single space after ":" with a single-line declaration',
-});
-
-const meta = {
- url: 'https://stylelint.io/user-guide/rules/declaration-colon-space-after',
- fixable: true,
- deprecated: true,
-};
-
-/** @type {import('stylelint').Rule} */
-const rule = (primary, _secondaryOptions, context) => {
- const checker = whitespaceChecker('space', primary, messages);
-
- return (root, result) => {
- const validOptions = validateOptions(result, ruleName, {
- actual: primary,
- possible: ['always', 'never', 'always-single-line'],
- });
-
- if (!validOptions) {
- return;
- }
-
- declarationColonSpaceChecker({
- root,
- result,
- locationChecker: checker.after,
- checkedRuleName: ruleName,
- fix: context.fix
- ? (decl, index) => {
- const colonIndex = index - declarationValueIndex(decl);
- const between = decl.raws.between;
-
- if (between == null) throw new Error('`between` must be present');
-
- if (primary.startsWith('always')) {
- decl.raws.between =
- between.slice(0, colonIndex) + between.slice(colonIndex).replace(/^:\s*/, ': ');
-
- return true;
- }
-
- if (primary === 'never') {
- decl.raws.between =
- between.slice(0, colonIndex) + between.slice(colonIndex).replace(/^:\s*/, ':');
-
- return true;
- }
-
- return false;
- }
- : null,
- });
- };
-};
-
-rule.ruleName = ruleName;
-rule.messages = messages;
-rule.meta = meta;
-module.exports = rule;
diff --git a/lib/rules/declaration-colon-space-before/README.md b/lib/rules/declaration-colon-space-before/README.md
deleted file mode 100644
index 8c07819e45..0000000000
--- a/lib/rules/declaration-colon-space-before/README.md
+++ /dev/null
@@ -1,74 +0,0 @@
-# declaration-colon-space-before
-
-> **Warning** This rule is deprecated and will be removed in the future. See [the migration guide](../../../docs/migration-guide/to-15.md).
-
-Require a single space or disallow whitespace before the colon of declarations.
-
-
-```css
-a { color :pink }
-/** ↑
- * The space before this colon */
-```
-
-The [`fix` option](../../../docs/user-guide/options.md#fix) can automatically fix all of the problems reported by this rule.
-
-## Options
-
-`string`: `"always"|"never"`
-
-### `"always"`
-
-There _must always_ be a single space before the colon.
-
-The following patterns are considered problems:
-
-
-```css
-a { color: pink }
-```
-
-
-```css
-a { color:pink }
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { color : pink }
-```
-
-
-```css
-a { color :pink }
-```
-
-### `"never"`
-
-There _must never_ be whitespace before the colon.
-
-The following patterns are considered problems:
-
-
-```css
-a { color : pink }
-```
-
-
-```css
-a { color :pink }
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { color: pink }
-```
-
-
-```css
-a { color:pink }
-```
diff --git a/lib/rules/declaration-colon-space-before/__tests__/index.js b/lib/rules/declaration-colon-space-before/__tests__/index.js
deleted file mode 100644
index 77c56596a0..0000000000
--- a/lib/rules/declaration-colon-space-before/__tests__/index.js
+++ /dev/null
@@ -1,171 +0,0 @@
-'use strict';
-
-const { messages, ruleName } = require('..');
-
-testRule({
- ruleName,
- config: ['always'],
- fix: true,
-
- accept: [
- {
- code: 'a { color :pink }',
- description: 'space only before',
- },
- {
- code: 'a { color : pink }',
- description: 'space before and after',
- },
- {
- code: 'a { color :\npink }',
- description: 'space before and newline after',
- },
- {
- code: 'a { color :\r\npink }',
- description: 'space before and CRLF after',
- },
- {
- code: '$map:(key:value)',
- description: 'SCSS map with no newlines',
- },
- {
- code: "$list:('value1', 'value2')",
- description: 'SCSS list with no newlines',
- },
- {
- code: 'a { background : url(data:application/font-woff;...); }',
- description: 'data URI',
- },
- ],
-
- reject: [
- {
- code: 'a { color: pink; }',
- fixed: 'a { color : pink; }',
- description: 'no space before',
- message: messages.expectedBefore(),
- line: 1,
- column: 11,
- },
- {
- code: 'a { color : pink; }',
- fixed: 'a { color : pink; }',
- description: 'two spaces before',
- message: messages.expectedBefore(),
- line: 1,
- column: 11,
- },
- {
- code: 'a { color\t: pink; }',
- fixed: 'a { color : pink; }',
- description: 'tab before',
- message: messages.expectedBefore(),
- line: 1,
- column: 11,
- },
- {
- code: 'a { color\n: pink; }',
- fixed: 'a { color : pink; }',
- description: 'newline before',
- message: messages.expectedBefore(),
- line: 2,
- column: 1,
- },
- {
- code: 'a { color\r\n: pink; }',
- fixed: 'a { color : pink; }',
- description: 'CRLF before',
- message: messages.expectedBefore(),
- line: 1,
- column: 11,
- },
- {
- code: 'a { color/*comment*/:/*comment*/pink; }',
- fixed: 'a { color/*comment*/ :/*comment*/pink; }',
- description: 'comment',
- message: messages.expectedBefore(),
- line: 1,
- column: 11,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['never'],
- fix: true,
-
- accept: [
- {
- code: 'a { color:pink }',
- description: 'no space before and after',
- },
- {
- code: 'a { color: pink }',
- description: 'no space before and space after',
- },
- {
- code: 'a { color:\npink }',
- description: 'no space before and newline after',
- },
- {
- code: 'a { color:\r\npink }',
- description: 'no space before and CRLF after',
- },
- {
- code: '$map :(key :value)',
- description: 'SCSS map with no newlines',
- },
- ],
-
- reject: [
- {
- code: 'a { color : pink; }',
- fixed: 'a { color: pink; }',
- description: 'space before',
- message: messages.rejectedBefore(),
- line: 1,
- column: 11,
- },
- {
- code: 'a { color : pink; }',
- fixed: 'a { color: pink; }',
- description: 'two spaces before',
- message: messages.rejectedBefore(),
- line: 1,
- column: 11,
- },
- {
- code: 'a { color\t: pink; }',
- fixed: 'a { color: pink; }',
- description: 'tab before',
- message: messages.rejectedBefore(),
- line: 1,
- column: 11,
- },
- {
- code: 'a { color\n: pink; }',
- fixed: 'a { color: pink; }',
- description: 'newline before',
- message: messages.rejectedBefore(),
- line: 2,
- column: 1,
- },
- {
- code: 'a { color\r\n: pink; }',
- fixed: 'a { color: pink; }',
- description: 'CRLF before',
- message: messages.rejectedBefore(),
- line: 1,
- column: 11,
- },
- {
- code: 'a { color/*comment*/ :/*comment*/pink; }',
- fixed: 'a { color/*comment*/:/*comment*/pink; }',
- description: 'comment',
- message: messages.rejectedBefore(),
- line: 1,
- column: 11,
- },
- ],
-});
diff --git a/lib/rules/declaration-colon-space-before/index.js b/lib/rules/declaration-colon-space-before/index.js
deleted file mode 100644
index 38e8966958..0000000000
--- a/lib/rules/declaration-colon-space-before/index.js
+++ /dev/null
@@ -1,72 +0,0 @@
-'use strict';
-
-const declarationColonSpaceChecker = require('../declarationColonSpaceChecker');
-const declarationValueIndex = require('../../utils/declarationValueIndex');
-const ruleMessages = require('../../utils/ruleMessages');
-const validateOptions = require('../../utils/validateOptions');
-const whitespaceChecker = require('../../utils/whitespaceChecker');
-
-const ruleName = 'declaration-colon-space-before';
-
-const messages = ruleMessages(ruleName, {
- expectedBefore: () => 'Expected single space before ":"',
- rejectedBefore: () => 'Unexpected whitespace before ":"',
-});
-
-const meta = {
- url: 'https://stylelint.io/user-guide/rules/declaration-colon-space-before',
- fixable: true,
- deprecated: true,
-};
-
-/** @type {import('stylelint').Rule} */
-const rule = (primary, _secondaryOptions, context) => {
- const checker = whitespaceChecker('space', primary, messages);
-
- return (root, result) => {
- const validOptions = validateOptions(result, ruleName, {
- actual: primary,
- possible: ['always', 'never'],
- });
-
- if (!validOptions) {
- return;
- }
-
- declarationColonSpaceChecker({
- root,
- result,
- locationChecker: checker.before,
- checkedRuleName: ruleName,
- fix: context.fix
- ? (decl, index) => {
- const colonIndex = index - declarationValueIndex(decl);
- const between = decl.raws.between;
-
- if (between == null) throw new Error('`between` must be present');
-
- if (primary === 'always') {
- decl.raws.between =
- between.slice(0, colonIndex).replace(/\s*$/, ' ') + between.slice(colonIndex);
-
- return true;
- }
-
- if (primary === 'never') {
- decl.raws.between =
- between.slice(0, colonIndex).replace(/\s*$/, '') + between.slice(colonIndex);
-
- return true;
- }
-
- return false;
- }
- : null,
- });
- };
-};
-
-rule.ruleName = ruleName;
-rule.messages = messages;
-rule.meta = meta;
-module.exports = rule;
diff --git a/lib/rules/declaration-empty-line-before/README.md b/lib/rules/declaration-empty-line-before/README.md
index 4586f7a210..4f0b369efd 100644
--- a/lib/rules/declaration-empty-line-before/README.md
+++ b/lib/rules/declaration-empty-line-before/README.md
@@ -15,7 +15,7 @@ a {
This rule only applies to standard property declarations. Use the [`custom-property-empty-line-before`](../custom-property-empty-line-before/README.md) rule for custom property declarations.
-The [`fix` option](../../../docs/user-guide/options.md#fix) can automatically fix all of the problems reported by this rule. We recommend to enable [`indentation`](../indentation/README.md) rule for better autofixing results with this rule.
+The [`fix` option](../../../docs/user-guide/options.md#fix) can automatically fix all of the problems reported by this rule.
## Options
diff --git a/lib/rules/declarationBangSpaceChecker.js b/lib/rules/declarationBangSpaceChecker.js
deleted file mode 100644
index ad17cd22ff..0000000000
--- a/lib/rules/declarationBangSpaceChecker.js
+++ /dev/null
@@ -1,60 +0,0 @@
-'use strict';
-
-const declarationValueIndex = require('../utils/declarationValueIndex');
-const report = require('../utils/report');
-const styleSearch = require('style-search');
-
-/** @typedef {import('postcss').Declaration} Declaration */
-
-/** @typedef {(args: { source: string, index: number, err: (message: string) => void }) => void} LocationChecker */
-
-/**
- * @param {{
- * root: import('postcss').Root,
- * locationChecker: LocationChecker,
- * result: import('stylelint').PostcssResult,
- * checkedRuleName: string,
- * fix: ((decl: Declaration, index: number) => boolean) | null,
- * }} opts
- * @returns {void}
- */
-module.exports = function declarationBangSpaceChecker(opts) {
- opts.root.walkDecls((decl) => {
- const indexOffset = declarationValueIndex(decl);
- const declString = decl.toString();
- const valueString = decl.toString().slice(indexOffset);
-
- if (!valueString.includes('!')) {
- return;
- }
-
- styleSearch({ source: valueString, target: '!' }, (match) => {
- check(declString, match.startIndex + indexOffset, decl);
- });
- });
-
- /**
- * @param {string} source
- * @param {number} index
- * @param {Declaration} decl
- */
- function check(source, index, decl) {
- opts.locationChecker({
- source,
- index,
- err: (message) => {
- if (opts.fix && opts.fix(decl, index)) {
- return;
- }
-
- report({
- message,
- node: decl,
- index,
- result: opts.result,
- ruleName: opts.checkedRuleName,
- });
- },
- });
- }
-};
diff --git a/lib/rules/declarationColonSpaceChecker.js b/lib/rules/declarationColonSpaceChecker.js
deleted file mode 100644
index 1f84e1d300..0000000000
--- a/lib/rules/declarationColonSpaceChecker.js
+++ /dev/null
@@ -1,57 +0,0 @@
-'use strict';
-
-const declarationValueIndex = require('../utils/declarationValueIndex');
-const isStandardSyntaxDeclaration = require('../utils/isStandardSyntaxDeclaration');
-const report = require('../utils/report');
-
-/** @typedef {(args: { source: string, index: number, lineCheckStr: string, err: (message: string) => void }) => void} LocationChecker */
-
-/**
- * @param {{
- * root: import('postcss').Root,
- * locationChecker: LocationChecker,
- * fix: ((decl: import('postcss').Declaration, index: number) => boolean) | null,
- * result: import('stylelint').PostcssResult,
- * checkedRuleName: string,
- * }} opts
- */
-module.exports = function declarationColonSpaceChecker(opts) {
- opts.root.walkDecls((decl) => {
- if (!isStandardSyntaxDeclaration(decl)) {
- return;
- }
-
- // Get the raw prop, and only the prop
- const endOfPropIndex = declarationValueIndex(decl) + (decl.raws.between || '').length - 1;
-
- // The extra characters tacked onto the end ensure that there is a character to check
- // after the colon. Otherwise, with `background:pink` the character after the
- const propPlusColon = `${decl.toString().slice(0, endOfPropIndex)}xxx`;
-
- for (let i = 0, l = propPlusColon.length; i < l; i++) {
- if (propPlusColon[i] !== ':') {
- continue;
- }
-
- opts.locationChecker({
- source: propPlusColon,
- index: i,
- lineCheckStr: decl.value,
- err: (message) => {
- if (opts.fix && opts.fix(decl, i)) {
- return;
- }
-
- report({
- message,
- node: decl,
- index: decl.prop.toString().length + 1,
- result: opts.result,
- ruleName: opts.checkedRuleName,
- });
- },
- });
- break;
- }
- });
-};
diff --git a/lib/rules/findMediaOperator.js b/lib/rules/findMediaOperator.js
deleted file mode 100644
index 698ea8b0be..0000000000
--- a/lib/rules/findMediaOperator.js
+++ /dev/null
@@ -1,30 +0,0 @@
-'use strict';
-
-const styleSearch = require('style-search');
-
-const rangeOperators = ['>=', '<=', '>', '<', '='];
-
-/** @typedef {import('style-search').StyleSearchMatch} StyleSearchMatch */
-
-/**
- * @template {import('postcss').AtRule} T
- * @param {T} atRule
- * @param {(match: StyleSearchMatch, params: string, atRule: T) => void} cb
- */
-module.exports = function findMediaOperator(atRule, cb) {
- if (atRule.name.toLowerCase() !== 'media') {
- return;
- }
-
- const params = atRule.raws.params ? atRule.raws.params.raw : atRule.params;
-
- styleSearch({ source: params, target: rangeOperators }, (match) => {
- const before = params[match.startIndex - 1];
-
- if (before === '>' || before === '<') {
- return;
- }
-
- cb(match, params, atRule);
- });
-};
diff --git a/lib/rules/function-comma-newline-after/README.md b/lib/rules/function-comma-newline-after/README.md
deleted file mode 100644
index 75b4e7b2ab..0000000000
--- a/lib/rules/function-comma-newline-after/README.md
+++ /dev/null
@@ -1,115 +0,0 @@
-# function-comma-newline-after
-
-> **Warning** This rule is deprecated and will be removed in the future. See [the migration guide](../../../docs/migration-guide/to-15.md).
-
-Require a newline or disallow whitespace after the commas of functions.
-
-
-```css
-a { transform: translate(1,
- 1) } /* ↑ */
-/** ↑
- * These commas */
-```
-
-The [`fix` option](../../../docs/user-guide/options.md#fix) can automatically fix all of the problems reported by this rule.
-
-## Options
-
-`string`: `"always"|"always-multi-line"|"never-multi-line"`
-
-### `"always"`
-
-There _must always_ be a newline after the commas.
-
-The following patterns are considered problems:
-
-
-```css
-a { transform: translate(1,1) }
-```
-
-
-```css
-a { transform: translate(1 ,1) }
-```
-
-
-```css
-a { transform: translate(1
- ,1) }
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a {
- transform: translate(1,
- 1)
-}
-```
-
-### `"always-multi-line"`
-
-There _must always_ be a newline after the commas in multi-line functions.
-
-The following patterns are considered problems:
-
-
-```css
-a { transform: translate(1
- ,1) }
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { transform: translate(1,1) }
-```
-
-
-```css
-a { transform: translate(1 ,1) }
-```
-
-
-```css
-a {
- transform: translate(1,
- 1)
-}
-```
-
-### `"never-multi-line"`
-
-There _must never_ be whitespace after the commas in multi-line functions.
-
-The following patterns are considered problems:
-
-
-```css
-a { transform: translate(1
- , 1) }
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { transform: translate(1, 1) }
-```
-
-
-```css
-a { transform: translate(1 , 1) }
-```
-
-
-```css
-a {
- transform: translate(1
- ,1)
-}
-```
diff --git a/lib/rules/function-comma-newline-after/__tests__/index.js b/lib/rules/function-comma-newline-after/__tests__/index.js
deleted file mode 100644
index 2c370dafd1..0000000000
--- a/lib/rules/function-comma-newline-after/__tests__/index.js
+++ /dev/null
@@ -1,432 +0,0 @@
-'use strict';
-
-const { messages, ruleName } = require('..');
-
-testRule({
- ruleName,
- config: ['always'],
- fix: true,
-
- accept: [
- {
- code: 'a::before { content: "func(foo, bar, baz)"; }',
- },
- {
- code: "a::before { background: url('func(foo,bar,baz)'); }",
- },
- {
- code: 'a { background-size: 0,\n 0,\n 0; }',
- },
- {
- code: 'a { transform: translate(1 ,\n1); }',
- },
- {
- code: 'a { transform: translate(1 ,\n\n1); }',
- },
- {
- code: 'a { transform: translate(\n 1,\n 1\n); }',
- },
- {
- code: 'a { transform: translate(1,\r\n1); }',
- description: 'CRLF',
- },
- {
- code: 'a { transform: translate(1,\r\n\r\n1); }',
- description: 'CRLF',
- },
- {
- code: 'a { transform: color(rgb(0 ,\n\t0,\n\t0) lightness(50%)); }',
- },
- {
- code: 'a { background: linear-gradient(45deg,\n rgba(0,\n 0,\n 0,\n 1),\n red); }',
- },
- {
- code: `
- a {
- transform: translate(
- 1px, /* comment */
- 1px
- );
- }
- `,
- description: 'eol comments',
- },
- ],
-
- reject: [
- {
- code: 'a { transform: translate(1,1); }',
- fixed: 'a { transform: translate(1,\n1); }',
- message: messages.expectedAfter(),
- line: 1,
- column: 27,
- },
- {
- code: 'a { transform: translate(1, 1); }',
- fixed: 'a { transform: translate(1,\n1); }',
- message: messages.expectedAfter(),
- line: 1,
- column: 27,
- },
- {
- code: 'a { transform: translate(1, 1); }',
- fixed: 'a { transform: translate(1,\n1); }',
- message: messages.expectedAfter(),
- line: 1,
- column: 27,
- },
- {
- code: 'a\r\n{ transform: translate(1, 1); }',
- fixed: 'a\r\n{ transform: translate(1,\r\n1); }',
- description: 'CRLF',
- message: messages.expectedAfter(),
- line: 2,
- column: 25,
- },
- {
- code: 'a { transform: translate(1,\t1); }',
- fixed: 'a { transform: translate(1,\n1); }',
- message: messages.expectedAfter(),
- line: 1,
- column: 27,
- },
- {
- code: 'a { transform: color(rgb(0 , 0 ,\n0) lightness(50%)); }',
- fixed: 'a { transform: color(rgb(0 ,\n0 ,\n0) lightness(50%)); }',
- message: messages.expectedAfter(),
- line: 1,
- column: 28,
- },
- {
- code: 'a { transform: color(lightness(50%) rgb(0 ,\n 0 ,0)); }',
- fixed: 'a { transform: color(lightness(50%) rgb(0 ,\n 0 ,\n0)); }',
- message: messages.expectedAfter(),
- line: 2,
- column: 4,
- },
- {
- code: 'a { background: linear-gradient(45deg,\n rgba(0,\n 0, 0,\n 1),\n red); }',
- fixed: 'a { background: linear-gradient(45deg,\n rgba(0,\n 0,\n0,\n 1),\n red); }',
- message: messages.expectedAfter(),
- line: 3,
- column: 3,
- },
- {
- code: 'a { transform: translate(\n 1,1\n); }',
- fixed: 'a { transform: translate(\n 1,\n1\n); }',
- message: messages.expectedAfter(),
- line: 2,
- column: 4,
- },
- {
- code:
- 'a {\n transform: translate(\n 1px, /* comment (with trailing space) */ \n' +
- ' 1px\n );\n}',
- fixed:
- 'a {\n transform: translate(\n 1px,\n/* comment (with trailing space) */ \n' +
- ' 1px\n );\n}',
- description: 'eol comments',
- message: messages.expectedAfter(),
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['always'],
- customSyntax: 'postcss-scss',
-
- accept: [
- {
- code: '$map: (key: value, key2: value2)',
- description: 'sass map ignored',
- },
- {
- code: '$list: (value, value2)',
- description: 'sass list ignored',
- },
- {
- code: `
- a {
- transform: translate(
- 1px, // line comment
- 1px
- );
- }
- `,
- description: 'eol comments',
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['always-multi-line'],
- fix: true,
-
- accept: [
- {
- code: 'a::before { content: "func(foo, bar, baz)"; }',
- },
- {
- code: "a::before { background: url('func(foo,bar,baz)'); }",
- },
- {
- code: 'a { background-size: 0,\n 0,\n 0; }',
- },
- {
- code: 'a { transform: translate(1 ,\n1); }',
- },
- {
- code: 'a { transform: translate(1,\r\n1); }',
- description: 'CRLF',
- },
- {
- code: 'a { transform: color(rgb(0 ,\n\t0,\n\t0) lightness(50%)); }',
- },
- {
- code: 'a { transform: translate(1,1); }',
- },
- {
- code: 'a { transform: translate(1, 1); }',
- },
- {
- code: 'a { transform: translate(1, 1); }',
- },
- {
- code: 'a { transform: translate(1,\t1); }',
- },
- {
- code: 'a {\r\n transform:\r\n translate(1,1)\r\n scale(3);\r\n}',
- description: 'CRLF',
- },
- {
- code: `
- .foo {
- box-shadow:
- inset 0 8px 8px -8px rgba(0, 0, 0, 1)
- inset 0 -10px 12px 0 #f00;
- }
- `,
- },
- {
- code: `
- .foo {
- background-image:
- repeating-linear-gradient(
- -45deg,
- transparent,
- rgba(0, 0, 0, 1) 5px
- );
- }
- `,
- },
- {
- code: `
- a {
- transform: translate(
- 1px, /* comment */
- 1px
- );
- }
- `,
- description: 'eol comments',
- },
- ],
-
- reject: [
- {
- code: 'a { transform: color(rgb(0 , 0 ,\n0) lightness(50%)); }',
- fixed: 'a { transform: color(rgb(0 ,\n0 ,\n0) lightness(50%)); }',
- message: messages.expectedAfterMultiLine(),
- line: 1,
- column: 28,
- },
- {
- code: 'a\r\n{ transform: color(rgb(0 , 0 ,\r\n0) lightness(50%)); }',
- fixed: 'a\r\n{ transform: color(rgb(0 ,\r\n0 ,\r\n0) lightness(50%)); }',
- description: 'CRLF',
- message: messages.expectedAfterMultiLine(),
- line: 2,
- column: 26,
- },
- {
- code: 'a { transform: color(lightness(50%) rgb(0 ,\n 0 ,0)); }',
- fixed: 'a { transform: color(lightness(50%) rgb(0 ,\n 0 ,\n0)); }',
- message: messages.expectedAfterMultiLine(),
- line: 2,
- column: 4,
- },
- {
- code: 'a { background-image: repeating-linear-gradient(\n-45deg,\ntransparent, rgba(0, 0, 0, 1) 5px\n);}',
- fixed:
- 'a { background-image: repeating-linear-gradient(\n-45deg,\ntransparent,\nrgba(0, 0, 0, 1) 5px\n);}',
- message: messages.expectedAfterMultiLine(),
- line: 3,
- column: 12,
- },
- {
- code: 'a { background: linear-gradient(45deg,rgba(0,\n0 ,\n 0 ,\n 1)); }',
- fixed: 'a { background: linear-gradient(45deg,\nrgba(0,\n0 ,\n 0 ,\n 1)); }',
- message: messages.expectedAfterMultiLine(),
- line: 1,
- column: 38,
- },
- {
- code: 'a { transform: translate(\n 1,1\n); }',
- fixed: 'a { transform: translate(\n 1,\n1\n); }',
- message: messages.expectedAfterMultiLine(),
- line: 2,
- column: 4,
- },
- {
- code:
- 'a {\n transform: translate(\n 1px, /* comment (with trailing space) */ \n' +
- ' 1px\n );\n}',
- fixed:
- 'a {\n transform: translate(\n 1px,\n/* comment (with trailing space) */ \n' +
- ' 1px\n );\n}',
- description: 'eol comments',
- message: messages.expectedAfterMultiLine(),
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['always-multi-line'],
- customSyntax: 'postcss-scss',
-
- accept: [
- {
- code: '$map: (key: value\n, key2: value2)',
- description: 'sass map',
- },
- {
- code: `
- a {
- transform: translate(
- 1px, // line comment
- 1px
- );
- }
- `,
- description: 'eol comments',
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['never-multi-line'],
- fix: true,
-
- accept: [
- {
- code: 'a::before { content: "func(foo,\n bar,\n baz)"; }',
- },
- {
- code: "a::before { background: url('func(foo,\nbar,\nbaz)'); }",
- },
- {
- code: 'a { background-size: 0\n, 0\n, 0; }',
- },
- {
- code: 'a { transform: translate(1\r\n,1); }',
- description: 'CRLF',
- },
- {
- code: 'a { transform: color(rgb(0\n\t,0\n\t,0) lightness(50%)); }',
- },
- {
- code: 'a { transform: translate(1,1); }',
- },
- {
- code: 'a { transform: translate(1, 1); }',
- },
- {
- code: 'a { transform: translate(1, 1); }',
- },
- {
- code: 'a { transform: translate(1,\t1); }',
- },
- {
- code: 'a { background: linear-gradient(45deg\n,rgba(0, 0, 0, 1),red); }',
- },
- {
- code: `
- a {
- transform: translate(1px, 1px); /* comment */
- }
- `,
- description: 'eol comments',
- },
- ],
-
- reject: [
- {
- code: 'a { transform: color(rgb(0 ,0 ,\n0) lightness(50%)); }',
- fixed: 'a { transform: color(rgb(0 ,0 ,0) lightness(50%)); }',
- message: messages.rejectedAfterMultiLine(),
- line: 1,
- column: 31,
- },
- {
- code: 'a { transform: color(rgb(0 ,0 ,\r\n0) lightness(50%)); }',
- fixed: 'a { transform: color(rgb(0 ,0 ,0) lightness(50%)); }',
- description: 'CRLF',
- message: messages.rejectedAfterMultiLine(),
- line: 1,
- column: 31,
- },
- {
- code: 'a { transform: color(lightness(50%) rgb(0 ,\n 0 ,0)); }',
- fixed: 'a { transform: color(lightness(50%) rgb(0 ,0 ,0)); }',
- message: messages.rejectedAfterMultiLine(),
- line: 1,
- column: 43,
- },
- {
- code: 'a { transform: color(rgb(0\n,0 ,\n0) lightness(50%)); }',
- fixed: 'a { transform: color(rgb(0\n,0 ,0) lightness(50%)); }',
- message: messages.rejectedAfterMultiLine(),
- line: 2,
- column: 4,
- },
- {
- code: 'a { transform: color(lightness(50%) rgb(0 ,\n 0\n,0)); }',
- fixed: 'a { transform: color(lightness(50%) rgb(0 ,0\n,0)); }',
- message: messages.rejectedAfterMultiLine(),
- line: 1,
- column: 43,
- },
- {
- code: 'a { background: linear-gradient(45deg\n,rgba(0,0 , 0, 1), red); }',
- fixed: 'a { background: linear-gradient(45deg\n,rgba(0,0 , 0, 1),red); }',
- message: messages.rejectedAfterMultiLine(),
- line: 2,
- column: 18,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['never-multi-line'],
- customSyntax: 'postcss-scss',
-
- accept: [
- {
- code: '$map: (key: value,\nkey2: value2)',
- description: 'sass map',
- },
- {
- code: `
- a {
- transform: translate(1px, 1px); // line comment
- }
- `,
- description: 'eol comments',
- },
- ],
-});
diff --git a/lib/rules/function-comma-newline-after/index.js b/lib/rules/function-comma-newline-after/index.js
deleted file mode 100644
index 1852dc22c4..0000000000
--- a/lib/rules/function-comma-newline-after/index.js
+++ /dev/null
@@ -1,60 +0,0 @@
-'use strict';
-
-const fixer = require('../functionCommaSpaceFix');
-const functionCommaSpaceChecker = require('../functionCommaSpaceChecker');
-const ruleMessages = require('../../utils/ruleMessages');
-const validateOptions = require('../../utils/validateOptions');
-const whitespaceChecker = require('../../utils/whitespaceChecker');
-
-const ruleName = 'function-comma-newline-after';
-
-const messages = ruleMessages(ruleName, {
- expectedAfter: () => 'Expected newline after ","',
- expectedAfterMultiLine: () => 'Expected newline after "," in a multi-line function',
- rejectedAfterMultiLine: () => 'Unexpected whitespace after "," in a multi-line function',
-});
-
-const meta = {
- url: 'https://stylelint.io/user-guide/rules/function-comma-newline-after',
- fixable: true,
- deprecated: true,
-};
-
-/** @type {import('stylelint').Rule} */
-const rule = (primary, _secondaryOptions, context) => {
- const checker = whitespaceChecker('newline', primary, messages);
-
- return (root, result) => {
- const validOptions = validateOptions(result, ruleName, {
- actual: primary,
- possible: ['always', 'always-multi-line', 'never-multi-line'],
- });
-
- if (!validOptions) {
- return;
- }
-
- functionCommaSpaceChecker({
- root,
- result,
- locationChecker: checker.afterOneOnly,
- checkedRuleName: ruleName,
- fix: context.fix
- ? (div, index, nodes) =>
- fixer({
- div,
- index,
- nodes,
- expectation: primary,
- position: 'after',
- symb: context.newline || '',
- })
- : null,
- });
- };
-};
-
-rule.ruleName = ruleName;
-rule.messages = messages;
-rule.meta = meta;
-module.exports = rule;
diff --git a/lib/rules/function-comma-newline-before/README.md b/lib/rules/function-comma-newline-before/README.md
deleted file mode 100644
index 091b274065..0000000000
--- a/lib/rules/function-comma-newline-before/README.md
+++ /dev/null
@@ -1,131 +0,0 @@
-# function-comma-newline-before
-
-> **Warning** This rule is deprecated and will be removed in the future. See [the migration guide](../../../docs/migration-guide/to-15.md).
-
-Require a newline or disallow whitespace before the commas of functions.
-
-
-```css
- a { transform: translate(1
- , 1) }
-/** ↑
- * This comma */
-```
-
-The [`fix` option](../../../docs/user-guide/options.md#fix) can automatically fix all of the problems reported by this rule.
-
-## Options
-
-`string`: `"always"|"always-multi-line"|"never-multi-line"`
-
-### `"always"`
-
-There _must always_ be a newline before the commas.
-
-The following patterns are considered problems:
-
-
-```css
-a { transform: translate(1,1) }
-```
-
-
-```css
-a { transform: translate(1 ,1) }
-```
-
-
-```css
-a { transform: translate(1,
- 1) }
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a {
- transform: translate(1
- ,1)
-}
-```
-
-
-```css
-a {
- transform: translate(1
- , 1)
-}
-```
-
-### `"always-multi-line"`
-
-There _must always_ be a newline before the commas in multi-line functions.
-
-The following patterns are considered problems:
-
-
-```css
-a { transform: translate(1,
- 1) }
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { transform: translate(1,1) }
-```
-
-
-```css
-a { transform: translate(1 ,1) }
-```
-
-
-```css
-a {
- transform: translate(1
- ,1)
-}
-```
-
-
-```css
-a {
- transform: translate(1
- , 1)
-}
-```
-
-### `"never-multi-line"`
-
-There _must never_ be whitespace before the commas in multi-line functions.
-
-The following patterns are considered problems:
-
-
-```css
-a { transform: translate(1 ,
- 1) }
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { transform: translate(1 ,1) }
-```
-
-
-```css
-a { transform: translate(1 , 1) }
-```
-
-
-```css
-a {
- transform: translate(1,
- 1)
-}
-```
diff --git a/lib/rules/function-comma-newline-before/__tests__/index.js b/lib/rules/function-comma-newline-before/__tests__/index.js
deleted file mode 100644
index 107f8865fa..0000000000
--- a/lib/rules/function-comma-newline-before/__tests__/index.js
+++ /dev/null
@@ -1,320 +0,0 @@
-'use strict';
-
-const { messages, ruleName } = require('..');
-
-testRule({
- ruleName,
- config: ['always'],
- fix: true,
-
- accept: [
- {
- code: 'a::before { content: "func(foo ,bar ,baz)"; }',
- },
- {
- code: "a::before { background: url('func(foo,bar,baz)'); }",
- },
- {
- code: 'a { background-size: 0\n, 0\n, 0; }',
- },
- {
- code: 'a { transform: translate(1\n,1); }',
- },
- {
- code: 'a { transform: translate(1\r\n, 1); }',
- description: 'CRLF',
- },
- {
- code: 'a { transform: translate(1\n\n,1); }',
- },
- {
- code: 'a { transform: translate(1\r\n\r\n, 1); }',
- description: 'CRLF',
- },
- {
- code: 'a { transform: color(rgb(0\n\t, 0\n\t,0) lightness(50%)); }',
- },
- {
- code: 'a { transform: color(rgb(0\n , 0\n ,0) lightness(50%)); }',
- },
- {
- code: `
- a {
- transform: translate(
- 1px /* comment */
- ,1px
- );
- }
- `,
- description: 'eol comments',
- },
- ],
-
- reject: [
- {
- code: 'a { transform: translate(1,1); }',
- fixed: 'a { transform: translate(1\n,1); }',
- message: messages.expectedBefore(),
- line: 1,
- column: 27,
- },
- {
- code: 'a\r\n{ transform: translate(1,1); }',
- fixed: 'a\r\n{ transform: translate(1\r\n,1); }',
- description: 'CRLF',
- message: messages.expectedBefore(),
- line: 2,
- column: 25,
- },
- {
- code: 'a { transform: translate(1 ,1); }',
- fixed: 'a { transform: translate(1\n,1); }',
- message: messages.expectedBefore(),
- line: 1,
- column: 29,
- },
- {
- code: 'a { transform: translate(1 ,1); }',
- fixed: 'a { transform: translate(1\n,1); }',
- message: messages.expectedBefore(),
- line: 1,
- column: 28,
- },
- {
- code: 'a { transform: translate(1\t,1); }',
- fixed: 'a { transform: translate(1\n,1); }',
- message: messages.expectedBefore(),
- line: 1,
- column: 28,
- },
- {
- code: 'a { transform: color(rgb(0 , 0 \n,0) lightness(50%)); }',
- fixed: 'a { transform: color(rgb(0\n, 0 \n,0) lightness(50%)); }',
- message: messages.expectedBefore(),
- line: 1,
- column: 28,
- },
- {
- code: 'a { transform: color(lightness(50%) rgb(0\n, 0,0)); }',
- fixed: 'a { transform: color(lightness(50%) rgb(0\n, 0\n,0)); }',
- message: messages.expectedBefore(),
- line: 2,
- column: 4,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['always'],
- customSyntax: 'postcss-scss',
-
- accept: [
- {
- code: '$map: (key: value, key2: value2)',
- description: 'Sass map ignored',
- },
- {
- code: '$list: (value, value2)',
- description: 'Sass list ignored',
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['always-multi-line'],
- fix: true,
-
- accept: [
- {
- code: 'a::before { content: "func(foo ,bar ,baz)"; }',
- },
- {
- code: "a::before { background: url('func(foo,bar,baz)'); }",
- },
- {
- code: 'a { background-size: 0\n, 0\n, 0; }',
- },
- {
- code: 'a { transform: translate(1\n,1); }',
- },
- {
- code: 'a { transform: translate(1\r\n, 1); }',
- description: 'CRLF',
- },
- {
- code: 'a { transform: color(rgb(0\n\t, 0\n\t,0) lightness(50%)); }',
- },
- {
- code: 'a { transform: color(rgb(0\n , 0\n ,0) lightness(50%)); }',
- },
- {
- code: 'a { transform: translate(1,1); }',
- },
- {
- code: 'a { transform: translate(1 ,1); }',
- },
- {
- code: 'a { transform: translate(1 , 1); }',
- },
- {
- code: 'a { transform: translate(1\t,1); }',
- },
- {
- code: 'a { background: linear-gradient(45deg\n, rgba(0, 0, 0, 1)\n, red); }',
- },
- {
- code: `
- a {
- transform: translate(
- 1px /* comment */
- ,1px
- );
- }
- `,
- description: 'eol comments',
- },
- ],
-
- reject: [
- {
- code: 'a { transform: color(rgb(0\n, 0, 0) lightness(50%)); }',
- fixed: 'a { transform: color(rgb(0\n, 0\n, 0) lightness(50%)); }',
- message: messages.expectedBeforeMultiLine(),
- line: 2,
- column: 4,
- },
- {
- code: 'a { transform: color(rgb(0\r\n, 0, 0) lightness(50%)); }',
- fixed: 'a { transform: color(rgb(0\r\n, 0\r\n, 0) lightness(50%)); }',
- message: messages.expectedBeforeMultiLine(),
- line: 2,
- column: 4,
- },
- {
- code: 'a { transform: color(lightness(50%) rgb(0,0\n,0)); }',
- fixed: 'a { transform: color(lightness(50%) rgb(0\n,0\n,0)); }',
- message: messages.expectedBeforeMultiLine(),
- line: 1,
- column: 42,
- },
- {
- code: 'a { background: linear-gradient(45deg\n, rgba(0\n, 0, 0\n, 1)\n, red); }',
- fixed: 'a { background: linear-gradient(45deg\n, rgba(0\n, 0\n, 0\n, 1)\n, red); }',
- message: messages.expectedBeforeMultiLine(),
- line: 3,
- column: 4,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['always-multi-line'],
- customSyntax: 'postcss-scss',
-
- accept: [
- {
- code: '$map: (key: value,\nkey2: value2)',
- description: 'SCSS map',
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['never-multi-line'],
- fix: true,
-
- accept: [
- {
- code: 'a::before { content: "func(foo\n,bar\n,baz)"; }',
- },
- {
- code: "a::before { background: url('func(foo\n,bar,baz)'); }",
- },
- {
- code: 'a { transform: translate(1,1); }',
- },
- {
- code: 'a { transform: translate(1 ,1); }',
- },
- {
- code: 'a { transform: translate(1 , 1); }',
- },
- {
- code: 'a { transform: translate(1\t,1); }',
- },
- ],
-
- reject: [
- {
- code: 'a { transform: color(rgb(0,0\n,0) lightness(50%)); }',
- fixed: 'a { transform: color(rgb(0,0,0) lightness(50%)); }',
- message: messages.rejectedBeforeMultiLine(),
- line: 2,
- column: 1,
- },
- {
- code: 'a { transform: color(rgb(0,0\r\n,0) lightness(50%)); }',
- fixed: 'a { transform: color(rgb(0,0,0) lightness(50%)); }',
- message: messages.rejectedBeforeMultiLine(),
- line: 2,
- column: 1,
- },
- {
- code: 'a { transform: color(lightness(50%) rgb(0\n, 0, 0)); }',
- fixed: 'a { transform: color(lightness(50%) rgb(0, 0, 0)); }',
- message: messages.rejectedBeforeMultiLine(),
- line: 2,
- column: 1,
- },
- {
- code: 'a { transform: color(rgb(0\n,0,\n0) lightness(50%)); }',
- fixed: 'a { transform: color(rgb(0,0,\n0) lightness(50%)); }',
- message: messages.rejectedBeforeMultiLine(),
- line: 2,
- column: 1,
- },
- {
- code: 'a { transform: color(lightness(50%) rgb(0,\n 0\n,0)); }',
- fixed: 'a { transform: color(lightness(50%) rgb(0,\n 0,0)); }',
- message: messages.rejectedBeforeMultiLine(),
- line: 3,
- column: 1,
- },
- {
- code: `
- a {
- transform: translate(
- 1px /* comment */
- , 1px
- );
- }
- `,
- fixed: `
- a {
- transform: translate(
- 1px /* comment */, 1px
- );
- }
- `,
- description: 'eol comments',
- message: messages.rejectedBeforeMultiLine(),
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['never-multi-line'],
- customSyntax: 'postcss-scss',
-
- accept: [
- {
- code: '$map: (key: value\n,key2: value2)',
- description: 'SCSS map',
- },
- ],
-});
diff --git a/lib/rules/function-comma-newline-before/index.js b/lib/rules/function-comma-newline-before/index.js
deleted file mode 100644
index a94d55bfd3..0000000000
--- a/lib/rules/function-comma-newline-before/index.js
+++ /dev/null
@@ -1,60 +0,0 @@
-'use strict';
-
-const fixer = require('../functionCommaSpaceFix');
-const functionCommaSpaceChecker = require('../functionCommaSpaceChecker');
-const ruleMessages = require('../../utils/ruleMessages');
-const validateOptions = require('../../utils/validateOptions');
-const whitespaceChecker = require('../../utils/whitespaceChecker');
-
-const ruleName = 'function-comma-newline-before';
-
-const messages = ruleMessages(ruleName, {
- expectedBefore: () => 'Expected newline before ","',
- expectedBeforeMultiLine: () => 'Expected newline before "," in a multi-line function',
- rejectedBeforeMultiLine: () => 'Unexpected whitespace before "," in a multi-line function',
-});
-
-const meta = {
- url: 'https://stylelint.io/user-guide/rules/function-comma-newline-before',
- fixable: true,
- deprecated: true,
-};
-
-/** @type {import('stylelint').Rule} */
-const rule = (primary, _secondaryOptions, context) => {
- const checker = whitespaceChecker('newline', primary, messages);
-
- return (root, result) => {
- const validOptions = validateOptions(result, ruleName, {
- actual: primary,
- possible: ['always', 'always-multi-line', 'never-multi-line'],
- });
-
- if (!validOptions) {
- return;
- }
-
- functionCommaSpaceChecker({
- root,
- result,
- locationChecker: checker.beforeAllowingIndentation,
- checkedRuleName: ruleName,
- fix: context.fix
- ? (div, index, nodes) =>
- fixer({
- div,
- index,
- nodes,
- expectation: primary,
- position: 'before',
- symb: context.newline || '',
- })
- : null,
- });
- };
-};
-
-rule.ruleName = ruleName;
-rule.messages = messages;
-rule.meta = meta;
-module.exports = rule;
diff --git a/lib/rules/function-comma-space-after/README.md b/lib/rules/function-comma-space-after/README.md
deleted file mode 100644
index 5f0998fe5d..0000000000
--- a/lib/rules/function-comma-space-after/README.md
+++ /dev/null
@@ -1,146 +0,0 @@
-# function-comma-space-after
-
-> **Warning** This rule is deprecated and will be removed in the future. See [the migration guide](../../../docs/migration-guide/to-15.md).
-
-Require a single space or disallow whitespace after the commas of functions.
-
-
-```css
-a { transform: translate(1, 1) }
-/** ↑
- * The space after this comma */
-```
-
-The [`fix` option](../../../docs/user-guide/options.md#fix) can automatically fix all of the problems reported by this rule.
-
-## Options
-
-`string`: `"always"|"never"|"always-single-line"|"never-single-line"`
-
-### `"always"`
-
-There _must always_ be a single space after the commas.
-
-The following patterns are considered problems:
-
-
-```css
-a { transform: translate(1,1) }
-```
-
-
-```css
-a { transform: translate(1 ,1) }
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { transform: translate(1, 1) }
-```
-
-
-```css
-a { transform: translate(1 , 1) }
-```
-
-### `"never"`
-
-There _must never_ be whitespace after the commas.
-
-The following patterns are considered problems:
-
-
-```css
-a { transform: translate(1, 1) }
-```
-
-
-```css
-a { transform: translate(1 , 1) }
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { transform: translate(1,1) }
-```
-
-
-```css
-a { transform: translate(1 ,1) }
-```
-
-### `"always-single-line"`
-
-There _must always_ be a single space after the commas in single-line functions.
-
-The following patterns are considered problems:
-
-
-```css
-a { transform: translate(1,1) }
-```
-
-
-```css
-a { transform: translate(1 ,1) }
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { transform: translate(1, 1) }
-```
-
-
-```css
-a { transform: translate(1 , 1) }
-```
-
-
-```css
-a {
- transform: translate(1
- ,1)
-}
-```
-
-### `"never-single-line"`
-
-There _must never_ be whitespace after the commas in single-line functions.
-
-The following patterns are considered problems:
-
-
-```css
-a { transform: translate(1, 1) }
-```
-
-
-```css
-a { transform: translate(1 , 1) }
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { transform: translate(1,1) }
-```
-
-
-```css
-a { transform: translate(1 ,1) }
-```
-
-
-```css
-a {
- transform: translate(1
- , 1)
-}
-```
diff --git a/lib/rules/function-comma-space-after/__tests__/index.js b/lib/rules/function-comma-space-after/__tests__/index.js
deleted file mode 100644
index 9f5af35546..0000000000
--- a/lib/rules/function-comma-space-after/__tests__/index.js
+++ /dev/null
@@ -1,480 +0,0 @@
-'use strict';
-
-const { messages, ruleName } = require('..');
-
-testRule({
- ruleName,
- config: ['always'],
- fix: true,
-
- accept: [
- {
- code: 'a::before { content: "func(foo,bar,baz)"; }',
- },
- {
- code: "a::before { background: url('func(foo,bar,baz)'); }",
- },
- {
- code: 'a { background-size: 0,0,0; }',
- },
- {
- code: 'a { transform: translate(1 , 1); }',
- },
- {
- code: 'a { transform: translate(1, 1); }',
- },
- {
- code: 'a { transform: color(rgb(0 , 0, 0) lightness(50%)); }',
- },
- {
- code: 'a { background: url(data:image/svg+xml;charset=utf8,%3Csvg%20xmlns); }',
- description: 'data URI with spaceless comma',
- },
- {
- code: 'a { transform: translate(1, /* comment */1); }',
- description: 'comments',
- },
- ],
-
- reject: [
- {
- code: 'a { transform: translate(1,1); }',
- fixed: 'a { transform: translate(1, 1); }',
- message: messages.expectedAfter(),
- line: 1,
- column: 27,
- },
- {
- code: 'a { transform: translate(1, 1); }',
- fixed: 'a { transform: translate(1, 1); }',
- message: messages.expectedAfter(),
- line: 1,
- column: 27,
- },
- {
- code: 'a { transform: translate(1,\n1); }',
- fixed: 'a { transform: translate(1, 1); }',
- message: messages.expectedAfter(),
- line: 1,
- column: 27,
- },
- {
- code: 'a { transform: translate(1,\r\n1); }',
- fixed: 'a { transform: translate(1, 1); }',
- description: 'CRLF',
- message: messages.expectedAfter(),
- line: 1,
- column: 27,
- },
- {
- code: 'a { transform: translate(1,\t1); }',
- fixed: 'a { transform: translate(1, 1); }',
- message: messages.expectedAfter(),
- line: 1,
- column: 27,
- },
- {
- code: 'a { transform: color(rgb(0 , 0 ,0) lightness(50%)); }',
- fixed: 'a { transform: color(rgb(0 , 0 , 0) lightness(50%)); }',
- message: messages.expectedAfter(),
- line: 1,
- column: 32,
- },
- {
- code: 'a { transform: color(lightness(50%) rgb(0 , 0 ,0)); }',
- fixed: 'a { transform: color(lightness(50%) rgb(0 , 0 , 0)); }',
- message: messages.expectedAfter(),
- line: 1,
- column: 47,
- },
- {
- code: 'a { transform: translate(1,/* comment */1); }',
- fixed: 'a { transform: translate(1, /* comment */1); }',
- description: 'comments',
- message: messages.expectedAfter(),
- },
- {
- code: 'a { color: rgba(0,0,0,0); }',
- fixed: 'a { color: rgba(0, 0, 0, 0); }',
- warnings: [
- {
- message: messages.expectedAfter(),
- line: 1,
- column: 18,
- },
- {
- message: messages.expectedAfter(),
- line: 1,
- column: 20,
- },
- {
- message: messages.expectedAfter(),
- line: 1,
- column: 22,
- },
- ],
- },
- {
- code: 'a { background: linear-gradient(45deg,rgba(0,0,0,1),red); }',
- fixed: 'a { background: linear-gradient(45deg, rgba(0, 0, 0, 1), red); }',
- warnings: [
- {
- message: messages.expectedAfter(),
- line: 1,
- column: 38,
- },
- {
- message: messages.expectedAfter(),
- line: 1,
- column: 52,
- },
- {
- message: messages.expectedAfter(),
- line: 1,
- column: 45,
- },
- {
- message: messages.expectedAfter(),
- line: 1,
- column: 47,
- },
- {
- message: messages.expectedAfter(),
- line: 1,
- column: 49,
- },
- ],
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['always'],
- customSyntax: 'postcss-scss',
- fix: true,
-
- accept: [
- {
- code: '$map: (key: value,key2: value2)',
- description: 'Sass map ignored',
- },
- {
- code: '$list: (value,value2)',
- description: 'Sass list ignored',
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['never'],
- fix: true,
-
- accept: [
- {
- code: 'a::before { content: "func(foo, bar, baz)"; }',
- },
- {
- code: "a::before { background: url('func(foo, bar, baz)'); }",
- },
- {
- code: 'a { background-size: 0, 0, 0; }',
- },
- {
- code: 'a { transform: translate(1 ,1); }',
- },
- {
- code: 'a { transform: translate(1,1); }',
- },
- {
- code: 'a { transform: color(rgb(0 ,0,0) lightness(50%)); }',
- },
- {
- code: 'a { transform: translate(1,/* comment */1); }',
- description: 'comments',
- },
- ],
-
- reject: [
- {
- code: 'a { transform: translate(1, 1); }',
- fixed: 'a { transform: translate(1,1); }',
- message: messages.rejectedAfter(),
- line: 1,
- column: 27,
- },
- {
- code: 'a { transform: translate(1, 1); }',
- fixed: 'a { transform: translate(1,1); }',
- message: messages.rejectedAfter(),
- line: 1,
- column: 27,
- },
- {
- code: 'a { transform: translate(1,\n1); }',
- fixed: 'a { transform: translate(1,1); }',
- message: messages.rejectedAfter(),
- line: 1,
- column: 27,
- },
- {
- code: 'a { transform: translate(1,\r\n1); }',
- fixed: 'a { transform: translate(1,1); }',
- description: 'CRLF',
- message: messages.rejectedAfter(),
- line: 1,
- column: 27,
- },
- {
- code: 'a { transform: translate(1,\t1); }',
- fixed: 'a { transform: translate(1,1); }',
- message: messages.rejectedAfter(),
- line: 1,
- column: 27,
- },
- {
- code: 'a { transform: color(rgb(0 , 0 ,0) lightness(50%)); }',
- fixed: 'a { transform: color(rgb(0 ,0 ,0) lightness(50%)); }',
- message: messages.rejectedAfter(),
- line: 1,
- column: 28,
- },
- {
- code: 'a { transform: lightness(50%) color(rgb(0 , 0 ,0) ); }',
- fixed: 'a { transform: lightness(50%) color(rgb(0 ,0 ,0) ); }',
- message: messages.rejectedAfter(),
- line: 1,
- column: 43,
- },
- {
- code: 'a { transform: translate(1, /* comment */1); }',
- fixed: 'a { transform: translate(1,/* comment */1); }',
- description: 'comments',
- message: messages.rejectedAfter(),
- },
- {
- code: 'a { transform: translate(1, /* comment */ 1); }',
- fixed: 'a { transform: translate(1,/* comment */1); }',
- description: 'comments',
- message: messages.rejectedAfter(),
- },
- {
- code: 'a { transform: translate(1, /* 1 */\n/* 2 */ /* 3 */ 1); }',
- fixed: 'a { transform: translate(1,/* 1 *//* 2 *//* 3 */1); }',
- description: 'comments',
- message: messages.rejectedAfter(),
- },
- {
- code: 'a { background: linear-gradient(45deg , rgba(0 , 0 , 0 , 1) , red); }',
- fixed: 'a { background: linear-gradient(45deg ,rgba(0 ,0 ,0 ,1) ,red); }',
- warnings: [
- {
- message: messages.rejectedAfter(),
- line: 1,
- column: 39,
- },
- {
- message: messages.rejectedAfter(),
- line: 1,
- column: 61,
- },
- {
- message: messages.rejectedAfter(),
- line: 1,
- column: 48,
- },
- {
- message: messages.rejectedAfter(),
- line: 1,
- column: 52,
- },
- {
- message: messages.rejectedAfter(),
- line: 1,
- column: 56,
- },
- ],
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['never'],
- customSyntax: 'postcss-scss',
-
- accept: [
- {
- code: '$map: (key: value, key2: value2)',
- description: 'SCSS map',
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['always-single-line'],
- fix: true,
-
- accept: [
- {
- code: 'a::before { content: "func(foo,bar,baz)"; }',
- },
- {
- code: "a::before { background: url('func(foo,bar,baz)'); }",
- },
- {
- code: 'a { background-size: 0,0,0; }',
- },
- {
- code: 'a { transform: translate(1 , 1); }',
- },
- {
- code: 'a { transform: translate(1, 1); }',
- },
- {
- code: 'a { transform: color(rgb(0 , 0, 0) lightness(50%)); }',
- },
- {
- code: 'a { transform: translate(1,\n1); }',
- },
- {
- code: 'a { transform: translate(1\n,1); }',
- },
- {
- code: 'a { transform: translate(1,\r\n1); }',
- description: 'CRLF',
- },
- {
- code: 'a { color: rgba(0,0\n,0); }',
- description: 'CRLF',
- },
- {
- code: 'a { color: rgba(0\n,0,0); }',
- description: 'CRLF',
- },
- {
- code: 'a { background: linear-gradient(45deg\n,rgba(0, 0, 0, 1)\n,red); }',
- },
- ],
-
- reject: [
- {
- code: 'a { transform: color(rgb(0 , 0 ,0) lightness(50%)); }',
- fixed: 'a { transform: color(rgb(0 , 0 , 0) lightness(50%)); }',
- message: messages.expectedAfterSingleLine(),
- line: 1,
- column: 32,
- },
- {
- code: 'a { transform: color(lightness(50%) rgb(0 , 0 ,0)); }',
- fixed: 'a { transform: color(lightness(50%) rgb(0 , 0 , 0)); }',
- message: messages.expectedAfterSingleLine(),
- line: 1,
- column: 47,
- },
- {
- code: 'a { background: linear-gradient(45deg\n,rgba(0, 0,0, 1),red); }',
- fixed: 'a { background: linear-gradient(45deg\n,rgba(0, 0, 0, 1),red); }',
- message: messages.expectedAfterSingleLine(),
- line: 2,
- column: 11,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['always-single-line'],
- customSyntax: 'postcss-scss',
-
- accept: [
- {
- code: '$map: (key: value,key2: value2)',
- description: 'SCSS map',
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['never-single-line'],
- fix: true,
-
- accept: [
- {
- code: 'a::before { content: "func(foo, bar, baz)"; }',
- },
- {
- code: "a::before { background: url('func(foo, bar, baz)'); }",
- },
- {
- code: 'a { background-size: 0, 0, 0; }',
- },
- {
- code: 'a { transform: translate(1 ,1); }',
- },
- {
- code: 'a { transform: translate(1,1); }',
- },
- {
- code: 'a { transform: color(rgb(0 ,0,0) lightness(50%)); }',
- },
- {
- code: 'a { transform: translate(1,\n1); }',
- },
- {
- code: 'a { transform: translate(1\n, 1); }',
- },
- {
- code: 'a { transform: translate(1\r\n, 1); }',
- description: 'CRLF',
- },
- {
- code: 'a { color: rgba(0, 0\n, 0); }',
- description: 'CRLF',
- },
- {
- code: 'a { color: rgba(0\n, 0, 0); }',
- description: 'CRLF',
- },
- ],
-
- reject: [
- {
- code: 'a { transform: color(rgb(0 , 0 ,0) lightness(50%)); }',
- fixed: 'a { transform: color(rgb(0 ,0 ,0) lightness(50%)); }',
- message: messages.rejectedAfterSingleLine(),
- line: 1,
- column: 28,
- },
- {
- code: 'a { transform: lightness(50%) color(rgb(0 , 0 ,0) ); }',
- fixed: 'a { transform: lightness(50%) color(rgb(0 ,0 ,0) ); }',
- message: messages.rejectedAfterSingleLine(),
- line: 1,
- column: 43,
- },
- {
- code: 'a { transform: lightness(50%)\ncolor(rgb(0 , 0 ,0) ); }',
- fixed: 'a { transform: lightness(50%)\ncolor(rgb(0 ,0 ,0) ); }',
- message: messages.rejectedAfterSingleLine(),
- line: 2,
- column: 13,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['never-single-line'],
- customSyntax: 'postcss-scss',
-
- accept: [
- {
- code: '$map: (key: value, key2: value2)',
- description: 'SCSS map',
- },
- ],
-});
diff --git a/lib/rules/function-comma-space-after/index.js b/lib/rules/function-comma-space-after/index.js
deleted file mode 100644
index 3f4d4122cc..0000000000
--- a/lib/rules/function-comma-space-after/index.js
+++ /dev/null
@@ -1,61 +0,0 @@
-'use strict';
-
-const fixer = require('../functionCommaSpaceFix');
-const functionCommaSpaceChecker = require('../functionCommaSpaceChecker');
-const ruleMessages = require('../../utils/ruleMessages');
-const validateOptions = require('../../utils/validateOptions');
-const whitespaceChecker = require('../../utils/whitespaceChecker');
-
-const ruleName = 'function-comma-space-after';
-
-const messages = ruleMessages(ruleName, {
- expectedAfter: () => 'Expected single space after ","',
- rejectedAfter: () => 'Unexpected whitespace after ","',
- expectedAfterSingleLine: () => 'Expected single space after "," in a single-line function',
- rejectedAfterSingleLine: () => 'Unexpected whitespace after "," in a single-line function',
-});
-
-const meta = {
- url: 'https://stylelint.io/user-guide/rules/function-comma-space-after',
- fixable: true,
- deprecated: true,
-};
-
-/** @type {import('stylelint').Rule} */
-const rule = (primary, _secondaryOptions, context) => {
- const checker = whitespaceChecker('space', primary, messages);
-
- return (root, result) => {
- const validOptions = validateOptions(result, ruleName, {
- actual: primary,
- possible: ['always', 'never', 'always-single-line', 'never-single-line'],
- });
-
- if (!validOptions) {
- return;
- }
-
- functionCommaSpaceChecker({
- root,
- result,
- locationChecker: checker.after,
- checkedRuleName: ruleName,
- fix: context.fix
- ? (div, index, nodes) =>
- fixer({
- div,
- index,
- nodes,
- expectation: primary,
- position: 'after',
- symb: ' ',
- })
- : null,
- });
- };
-};
-
-rule.ruleName = ruleName;
-rule.messages = messages;
-rule.meta = meta;
-module.exports = rule;
diff --git a/lib/rules/function-comma-space-before/README.md b/lib/rules/function-comma-space-before/README.md
deleted file mode 100644
index 91c8e9d3c9..0000000000
--- a/lib/rules/function-comma-space-before/README.md
+++ /dev/null
@@ -1,146 +0,0 @@
-# function-comma-space-before
-
-> **Warning** This rule is deprecated and will be removed in the future. See [the migration guide](../../../docs/migration-guide/to-15.md).
-
-Require a single space or disallow whitespace before the commas of functions.
-
-
-```css
-a { transform: translate(1 ,1) }
-/** ↑
- * The space before this comma */
-```
-
-The [`fix` option](../../../docs/user-guide/options.md#fix) can automatically fix all of the problems reported by this rule.
-
-## Options
-
-`string`: `"always"|"never"|"always-single-line"|"never-single-line"`
-
-### `"always"`
-
-There _must always_ be a single space before the commas.
-
-The following patterns are considered problems:
-
-
-```css
-a { transform: translate(1,1) }
-```
-
-
-```css
-a { transform: translate(1, 1) }
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { transform: translate(1 ,1) }
-```
-
-
-```css
-a { transform: translate(1 , 1) }
-```
-
-### `"never"`
-
-There _must never_ be whitespace before the commas.
-
-The following patterns are considered problems:
-
-
-```css
-a { transform: translate(1 ,1) }
-```
-
-
-```css
-a { transform: translate(1 , 1) }
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { transform: translate(1,1) }
-```
-
-
-```css
-a { transform: translate(1, 1) }
-```
-
-### `"always-single-line"`
-
-There _must always_ be a single space before the commas in single-line functions.
-
-The following patterns are considered problems:
-
-
-```css
-a { transform: translate(1,1) }
-```
-
-
-```css
-a { transform: translate(1, 1) }
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { transform: translate(1 ,1) }
-```
-
-
-```css
-a { transform: translate(1 , 1) }
-```
-
-
-```css
-a {
- transform: translate(1,
- 1)
-}
-```
-
-### `"never-single-line"`
-
-There _must never_ be whitespace before the commas in single-line functions.
-
-The following patterns are considered problems:
-
-
-```css
-a { transform: translate(1 ,1) }
-```
-
-
-```css
-a { transform: translate(1 , 1) }
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { transform: translate(1,1) }
-```
-
-
-```css
-a { transform: translate(1, 1) }
-```
-
-
-```css
-a {
- transform: translate(1 ,
- 1)
-}
-```
diff --git a/lib/rules/function-comma-space-before/__tests__/index.js b/lib/rules/function-comma-space-before/__tests__/index.js
deleted file mode 100644
index 14f4987e9c..0000000000
--- a/lib/rules/function-comma-space-before/__tests__/index.js
+++ /dev/null
@@ -1,386 +0,0 @@
-'use strict';
-
-const { messages, ruleName } = require('..');
-
-testRule({
- ruleName,
- config: ['always'],
- fix: true,
-
- accept: [
- {
- code: 'a::before { content: "func(foo,bar,baz)"; }',
- },
- {
- code: "a::before { background: url('func(foo,bar,baz)'); }",
- },
- {
- code: 'a { background-size: 0, 0, 0; }',
- },
- {
- code: 'a { transform: translate(1 , 1); }',
- },
- {
- code: 'a { transform: translate(1 ,1); }',
- },
- {
- code: 'a { transform: color(rgb(0 , 0 ,0) lightness(50%)); }',
- },
- {
- code: 'a { background: url(data:image/svg+xml;charset=utf8,%3Csvg%20xmlns); }',
- description: 'data URI with spaceless comma',
- },
- ],
-
- reject: [
- {
- code: 'a { transform: translate(1, 1); }',
- fixed: 'a { transform: translate(1 , 1); }',
- message: messages.expectedBefore(),
- line: 1,
- column: 27,
- },
- {
- code: 'a { transform: translate(1 , 1); }',
- fixed: 'a { transform: translate(1 , 1); }',
- message: messages.expectedBefore(),
- line: 1,
- column: 29,
- },
- {
- code: 'a { transform: translate(1\n, 1); }',
- fixed: 'a { transform: translate(1 , 1); }',
- message: messages.expectedBefore(),
- line: 2,
- column: 1,
- },
- {
- code: 'a { transform: translate(1\r\n, 1); }',
- fixed: 'a { transform: translate(1 , 1); }',
- description: 'CRLF',
- message: messages.expectedBefore(),
- line: 2,
- column: 1,
- },
- {
- code: 'a { transform: translate(1\t, 1); }',
- fixed: 'a { transform: translate(1 , 1); }',
- message: messages.expectedBefore(),
- line: 1,
- column: 28,
- },
- {
- code: 'a { transform: color(rgb(0 , 0, 0) lightness(50%)); }',
- fixed: 'a { transform: color(rgb(0 , 0 , 0) lightness(50%)); }',
- message: messages.expectedBefore(),
- line: 1,
- column: 31,
- },
- {
- code: 'a { transform: color(lightness(50%) rgb(0 , 0, 0)); }',
- fixed: 'a { transform: color(lightness(50%) rgb(0 , 0 , 0)); }',
- message: messages.expectedBefore(),
- line: 1,
- column: 46,
- },
- {
- code: `
- a {
- transform: translate(
- 1px /* comment */
- ,1px
- );
- }
- `,
- fixed: `
- a {
- transform: translate(
- 1px /* comment */ ,1px
- );
- }
- `,
- description: 'eol comments',
- message: messages.expectedBefore(),
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['always'],
- customSyntax: 'postcss-scss',
-
- accept: [
- {
- code: '$map: (key: value,key2: value2)',
- description: 'Sass map ignored',
- },
- {
- code: '$list: (value, value2)',
- description: 'Sass list ignored',
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['never'],
- fix: true,
-
- accept: [
- {
- code: 'a::before { content: "func(foo ,bar ,baz)"; }',
- },
- {
- code: "a::before { background: url('func(foo ,bar ,baz)'); }",
- },
- {
- code: 'a { background-size: 0 , 0 , 0; }',
- },
- {
- code: 'a { transform: translate(1, 1); }',
- },
- {
- code: 'a { transform: translate(1,1); }',
- },
- {
- code: 'a { transform: color(rgb(0, 0,0) lightness(50%)); }',
- },
- ],
-
- reject: [
- {
- code: 'a { transform: translate(1 , 1); }',
- fixed: 'a { transform: translate(1, 1); }',
- message: messages.rejectedBefore(),
- line: 1,
- column: 28,
- },
- {
- code: 'a { transform: translate(1 , 1); }',
- fixed: 'a { transform: translate(1, 1); }',
- message: messages.rejectedBefore(),
- line: 1,
- column: 29,
- },
- {
- code: 'a { transform: translate(1\n, 1); }',
- fixed: 'a { transform: translate(1, 1); }',
- message: messages.rejectedBefore(),
- line: 2,
- column: 1,
- },
- {
- code: 'a { transform: translate(1\r\n, 1); }',
- fixed: 'a { transform: translate(1, 1); }',
- description: 'CRLF',
- message: messages.rejectedBefore(),
- line: 2,
- column: 1,
- },
- {
- code: 'a { transform: translate(1\t, 1); }',
- fixed: 'a { transform: translate(1, 1); }',
- message: messages.rejectedBefore(),
- line: 1,
- column: 28,
- },
- {
- code: 'a { transform: color(rgb(0, 0 , 0) lightness(50%)); }',
- fixed: 'a { transform: color(rgb(0, 0, 0) lightness(50%)); }',
- message: messages.rejectedBefore(),
- line: 1,
- column: 31,
- },
- {
- code: 'a { transform: color(lightness(50%) rgb(0, 0 , 0)); }',
- fixed: 'a { transform: color(lightness(50%) rgb(0, 0, 0)); }',
- message: messages.rejectedBefore(),
- line: 1,
- column: 46,
- },
- {
- code: 'a { transform: translate(1 /*comment*/ , 1); }',
- fixed: 'a { transform: translate(1 /*comment*/, 1); }',
- message: messages.rejectedBefore(),
- line: 1,
- column: 40,
- },
- {
- code: 'a { transform: translate(1 /*c*/ /*c*/ , 1); }',
- fixed: 'a { transform: translate(1 /*c*/ /*c*/, 1); }',
- message: messages.rejectedBefore(),
- line: 1,
- column: 40,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['never'],
- customSyntax: 'postcss-scss',
-
- accept: [
- {
- code: '$map: (key: value ,key2: value2)',
- description: 'SCSS map',
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['always-single-line'],
- fix: true,
-
- accept: [
- {
- code: 'a::before { content: "func(foo,bar,baz)"; }',
- },
- {
- code: "a::before { background: url('func(foo,bar,baz)'); }",
- },
- {
- code: 'a { background-size: 0, 0, 0; }',
- },
- {
- code: 'a { transform: translate(1 , 1); }',
- },
- {
- code: 'a { transform: translate(1 ,1); }',
- },
- {
- code: 'a { transform: color(rgb(0 , 0 ,0) lightness(50%)); }',
- },
- {
- code: 'a { transform: translate(1,\n1); }',
- },
- {
- code: 'a { transform: translate(1 ,\n1); }',
- },
- {
- code: 'a { transform: translate(1\t,\r\n1); }',
- description: 'CRLF',
- },
- {
- code: 'a { transform: translate(1\n, 1); }',
- },
- {
- code: 'a { transform: translate(1\n,\n1); }',
- },
- {
- code: 'a { background: linear-gradient(45deg,\nrgba(0 , 0 , 0 ,1)\n,red); }',
- },
- ],
-
- reject: [
- {
- code: 'a { transform: color(rgb(0 , 0, 0) lightness(50%)); }',
- fixed: 'a { transform: color(rgb(0 , 0 , 0) lightness(50%)); }',
- message: messages.expectedBeforeSingleLine(),
- line: 1,
- column: 31,
- },
- {
- code: 'a { transform: color(lightness(50%) rgb(0 , 0, 0)); }',
- fixed: 'a { transform: color(lightness(50%) rgb(0 , 0 , 0)); }',
- message: messages.expectedBeforeSingleLine(),
- line: 1,
- column: 46,
- },
- {
- code: 'a { background: linear-gradient(45deg,\nrgba(0 , 0,0 ,1),red); }',
- fixed: 'a { background: linear-gradient(45deg,\nrgba(0 , 0 ,0 ,1),red); }',
- message: messages.expectedBeforeSingleLine(),
- line: 2,
- column: 11,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['always-single-line'],
- customSyntax: 'postcss-scss',
-
- accept: [
- {
- code: '$map: (key: value,key2: value2)',
- description: 'SCSS map',
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['never-single-line'],
- fix: true,
-
- accept: [
- {
- code: 'a::before { content: "func(foo ,bar ,baz)"; }',
- },
- {
- code: "a::before { background: url('func(foo ,bar ,baz)'); }",
- },
- {
- code: 'a { background-size: 0 , 0 , 0; }',
- },
- {
- code: 'a { transform: translate(1, 1); }',
- },
- {
- code: 'a { transform: translate(1,1); }',
- },
- {
- code: 'a { transform: color(rgb(0, 0,0) lightness(50%)); }',
- },
- {
- code: 'a { transform: translate(1 ,\n1); }',
- },
- {
- code: 'a { transform: translate(1 ,\n1); }',
- },
- {
- code: 'a { transform: translate(1\t,\r\n1); }',
- description: 'CRLF',
- },
- {
- code: 'a { transform: translate(1\n, 1); }',
- },
- {
- code: 'a { transform: translate(1\n,\n1); }',
- },
- ],
-
- reject: [
- {
- code: 'a { transform: color(rgb(0, 0 , 0) lightness(50%)); }',
- fixed: 'a { transform: color(rgb(0, 0, 0) lightness(50%)); }',
- message: messages.rejectedBeforeSingleLine(),
- line: 1,
- column: 31,
- },
- {
- code: 'a { transform: color(lightness(50%) rgb(0, 0 , 0)); }',
- fixed: 'a { transform: color(lightness(50%) rgb(0, 0, 0)); }',
- message: messages.rejectedBeforeSingleLine(),
- line: 1,
- column: 46,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['never-single-line'],
- customSyntax: 'postcss-scss',
-
- accept: [
- {
- code: '$map: (key: value ,key2: value2)',
- description: 'SCSS map',
- },
- ],
-});
diff --git a/lib/rules/function-comma-space-before/index.js b/lib/rules/function-comma-space-before/index.js
deleted file mode 100644
index ca97bcc265..0000000000
--- a/lib/rules/function-comma-space-before/index.js
+++ /dev/null
@@ -1,61 +0,0 @@
-'use strict';
-
-const fixer = require('../functionCommaSpaceFix');
-const functionCommaSpaceChecker = require('../functionCommaSpaceChecker');
-const ruleMessages = require('../../utils/ruleMessages');
-const validateOptions = require('../../utils/validateOptions');
-const whitespaceChecker = require('../../utils/whitespaceChecker');
-
-const ruleName = 'function-comma-space-before';
-
-const messages = ruleMessages(ruleName, {
- expectedBefore: () => 'Expected single space before ","',
- rejectedBefore: () => 'Unexpected whitespace before ","',
- expectedBeforeSingleLine: () => 'Expected single space before "," in a single-line function',
- rejectedBeforeSingleLine: () => 'Unexpected whitespace before "," in a single-line function',
-});
-
-const meta = {
- url: 'https://stylelint.io/user-guide/rules/function-comma-space-before',
- fixable: true,
- deprecated: true,
-};
-
-/** @type {import('stylelint').Rule} */
-const rule = (primary, _secondaryOptions, context) => {
- const checker = whitespaceChecker('space', primary, messages);
-
- return (root, result) => {
- const validOptions = validateOptions(result, ruleName, {
- actual: primary,
- possible: ['always', 'never', 'always-single-line', 'never-single-line'],
- });
-
- if (!validOptions) {
- return;
- }
-
- functionCommaSpaceChecker({
- root,
- result,
- locationChecker: checker.before,
- checkedRuleName: ruleName,
- fix: context.fix
- ? (div, index, nodes) =>
- fixer({
- div,
- index,
- nodes,
- expectation: primary,
- position: 'before',
- symb: ' ',
- })
- : null,
- });
- };
-};
-
-rule.ruleName = ruleName;
-rule.messages = messages;
-rule.meta = meta;
-module.exports = rule;
diff --git a/lib/rules/function-max-empty-lines/README.md b/lib/rules/function-max-empty-lines/README.md
deleted file mode 100644
index 4b169c595b..0000000000
--- a/lib/rules/function-max-empty-lines/README.md
+++ /dev/null
@@ -1,80 +0,0 @@
-# function-max-empty-lines
-
-> **Warning** This rule is deprecated and will be removed in the future. See [the migration guide](../../../docs/migration-guide/to-15.md).
-
-Limit the number of adjacent empty lines within functions.
-
-
-```css
-a {
- transform:
- translate(
- /* ← */
- 1, /* ↑ */
- /* ← */
- 1 /* ↑ */
- /* ← */
- ); /* ↑ */
-} /* ↑ */
-/** ↑
- * These lines */
-```
-
-The [`fix` option](../../../docs/user-guide/options.md#fix) can automatically fix all of the problems reported by this rule.
-
-## Options
-
-`int`: Maximum number of adjacent empty lines allowed.
-
-For example, with `0`:
-
-The following patterns are considered problems:
-
-
-```css
-a {
- transform:
- translate(
-
- 1,
- 1
- );
-}
-```
-
-
-```css
-a {
- transform:
- translate(
- 1,
-
- 1
- );
-}
-```
-
-
-```css
-a {
- transform:
- translate(
- 1,
- 1
-
- );
-}
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a {
- transform:
- translate(
- 1,
- 1
- );
-}
-```
diff --git a/lib/rules/function-max-empty-lines/__tests__/index.js b/lib/rules/function-max-empty-lines/__tests__/index.js
deleted file mode 100644
index 441ce23334..0000000000
--- a/lib/rules/function-max-empty-lines/__tests__/index.js
+++ /dev/null
@@ -1,356 +0,0 @@
-'use strict';
-
-const { messages, ruleName } = require('..');
-
-testRule({
- ruleName,
- config: [0],
- fix: true,
-
- accept: [
- {
- code: 'a { transform: translate(1, 1); }',
- },
- {
- code: 'a { transform: translate(\n1\n,\n1\n); }',
- },
- {
- code: 'a { transform: translate(\r\n1\r\n,\r\n1\r\n); }',
- },
- {
- code: 'a { transform: translate\n\n(1, 1); }',
- },
- {
- code: 'a { transform: translate\r\n\r\n(1, 1); }',
- },
- {
- code: 'a { transform: translate(1, 1)\n\n; }',
- },
- {
- code: 'a { transform: translate(1, 1)\r\n\r\n; }',
- },
- {
- code: 'a { transform:\n\ntranslate(1, 1); }',
- },
- {
- code: 'a { transform:\r\n\r\ntranslate(1, 1); }',
- },
- {
- code: 'a { background: blah,\n\nfoo; }',
- },
- {
- code: 'a { background: blah,\r\n\r\nfoo; }',
- },
- {
- code: '$list: (value,\n\n\nvalue2)',
- description: 'Sass list ignored',
- },
- ],
-
- reject: [
- {
- code: 'a { transform: translate(/*c*/\n\n\n1,1); }',
- fixed: 'a { transform: translate(/*c*/\n1,1); }',
- message: messages.expected(0),
- line: 1,
- column: 15,
- },
- {
- code: 'a { transform: /*c*/translate(\n\n\n1,1); }',
- fixed: 'a { transform: /*c*/translate(\n1,1); }',
- message: messages.expected(0),
- line: 1,
- column: 20,
- },
- {
- code: 'a { transform: translate(\n\n1\n,\n1\n); }',
- fixed: 'a { transform: translate(\n1\n,\n1\n); }',
- message: messages.expected(0),
- line: 1,
- column: 15,
- },
- {
- code: 'a { transform: translate(\n\n1\n,\n1\n\n); }',
- fixed: 'a { transform: translate(\n1\n,\n1\n); }',
- message: messages.expected(0),
- line: 1,
- column: 15,
- },
- {
- code: 'a { transform: translate(\n\n1\n\n,\n1\n\n); }',
- fixed: 'a { transform: translate(\n1\n,\n1\n); }',
- message: messages.expected(0),
- line: 1,
- column: 15,
- },
- {
- code: 'a { transform: translate(\r\n\r\n1\r\n,\r\n1\r\n); }',
- fixed: 'a { transform: translate(\r\n1\r\n,\r\n1\r\n); }',
- message: messages.expected(0),
- line: 1,
- column: 15,
- },
- {
- code: 'a { transform: translate(\n1\n\n,\n1\n); }',
- fixed: 'a { transform: translate(\n1\n,\n1\n); }',
- message: messages.expected(0),
- line: 1,
- column: 15,
- },
- {
- code: 'a { transform: translate(\r\n1\r\n\r\n,\r\n1\r\n); }',
- fixed: 'a { transform: translate(\r\n1\r\n,\r\n1\r\n); }',
- message: messages.expected(0),
- line: 1,
- column: 15,
- },
- {
- code: 'a { transform: translate(\n1\n,\n\n1\n); }',
- fixed: 'a { transform: translate(\n1\n,\n1\n); }',
- message: messages.expected(0),
- line: 1,
- column: 15,
- },
- {
- code: 'a { transform: translate(\r\n1\r\n,\r\n\r\n1\r\n); }',
- fixed: 'a { transform: translate(\r\n1\r\n,\r\n1\r\n); }',
- message: messages.expected(0),
- line: 1,
- column: 15,
- },
- {
- code: 'a { transform: translate(\n1\n,\n1\n\n); }',
- fixed: 'a { transform: translate(\n1\n,\n1\n); }',
- message: messages.expected(0),
- line: 1,
- column: 15,
- },
- {
- code: 'a { transform: translate(\r\n1\r\n,\r\n1\r\n\r\n); }',
- fixed: 'a { transform: translate(\r\n1\r\n,\r\n1\r\n); }',
- message: messages.expected(0),
- line: 1,
- column: 15,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: [1],
- fix: true,
-
- accept: [
- {
- code: 'a { transform: translate(\n1\n,\n1\n); }',
- },
- {
- code: 'a { transform: translate(\r\n1\r\n,\r\n1\r\n); }',
- },
- {
- code: 'a { transform: translate(\n\n1\n,\n1\n); }',
- },
- {
- code: 'a { transform: translate(\r\n\r\n1\r\n,\r\n1\r\n); }',
- },
- {
- code: 'a { transform: translate(\n1\n\n,\n1\n); }',
- },
- {
- code: 'a { transform: translate(\r\n1\r\n\r\n,\r\n1\r\n); }',
- },
- {
- code: 'a { transform: translate(\n1\n,\n\n1\n); }',
- },
- {
- code: 'a { transform: translate(\r\n1\r\n,\r\n\r\n1\r\n); }',
- },
- {
- code: 'a { transform: translate(\n1\n,\n1\n\n); }',
- },
- {
- code: 'a { transform: translate(\r\n1\r\n,\r\n1\r\n\r\n); }',
- },
- ],
-
- reject: [
- {
- code: 'a { transform: translate(\n\n\n1\n,\n1\n); }',
- fixed: 'a { transform: translate(\n\n1\n,\n1\n); }',
- message: messages.expected(1),
- line: 1,
- column: 15,
- },
- {
- code: 'a { transform: translate(\r\n\r\n\r\n1\r\n,\r\n1\r\n); }',
- fixed: 'a { transform: translate(\r\n\r\n1\r\n,\r\n1\r\n); }',
- message: messages.expected(1),
- line: 1,
- column: 15,
- },
- {
- code: 'a { transform: translate(\n1\n\n\n,\n1\n); }',
- fixed: 'a { transform: translate(\n1\n\n,\n1\n); }',
- message: messages.expected(1),
- line: 1,
- column: 15,
- },
- {
- code: 'a { transform: translate(\r\n1\r\n\r\n\r\n,\r\n1\r\n); }',
- fixed: 'a { transform: translate(\r\n1\r\n\r\n,\r\n1\r\n); }',
- message: messages.expected(1),
- line: 1,
- column: 15,
- },
- {
- code: 'a { transform: translate(\n1\n,\n\n\n1\n); }',
- fixed: 'a { transform: translate(\n1\n,\n\n1\n); }',
- message: messages.expected(1),
- line: 1,
- column: 15,
- },
- {
- code: 'a { transform: translate(\r\n1\r\n,\r\n\r\n\r\n1\r\n); }',
- fixed: 'a { transform: translate(\r\n1\r\n,\r\n\r\n1\r\n); }',
- message: messages.expected(1),
- line: 1,
- column: 15,
- },
- {
- code: 'a { transform: translate(\n1\n,\n1\n\n\n); }',
- fixed: 'a { transform: translate(\n1\n,\n1\n\n); }',
- message: messages.expected(1),
- line: 1,
- column: 15,
- },
- {
- code: 'a { transform: translate(\r\n1\r\n,\r\n1\r\n\r\n\r\n); }',
- fixed: 'a { transform: translate(\r\n1\r\n,\r\n1\r\n\r\n); }',
- message: messages.expected(1),
- line: 1,
- column: 15,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: [2],
- fix: true,
-
- accept: [
- {
- code: 'a { transform: translate(\n1\n,\n1\n); }',
- },
- {
- code: 'a { transform: translate(\r\n1\r\n,\r\n1\r\n); }',
- },
- {
- code: 'a { transform: translate(\n\n1\n,\n1\n); }',
- },
- {
- code: 'a { transform: translate(\r\n\r\n1\r\n,\r\n1\r\n); }',
- },
- {
- code: 'a { transform: translate(\n1\n\n,\n1\n); }',
- },
- {
- code: 'a { transform: translate(\r\n1\r\n\r\n,\r\n1\r\n); }',
- },
- {
- code: 'a { transform: translate(\n1\n,\n\n1\n); }',
- },
- {
- code: 'a { transform: translate(\r\n1\r\n,\r\n\r\n1\r\n); }',
- },
- {
- code: 'a { transform: translate(\n1\n,\n1\n\n); }',
- },
- {
- code: 'a { transform: translate(\r\n1\r\n,\r\n1\r\n\r\n); }',
- },
- {
- code: 'a { transform: translate(\n\n\n1\n,\n1\n); }',
- },
- {
- code: 'a { transform: translate(\r\n\r\n\r\n1\r\n,\r\n1\r\n); }',
- },
- {
- code: 'a { transform: translate(\n1\n\n\n,\n1\n); }',
- },
- {
- code: 'a { transform: translate(\r\n1\r\n\r\n\r\n,\r\n1\r\n); }',
- },
- {
- code: 'a { transform: translate(\n1\n,\n\n\n1\n); }',
- },
- {
- code: 'a { transform: translate(\r\n1\r\n,\r\n\r\n\r\n1\r\n); }',
- },
- {
- code: 'a { transform: translate(\n1\n,\n1\n\n\n); }',
- },
- {
- code: 'a { transform: translate(\r\n1\r\n,\r\n1\r\n\r\n\r\n); }',
- },
- ],
-
- reject: [
- {
- code: 'a { transform: translate(\n\n\n\n1\n,\n1\n); }',
- fixed: 'a { transform: translate(\n\n\n1\n,\n1\n); }',
- message: messages.expected(2),
- line: 1,
- column: 15,
- },
- {
- code: 'a { transform: translate(\r\n\r\n\r\n\r\n1\r\n,\r\n1\r\n); }',
- fixed: 'a { transform: translate(\r\n\r\n\r\n1\r\n,\r\n1\r\n); }',
- message: messages.expected(2),
- line: 1,
- column: 15,
- },
- {
- code: 'a { transform: translate(\n1\n\n\n\n,\n1\n); }',
- fixed: 'a { transform: translate(\n1\n\n\n,\n1\n); }',
- message: messages.expected(2),
- line: 1,
- column: 15,
- },
- {
- code: 'a { transform: translate(\r\n1\r\n\r\n\r\n\r\n,\r\n1\r\n); }',
- fixed: 'a { transform: translate(\r\n1\r\n\r\n\r\n,\r\n1\r\n); }',
- message: messages.expected(2),
- line: 1,
- column: 15,
- },
- {
- code: 'a { transform: translate(\n1\n,\n\n\n\n1\n); }',
- fixed: 'a { transform: translate(\n1\n,\n\n\n1\n); }',
- message: messages.expected(2),
- line: 1,
- column: 15,
- },
- {
- code: 'a { transform: translate(\r\n1\r\n,\r\n\r\n\r\n\r\n1\r\n); }',
- fixed: 'a { transform: translate(\r\n1\r\n,\r\n\r\n\r\n1\r\n); }',
- message: messages.expected(2),
- line: 1,
- column: 15,
- },
- {
- code: 'a { transform: translate(\n1\n,\n1\n\n\n\n); }',
- fixed: 'a { transform: translate(\n1\n,\n1\n\n\n); }',
- message: messages.expected(2),
- line: 1,
- column: 15,
- },
- {
- code: 'a { transform: translate(\r\n1\r\n,\r\n1\r\n\r\n\r\n\r\n); }',
- fixed: 'a { transform: translate(\r\n1\r\n,\r\n1\r\n\r\n\r\n); }',
- message: messages.expected(2),
- line: 1,
- column: 15,
- },
- ],
-});
diff --git a/lib/rules/function-max-empty-lines/index.js b/lib/rules/function-max-empty-lines/index.js
deleted file mode 100644
index c20341375e..0000000000
--- a/lib/rules/function-max-empty-lines/index.js
+++ /dev/null
@@ -1,113 +0,0 @@
-'use strict';
-
-const getDeclarationValue = require('../../utils/getDeclarationValue');
-const report = require('../../utils/report');
-const ruleMessages = require('../../utils/ruleMessages');
-const setDeclarationValue = require('../../utils/setDeclarationValue');
-const validateOptions = require('../../utils/validateOptions');
-const valueParser = require('postcss-value-parser');
-const { isNumber } = require('../../utils/validateTypes');
-
-const ruleName = 'function-max-empty-lines';
-
-const messages = ruleMessages(ruleName, {
- expected: (max) => `Expected no more than ${max} empty ${max === 1 ? 'line' : 'lines'}`,
-});
-
-const meta = {
- url: 'https://stylelint.io/user-guide/rules/function-max-empty-lines',
- fixable: true,
- deprecated: true,
-};
-
-/**
- * @param {import('postcss').Declaration} decl
- */
-function placeIndexOnValueStart(decl) {
- if (decl.raws.between == null) throw new Error('`between` must be present');
-
- return decl.prop.length + decl.raws.between.length - 1;
-}
-
-/** @type {import('stylelint').Rule} */
-const rule = (primary, _secondaryOptions, context) => {
- const maxAdjacentNewlines = primary + 1;
-
- return (root, result) => {
- const validOptions = validateOptions(result, ruleName, {
- actual: primary,
- possible: isNumber,
- });
-
- if (!validOptions) {
- return;
- }
-
- const violatedCRLFNewLinesRegex = new RegExp(`(?:\r\n){${maxAdjacentNewlines + 1},}`);
- const violatedLFNewLinesRegex = new RegExp(`\n{${maxAdjacentNewlines + 1},}`);
- const allowedLFNewLinesString = context.fix ? '\n'.repeat(maxAdjacentNewlines) : '';
- const allowedCRLFNewLinesString = context.fix ? '\r\n'.repeat(maxAdjacentNewlines) : '';
-
- root.walkDecls((decl) => {
- if (!decl.value.includes('(')) {
- return;
- }
-
- const stringValue = getDeclarationValue(decl);
- /** @type {Array<[string, string]>} */
- const splittedValue = [];
- let sourceIndexStart = 0;
-
- valueParser(stringValue).walk((node) => {
- if (
- node.type !== 'function' /* ignore non functions */ ||
- node.value.length === 0 /* ignore sass lists */
- ) {
- return;
- }
-
- const stringifiedNode = valueParser.stringify(node);
-
- if (
- !violatedLFNewLinesRegex.test(stringifiedNode) &&
- !violatedCRLFNewLinesRegex.test(stringifiedNode)
- ) {
- return;
- }
-
- if (context.fix) {
- const newNodeString = stringifiedNode
- .replace(new RegExp(violatedLFNewLinesRegex, 'gm'), allowedLFNewLinesString)
- .replace(new RegExp(violatedCRLFNewLinesRegex, 'gm'), allowedCRLFNewLinesString);
-
- splittedValue.push([
- stringValue.slice(sourceIndexStart, node.sourceIndex),
- newNodeString,
- ]);
- sourceIndexStart = node.sourceIndex + stringifiedNode.length;
- } else {
- report({
- message: messages.expected(primary),
- node: decl,
- index: placeIndexOnValueStart(decl) + node.sourceIndex,
- result,
- ruleName,
- });
- }
- });
-
- if (context.fix && splittedValue.length > 0) {
- const updatedValue =
- splittedValue.reduce((acc, curr) => acc + curr[0] + curr[1], '') +
- stringValue.slice(sourceIndexStart);
-
- setDeclarationValue(decl, updatedValue);
- }
- });
- };
-};
-
-rule.ruleName = ruleName;
-rule.messages = messages;
-rule.meta = meta;
-module.exports = rule;
diff --git a/lib/rules/function-parentheses-newline-inside/README.md b/lib/rules/function-parentheses-newline-inside/README.md
deleted file mode 100644
index fc39fecda5..0000000000
--- a/lib/rules/function-parentheses-newline-inside/README.md
+++ /dev/null
@@ -1,146 +0,0 @@
-# function-parentheses-newline-inside
-
-> **Warning** This rule is deprecated and will be removed in the future. See [the migration guide](../../../docs/migration-guide/to-15.md).
-
-Require a newline or disallow whitespace on the inside of the parentheses of functions.
-
-
-```css
- a {
- transform: translate(
- 1, /* ↑ */
- 1 /* ↑ */
- ); /* ↑ */
- } /* ↑ */
-/** ↑ ↑
- * The newline inside these two parentheses */
-```
-
-The [`fix` option](../../../docs/user-guide/options.md#fix) can automatically fix all of the problems reported by this rule.
-
-## Options
-
-`string`: `"always"|"always-multi-line"|"never-multi-line"`
-
-### `"always"`
-
-There _must always_ be a newline inside the parentheses.
-
-The following patterns are considered problems:
-
-
-```css
-a { transform: translate(1, 1); }
-```
-
-
-```css
-a { transform: translate(1,
- 1
- ); }
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a {
- transform: translate(
- 1, 1
- );
-}
-```
-
-
-```css
-a {
- transform: translate(
- 1,
- 1
- );
-}
-```
-
-### `"always-multi-line"`
-
-There _must always_ be a newline inside the parentheses of multi-line functions.
-
-The following patterns are considered problems:
-
-
-```css
-a { transform: translate(1,
- 1) }
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { transform: translate(1, 1) }
-```
-
-
-```css
-a { transform: translate( 1, 1 ) }
-```
-
-
-```css
-a {
- transform: translate(
- 1, 1
- );
-}
-```
-
-
-```css
-a {
- transform: translate(
- 1,
- 1
- );
-}
-```
-
-### `"never-multi-line"`
-
-The following patterns are considered problems:
-
-
-```css
-a {
- transform: translate(
- 1, 1
- );
-}
-```
-
-
-```css
-a {
- transform: translate(
- 1,
- 1
- );
-}
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { transform: translate(1, 1) }
-```
-
-
-```css
-a { transform: translate( 1, 1 ) }
-```
-
-
-```css
-a { transform: translate(1,
- 1) }
-```
diff --git a/lib/rules/function-parentheses-newline-inside/__tests__/index.js b/lib/rules/function-parentheses-newline-inside/__tests__/index.js
deleted file mode 100644
index c1be9363b9..0000000000
--- a/lib/rules/function-parentheses-newline-inside/__tests__/index.js
+++ /dev/null
@@ -1,414 +0,0 @@
-'use strict';
-
-const { messages, ruleName } = require('..');
-
-testRule({
- ruleName,
- config: ['always'],
- fix: true,
-
- accept: [
- {
- code: 'a::before { content: "(a) ( a)"; }',
- },
- {
- code: "a::before { background: url(\n'asdf( Vcxvsd)ASD'\n); }",
- },
- {
- code: 'a { transform: translate(\n1, 1\n); }',
- },
- {
- code: 'a { transform: translate(\n\n1, 1\n\n); }',
- },
- {
- code: 'a { transform: translate(\r\n1, 1\r\n); }',
- description: 'CRLF',
- },
- {
- code: 'a { transform: translate(\r\n\r\n1, 1\r\n\r\n); }',
- description: 'CRLF',
- },
- {
- code: 'a { color: color(\nrgb(\n0, 0, 0\n) lightness(\n50%\n)\n); }',
- },
- {
- code: '$map: (key: value,key2: value2)',
- description: 'Sass map ignored',
- },
- {
- code: '$list: (value, value2)',
- description: 'Sass list ignored',
- },
- {
- code: 'a { transform: translate( /*comment*/\n1,\n 1\n); }',
- },
- ],
-
- reject: [
- {
- code: 'a { transform: translate(1, 1\n); }',
- fixed: 'a { transform: translate(\n1, 1\n); }',
- message: messages.expectedOpening,
- line: 1,
- column: 26,
- },
- {
- code: 'a { transform: translate(\n1, 1); }',
- fixed: 'a { transform: translate(\n1, 1\n); }',
- message: messages.expectedClosing,
- line: 2,
- column: 4,
- },
- {
- code: 'a { transform: translate( 1, 1\n); }',
- fixed: 'a { transform: translate(\n 1, 1\n); }',
- message: messages.expectedOpening,
- line: 1,
- column: 26,
- },
- {
- code: 'a { transform: translate(\n1,\n1\t); }',
- fixed: 'a { transform: translate(\n1,\n1\n\t); }',
- message: messages.expectedClosing,
- line: 3,
- column: 2,
- },
- {
- code: 'a { color: color(rgb(\n0, 0, 0\n) lightness(\n50%\n)\n); }',
- fixed: 'a { color: color(\nrgb(\n0, 0, 0\n) lightness(\n50%\n)\n); }',
- message: messages.expectedOpening,
- line: 1,
- column: 18,
- },
- {
- code: 'a { color: color(\nrgb(\n0, 0, 0\n) lightness(50%\n)\n); }',
- fixed: 'a { color: color(\nrgb(\n0, 0, 0\n) lightness(\n50%\n)\n); }',
- message: messages.expectedOpening,
- line: 4,
- column: 13,
- },
- {
- code: 'a::before { content: attr(data-foo\n); }',
- fixed: 'a::before { content: attr(\ndata-foo\n); }',
- message: messages.expectedOpening,
- line: 1,
- column: 27,
- },
- {
- code: 'a::before { content: attr(\n\tdata-foo); }',
- fixed: 'a::before { content: attr(\n\tdata-foo\n); }',
- message: messages.expectedClosing,
- line: 2,
- column: 9,
- },
- {
- code: 'a { transform: translate( 1,\n 1\n); }',
- fixed: 'a { transform: translate(\n 1,\n 1\n); }',
- message: messages.expectedOpening,
- line: 1,
- column: 26,
- },
- {
- code: 'a { transform: translate(1,\r\n1\n); }',
- fixed: 'a { transform: translate(\r\n1,\r\n1\n); }',
- description: 'CRLF',
- message: messages.expectedOpening,
- line: 1,
- column: 26,
- },
- {
- code: 'a { transform: translate( /*comment*/ 1,\n 1\n); }',
- fixed: 'a { transform: translate( /*comment*/\n 1,\n 1\n); }',
- message: messages.expectedOpening,
- line: 1,
- column: 26,
- },
- {
- code: 'a { transform: translate( /*c1*/ /*c2*/ 1,1 /*c3*/ /*c4*/ ); }',
- fixed: 'a { transform: translate( /*c1*/ /*c2*/\n 1,1 /*c3*/ /*c4*/\n ); }',
- warnings: [
- {
- message: messages.expectedOpening,
- line: 1,
- column: 26,
- },
- {
- message: messages.expectedClosing,
- line: 1,
- column: 58,
- },
- ],
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['always-multi-line'],
- fix: true,
-
- accept: [
- {
- code: 'a::before { content: "(a) ( a)"; }',
- },
- {
- code: "a::before { background: url(\n'asdf( Vcxvsd)ASD'\n); }",
- },
- {
- code: 'a { transform: translate(\n1, 1\n); }',
- },
- {
- code: 'a { transform: translate(\r\n1, 1\r\n); }',
- description: 'CRLF',
- },
- {
- code: 'a { color: color(\nrgb(\n0, 0, 0\n) lightness(\n50%\n)\n); }',
- },
- {
- code: 'a { transform: translate(1, 1); }',
- },
- {
- code: 'a { transform: translate( 1, 1\t); }',
- },
- {
- code: '$map: (key: value,\nkey2: value2)',
- description: 'SCSS map',
- },
- {
- code: 'a { transform: translate(\n/*comment*/ 1,1\n); }',
- },
- {
- code: 'a { transform: translate( /*comment*/\n1,1\n); }',
- },
- {
- code: 'a { transform: translate(\n1,1\n/*comment*/ ); }',
- },
- {
- code: 'a { transform: translate(\n1,1 /*comment*/\n); }',
- },
- ],
-
- reject: [
- {
- code: 'a { transform: translate(1, 1\n); }',
- fixed: 'a { transform: translate(\n1, 1\n); }',
- message: messages.expectedOpeningMultiLine,
- line: 1,
- column: 26,
- },
- {
- code: 'a { transform: translate(\n1, 1); }',
- fixed: 'a { transform: translate(\n1, 1\n); }',
- message: messages.expectedClosingMultiLine,
- line: 2,
- column: 4,
- },
- {
- code: 'a { transform: translate( 1, 1\n); }',
- fixed: 'a { transform: translate(\n 1, 1\n); }',
- message: messages.expectedOpeningMultiLine,
- line: 1,
- column: 26,
- },
- {
- code: 'a { transform: translate(\n1,\n1\t); }',
- fixed: 'a { transform: translate(\n1,\n1\n\t); }',
- message: messages.expectedClosingMultiLine,
- line: 3,
- column: 2,
- },
- {
- code: 'a { color: color(rgb(\n0, 0, 0\n) lightness(\n50%\n)\n); }',
- fixed: 'a { color: color(\nrgb(\n0, 0, 0\n) lightness(\n50%\n)\n); }',
- message: messages.expectedOpeningMultiLine,
- line: 1,
- column: 18,
- },
- {
- code: 'a { color: color(\nrgb(\n0, 0, 0\n) lightness(50%\n)\n); }',
- fixed: 'a { color: color(\nrgb(\n0, 0, 0\n) lightness(\n50%\n)\n); }',
- message: messages.expectedOpeningMultiLine,
- line: 4,
- column: 13,
- },
- {
- code: 'a::before { content: attr(data-foo\n); }',
- fixed: 'a::before { content: attr(\ndata-foo\n); }',
- message: messages.expectedOpeningMultiLine,
- line: 1,
- column: 27,
- },
- {
- code: 'a::before { content: attr(\n\tdata-foo); }',
- fixed: 'a::before { content: attr(\n\tdata-foo\n); }',
- message: messages.expectedClosingMultiLine,
- line: 2,
- column: 9,
- },
- {
- code: 'a { transform: translate( 1,\n 1\n); }',
- fixed: 'a { transform: translate(\n 1,\n 1\n); }',
- message: messages.expectedOpeningMultiLine,
- line: 1,
- column: 26,
- },
- {
- code: 'a { transform: translate(1,\r\n1\n); }',
- fixed: 'a { transform: translate(\r\n1,\r\n1\n); }',
- description: 'CRLF',
- message: messages.expectedOpeningMultiLine,
- line: 1,
- column: 26,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['never-multi-line'],
- fix: true,
-
- accept: [
- {
- code: 'a::before { content: "(a) ( a)"; }',
- },
- {
- code: "a::before { background: url('asdf(Vcxv\nsd\n)ASD'); }",
- },
- {
- code: 'a { transform: translate(1, 1); }',
- },
- {
- code: 'a { transform: translate(1,\r\n1); }',
- description: 'CRLF',
- },
- {
- code: 'a { color: color(rgb(0, 0, 0) lightness(50%)); }',
- },
- {
- code: 'a { transform: translate(1,\n 1); }',
- },
- {
- code: 'a { transform: translate(1,\n\t\t1); }',
- },
- {
- code: '$map: (\nkey: value,\nkey2: value2\n)',
- description: 'SCSS map',
- },
- {
- code: 'a { transform: translate(/*comment*/1,\n1); }',
- },
- {
- code: 'a { transform: translate(1,\n1/*comment*/); }',
- },
- ],
-
- reject: [
- {
- code: 'a { transform: translate(\n 1,\n 1); }',
- fixed: 'a { transform: translate(1,\n 1); }',
- message: messages.rejectedOpeningMultiLine,
- line: 1,
- column: 26,
- },
- {
- code: 'a { transform: translate( \n 1,\n 1); }',
- fixed: 'a { transform: translate(1,\n 1); }',
- message: messages.rejectedOpeningMultiLine,
- line: 1,
- column: 26,
- },
- {
- code: 'a { transform: translate(1,\n 1\n); }',
- fixed: 'a { transform: translate(1,\n 1); }',
- message: messages.rejectedClosingMultiLine,
- line: 2,
- column: 4,
- },
- {
- code: 'a { transform: translate(1,\r\n1\t); }',
- fixed: 'a { transform: translate(1,\r\n1); }',
- message: messages.rejectedClosingMultiLine,
- line: 2,
- column: 2,
- },
- {
- code: 'a { color: color(rgb(0,\r\n 0,\r\n 0\r\n) lightness(50%)); }',
- fixed: 'a { color: color(rgb(0,\r\n 0,\r\n 0) lightness(50%)); }',
- message: messages.rejectedClosingMultiLine,
- line: 3,
- column: 5,
- },
- {
- code: 'a { color: color(rgb(0, 0, 0) lightness(\n50%)); }',
- fixed: 'a { color: color(rgb(0, 0, 0) lightness(50%)); }',
- message: messages.rejectedOpeningMultiLine,
- line: 1,
- column: 41,
- },
- {
- code: 'a { transform: translate( /*c1*/ /*c2*/ 1,\n1 /*c3*/ /*c4*/ ); }',
- fixed: 'a { transform: translate(/*c1*//*c2*/1,\n1/*c3*//*c4*/); }',
- warnings: [
- {
- message: messages.rejectedOpeningMultiLine,
- line: 1,
- column: 26,
- },
- {
- message: messages.rejectedClosingMultiLine,
- line: 2,
- column: 16,
- },
- ],
- },
- {
- code: 'a { transform: translate( /*c1*//*c2*/1,\n1/*c3*//*c4*/ ); }',
- fixed: 'a { transform: translate(/*c1*//*c2*/1,\n1/*c3*//*c4*/); }',
- warnings: [
- {
- message: messages.rejectedOpeningMultiLine,
- line: 1,
- column: 26,
- },
- {
- message: messages.rejectedClosingMultiLine,
- line: 2,
- column: 14,
- },
- ],
- },
- {
- code: 'a { transform: translate(/*c1*//*c2*/ 1,\n1 /*c3*//*c4*/); }',
- fixed: 'a { transform: translate(/*c1*//*c2*/1,\n1/*c3*//*c4*/); }',
- warnings: [
- {
- message: messages.rejectedOpeningMultiLine,
- line: 1,
- column: 26,
- },
- {
- message: messages.rejectedClosingMultiLine,
- line: 2,
- column: 14,
- },
- ],
- },
- {
- code: 'a { transform: translate(/*c1*/ /*c2*/1,\n1/*c3*/ /*c4*/); }',
- fixed: 'a { transform: translate(/*c1*//*c2*/1,\n1/*c3*//*c4*/); }',
- warnings: [
- {
- message: messages.rejectedOpeningMultiLine,
- line: 1,
- column: 26,
- },
- {
- message: messages.rejectedClosingMultiLine,
- line: 2,
- column: 14,
- },
- ],
- },
- ],
-});
diff --git a/lib/rules/function-parentheses-newline-inside/index.js b/lib/rules/function-parentheses-newline-inside/index.js
deleted file mode 100644
index 67dd51e946..0000000000
--- a/lib/rules/function-parentheses-newline-inside/index.js
+++ /dev/null
@@ -1,276 +0,0 @@
-'use strict';
-
-const declarationValueIndex = require('../../utils/declarationValueIndex');
-const getDeclarationValue = require('../../utils/getDeclarationValue');
-const isSingleLineString = require('../../utils/isSingleLineString');
-const isStandardSyntaxFunction = require('../../utils/isStandardSyntaxFunction');
-const report = require('../../utils/report');
-const ruleMessages = require('../../utils/ruleMessages');
-const setDeclarationValue = require('../../utils/setDeclarationValue');
-const validateOptions = require('../../utils/validateOptions');
-const valueParser = require('postcss-value-parser');
-
-const ruleName = 'function-parentheses-newline-inside';
-
-const messages = ruleMessages(ruleName, {
- expectedOpening: 'Expected newline after "("',
- expectedClosing: 'Expected newline before ")"',
- expectedOpeningMultiLine: 'Expected newline after "(" in a multi-line function',
- rejectedOpeningMultiLine: 'Unexpected whitespace after "(" in a multi-line function',
- expectedClosingMultiLine: 'Expected newline before ")" in a multi-line function',
- rejectedClosingMultiLine: 'Unexpected whitespace before ")" in a multi-line function',
-});
-
-const meta = {
- url: 'https://stylelint.io/user-guide/rules/function-parentheses-newline-inside',
- fixable: true,
- deprecated: true,
-};
-
-/** @type {import('stylelint').Rule} */
-const rule = (primary, _secondaryOptions, context) => {
- return (root, result) => {
- const validOptions = validateOptions(result, ruleName, {
- actual: primary,
- possible: ['always', 'always-multi-line', 'never-multi-line'],
- });
-
- if (!validOptions) {
- return;
- }
-
- root.walkDecls((decl) => {
- if (!decl.value.includes('(')) {
- return;
- }
-
- let hasFixed = false;
- const declValue = getDeclarationValue(decl);
- const parsedValue = valueParser(declValue);
-
- parsedValue.walk((valueNode) => {
- if (valueNode.type !== 'function') {
- return;
- }
-
- if (!isStandardSyntaxFunction(valueNode)) {
- return;
- }
-
- const functionString = valueParser.stringify(valueNode);
- const isMultiLine = !isSingleLineString(functionString);
- const containsNewline = (/** @type {string} */ str) => str.includes('\n');
-
- // Check opening ...
-
- const openingIndex = valueNode.sourceIndex + valueNode.value.length + 1;
- const checkBefore = getCheckBefore(valueNode);
-
- if (primary === 'always' && !containsNewline(checkBefore)) {
- if (context.fix) {
- hasFixed = true;
- fixBeforeForAlways(valueNode, context.newline || '');
- } else {
- complain(messages.expectedOpening, openingIndex);
- }
- }
-
- if (isMultiLine && primary === 'always-multi-line' && !containsNewline(checkBefore)) {
- if (context.fix) {
- hasFixed = true;
- fixBeforeForAlways(valueNode, context.newline || '');
- } else {
- complain(messages.expectedOpeningMultiLine, openingIndex);
- }
- }
-
- if (isMultiLine && primary === 'never-multi-line' && checkBefore !== '') {
- if (context.fix) {
- hasFixed = true;
- fixBeforeForNever(valueNode);
- } else {
- complain(messages.rejectedOpeningMultiLine, openingIndex);
- }
- }
-
- // Check closing ...
-
- const closingIndex = valueNode.sourceIndex + functionString.length - 2;
- const checkAfter = getCheckAfter(valueNode);
-
- if (primary === 'always' && !containsNewline(checkAfter)) {
- if (context.fix) {
- hasFixed = true;
- fixAfterForAlways(valueNode, context.newline || '');
- } else {
- complain(messages.expectedClosing, closingIndex);
- }
- }
-
- if (isMultiLine && primary === 'always-multi-line' && !containsNewline(checkAfter)) {
- if (context.fix) {
- hasFixed = true;
- fixAfterForAlways(valueNode, context.newline || '');
- } else {
- complain(messages.expectedClosingMultiLine, closingIndex);
- }
- }
-
- if (isMultiLine && primary === 'never-multi-line' && checkAfter !== '') {
- if (context.fix) {
- hasFixed = true;
- fixAfterForNever(valueNode);
- } else {
- complain(messages.rejectedClosingMultiLine, closingIndex);
- }
- }
- });
-
- if (hasFixed) {
- setDeclarationValue(decl, parsedValue.toString());
- }
-
- /**
- * @param {string} message
- * @param {number} offset
- */
- function complain(message, offset) {
- report({
- ruleName,
- result,
- message,
- node: decl,
- index: declarationValueIndex(decl) + offset,
- });
- }
- });
- };
-};
-
-/** @typedef {import('postcss-value-parser').FunctionNode} FunctionNode */
-
-/**
- * @param {FunctionNode} valueNode
- */
-function getCheckBefore(valueNode) {
- let before = valueNode.before;
-
- for (const node of valueNode.nodes) {
- if (node.type === 'comment') {
- continue;
- }
-
- if (node.type === 'space') {
- before += node.value;
- continue;
- }
-
- break;
- }
-
- return before;
-}
-
-/**
- * @param {FunctionNode} valueNode
- */
-function getCheckAfter(valueNode) {
- let after = '';
-
- for (const node of [...valueNode.nodes].reverse()) {
- if (node.type === 'comment') {
- continue;
- }
-
- if (node.type === 'space') {
- after = node.value + after;
- continue;
- }
-
- break;
- }
-
- after += valueNode.after;
-
- return after;
-}
-
-/**
- * @param {FunctionNode} valueNode
- * @param {string} newline
- */
-function fixBeforeForAlways(valueNode, newline) {
- let target;
-
- for (const node of valueNode.nodes) {
- if (node.type === 'comment') {
- continue;
- }
-
- if (node.type === 'space') {
- target = node;
- continue;
- }
-
- break;
- }
-
- if (target) {
- target.value = newline + target.value;
- } else {
- valueNode.before = newline + valueNode.before;
- }
-}
-
-/**
- * @param {FunctionNode} valueNode
- */
-function fixBeforeForNever(valueNode) {
- valueNode.before = '';
-
- for (const node of valueNode.nodes) {
- if (node.type === 'comment') {
- continue;
- }
-
- if (node.type === 'space') {
- node.value = '';
- continue;
- }
-
- break;
- }
-}
-
-/**
- * @param {FunctionNode} valueNode
- * @param {string} newline
- */
-function fixAfterForAlways(valueNode, newline) {
- valueNode.after = newline + valueNode.after;
-}
-
-/**
- * @param {FunctionNode} valueNode
- */
-function fixAfterForNever(valueNode) {
- valueNode.after = '';
-
- for (const node of [...valueNode.nodes].reverse()) {
- if (node.type === 'comment') {
- continue;
- }
-
- if (node.type === 'space') {
- node.value = '';
- continue;
- }
-
- break;
- }
-}
-
-rule.ruleName = ruleName;
-rule.messages = messages;
-rule.meta = meta;
-module.exports = rule;
diff --git a/lib/rules/function-parentheses-space-inside/README.md b/lib/rules/function-parentheses-space-inside/README.md
deleted file mode 100644
index 0904931a0b..0000000000
--- a/lib/rules/function-parentheses-space-inside/README.md
+++ /dev/null
@@ -1,142 +0,0 @@
-# function-parentheses-space-inside
-
-> **Warning** This rule is deprecated and will be removed in the future. See [the migration guide](../../../docs/migration-guide/to-15.md).
-
-Require a single space or disallow whitespace on the inside of the parentheses of functions.
-
-
-```css
-a { transform: translate( 1, 1 ); }
-/** ↑ ↑
- * The space inside these two parentheses */
-```
-
-The [`fix` option](../../../docs/user-guide/options.md#fix) can automatically fix all of the problems reported by this rule.
-
-## Options
-
-`string`: `"always"|"never"|"always-single-line"|"never-single-line"`
-
-### `"always"`
-
-There _must always_ be a single space inside of the parentheses.
-
-The following patterns are considered problems:
-
-
-```css
-a { transform: translate(1, 1); }
-```
-
-
-```css
-a { transform: translate(1, 1 ); }
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { transform: translate( 1, 1 ); }
-```
-
-### `"never"`
-
-There _must never_ be whitespace on the inside of the parentheses.
-
-The following patterns are considered problems:
-
-
-```css
-a { transform: translate( 1, 1 ); }
-```
-
-
-```css
-a { transform: translate(1, 1 ); }
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { transform: translate(1, 1); }
-```
-
-### `"always-single-line"`
-
-There _must always_ be a single space inside the parentheses of single-line functions.
-
-The following patterns are considered problems:
-
-
-```css
-a { transform: translate(1, 1) }
-```
-
-
-```css
-a { transform: translate(1, 1 ) }
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { transform: translate( 1, 1 ) }
-```
-
-
-```css
-a { transform: translate(1,
- 1) }
-```
-
-
-```css
-a {
- transform: translate(
- 1,
- 1
- )
-}
-```
-
-### `"never-single-line"`
-
-There _must never_ be whitespace inside the parentheses of single-line functions.
-
-The following patterns are considered problems:
-
-
-```css
-a { transform: translate( 1, 1 ) }
-```
-
-
-```css
-a { transform: translate(1, 1 ) }
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { transform: translate(1, 1) }
-```
-
-
-```css
-a { transform: translate( 1,
- 1) }
-```
-
-
-```css
-a {
- transform: translate(
- 1,
- 1
- )
-}
-```
diff --git a/lib/rules/function-parentheses-space-inside/__tests__/index.js b/lib/rules/function-parentheses-space-inside/__tests__/index.js
deleted file mode 100644
index d129b224c3..0000000000
--- a/lib/rules/function-parentheses-space-inside/__tests__/index.js
+++ /dev/null
@@ -1,599 +0,0 @@
-'use strict';
-
-const mergeTestDescriptions = require('../../../testUtils/mergeTestDescriptions');
-
-const { messages, ruleName } = require('..');
-
-const alwaysTests = {
- accept: [
- {
- code: 'a { filter: grayscale(); }',
- description: 'ignore function without parameters',
- },
- {
- code: 'a { filter: grayscale( ); }',
- description: 'ignore function without parameters',
- },
- ],
-};
-
-testRule(
- mergeTestDescriptions(alwaysTests, {
- ruleName,
- config: ['always'],
- fix: true,
-
- accept: [
- {
- code: 'a::before { content: "(a) ( a )"; }',
- },
- {
- code: "a::before { background: url( 'asdf(Vcxvsd)ASD' ); }",
- },
- {
- code: 'a { transform: translate( 1, 1 ); }',
- },
- {
- code: 'a { color: color( rgb( 0, 0, 0 ) lightness( 50% ) ); }',
- },
- {
- code: '$map: (key: value, key2: value2)',
- description: 'SCSS map',
- },
- {
- code: '$list: (value, value2)',
- description: 'Sass list ignored',
- },
- ],
-
- reject: [
- {
- code: 'a { transform: translate(1, 1 ); }',
- fixed: 'a { transform: translate( 1, 1 ); }',
- message: messages.expectedOpening,
- line: 1,
- column: 26,
- },
- {
- code: 'a { transform: translate( 1, 1); }',
- fixed: 'a { transform: translate( 1, 1 ); }',
- message: messages.expectedClosing,
- line: 1,
- column: 30,
- },
- {
- code: 'a { transform: translate( 1, 1 ); }',
- fixed: 'a { transform: translate( 1, 1 ); }',
- message: messages.expectedOpening,
- line: 1,
- column: 26,
- },
- {
- code: 'a { transform: translate( 1, 1 ); }',
- fixed: 'a { transform: translate( 1, 1 ); }',
- message: messages.expectedClosing,
- line: 1,
- column: 32,
- },
- {
- code: 'a { color: color(rgb( 0, 0, 0 ) lightness( 50% ) ); }',
- fixed: 'a { color: color( rgb( 0, 0, 0 ) lightness( 50% ) ); }',
- message: messages.expectedOpening,
- line: 1,
- column: 18,
- },
- {
- code: 'a { color: color( rgb(0, 0, 0 ) lightness( 50% ) ); }',
- fixed: 'a { color: color( rgb( 0, 0, 0 ) lightness( 50% ) ); }',
- message: messages.expectedOpening,
- line: 1,
- column: 23,
- },
- {
- code: 'a { color: color( rgb( 0, 0, 0) lightness( 50% ) ); }',
- fixed: 'a { color: color( rgb( 0, 0, 0 ) lightness( 50% ) ); }',
- message: messages.expectedClosing,
- line: 1,
- column: 30,
- },
- {
- code: 'a { color: color( rgb( 0, 0, 0 ) lightness(50% ) ); }',
- fixed: 'a { color: color( rgb( 0, 0, 0 ) lightness( 50% ) ); }',
- message: messages.expectedOpening,
- line: 1,
- column: 44,
- },
- {
- code: 'a { color: color( rgb( 0, 0, 0 ) lightness( 50%) ); }',
- fixed: 'a { color: color( rgb( 0, 0, 0 ) lightness( 50% ) ); }',
- message: messages.expectedClosing,
- line: 1,
- column: 47,
- },
- {
- code: 'a { color: color( rgb( 0, 0, 0 ) lightness( 50% )); }',
- fixed: 'a { color: color( rgb( 0, 0, 0 ) lightness( 50% ) ); }',
- message: messages.expectedClosing,
- line: 1,
- column: 49,
- },
- {
- code: 'a::before { content: attr(data-foo ); }',
- fixed: 'a::before { content: attr( data-foo ); }',
- message: messages.expectedOpening,
- line: 1,
- column: 27,
- },
- {
- code: 'a::before { content: attr( data-foo); }',
- fixed: 'a::before { content: attr( data-foo ); }',
- message: messages.expectedClosing,
- line: 1,
- column: 35,
- },
- {
- code: 'a { transform: translate(\n 1,\n 1 ); }',
- fixed: 'a { transform: translate( 1,\n 1 ); }',
- message: messages.expectedOpening,
- line: 1,
- column: 26,
- },
- {
- code: 'a { transform: translate( 1,\n 1\n\t); }',
- fixed: 'a { transform: translate( 1,\n 1 ); }',
- message: messages.expectedClosing,
- line: 3,
- column: 1,
- },
- {
- code: 'a { transform: translate(1,\r\n1 ); }',
- fixed: 'a { transform: translate( 1,\r\n1 ); }',
- description: 'CRLF',
- message: messages.expectedOpening,
- line: 1,
- column: 26,
- },
- {
- code: 'a { transform: translate(/*comment*/1, 1/*comment*/); }',
- fixed: 'a { transform: translate( /*comment*/1, 1/*comment*/ ); }',
- description: 'comments',
- warnings: [
- {
- message: messages.expectedOpening,
- line: 1,
- column: 26,
- },
- {
- message: messages.expectedClosing,
- line: 1,
- column: 51,
- },
- ],
- },
- ],
- }),
-);
-
-testRule(
- mergeTestDescriptions(alwaysTests, {
- ruleName,
- config: ['always-single-line'],
- fix: true,
-
- accept: [
- {
- code: 'a::before { content: "(a) ( a )"; }',
- },
- {
- code: "a::before { background: url( 'asdf(Vcxvsd)ASD' ); }",
- },
- {
- code: 'a { transform: translate( 1, 1 ); }',
- },
- {
- code: 'a { color: color( rgb( 0, 0, 0 ) lightness( 50% ) ); }',
- },
- {
- code: 'a { transform: translate(\n 1,\n 1\n); }',
- },
- {
- code: 'a { transform: translate( \n 1,\n 1\n\t); }',
- },
- {
- code: 'a { transform: translate(1,\r\n1); }',
- description: 'CRLF',
- },
- {
- code: 'a { color: color(rgb(0,\n0,\n0 ) lightness( 50% )); }',
- },
- {
- code: '$map: (key: value, key2: value2)',
- description: 'SCSS map',
- },
- ],
-
- reject: [
- {
- code: 'a { color: color(rgb(0,\n0,\n0 ) lightness(50% )); }',
- fixed: 'a { color: color(rgb(0,\n0,\n0 ) lightness( 50% )); }',
- message: messages.expectedOpeningSingleLine,
- line: 3,
- column: 15,
- },
- {
- code: 'a { transform: translate(1, 1 ); }',
- fixed: 'a { transform: translate( 1, 1 ); }',
- message: messages.expectedOpeningSingleLine,
- line: 1,
- column: 26,
- },
- {
- code: 'a { transform: translate( 1, 1); }',
- fixed: 'a { transform: translate( 1, 1 ); }',
- message: messages.expectedClosingSingleLine,
- line: 1,
- column: 30,
- },
- {
- code: 'a { transform: translate( 1, 1 ); }',
- fixed: 'a { transform: translate( 1, 1 ); }',
- message: messages.expectedOpeningSingleLine,
- line: 1,
- column: 26,
- },
- {
- code: 'a { transform: translate( 1, 1 ); }',
- fixed: 'a { transform: translate( 1, 1 ); }',
- message: messages.expectedClosingSingleLine,
- line: 1,
- column: 32,
- },
- {
- code: 'a { color: color(rgb( 0, 0, 0 ) lightness( 50% ) ); }',
- fixed: 'a { color: color( rgb( 0, 0, 0 ) lightness( 50% ) ); }',
- message: messages.expectedOpeningSingleLine,
- line: 1,
- column: 18,
- },
- {
- code: 'a { color: color( rgb(0, 0, 0 ) lightness( 50% ) ); }',
- fixed: 'a { color: color( rgb( 0, 0, 0 ) lightness( 50% ) ); }',
- message: messages.expectedOpeningSingleLine,
- line: 1,
- column: 23,
- },
- {
- code: 'a { color: color( rgb( 0, 0, 0) lightness( 50% ) ); }',
- fixed: 'a { color: color( rgb( 0, 0, 0 ) lightness( 50% ) ); }',
- message: messages.expectedClosingSingleLine,
- line: 1,
- column: 30,
- },
- {
- code: 'a { color: color( rgb( 0, 0, 0 ) lightness(50% ) ); }',
- fixed: 'a { color: color( rgb( 0, 0, 0 ) lightness( 50% ) ); }',
- message: messages.expectedOpeningSingleLine,
- line: 1,
- column: 44,
- },
- {
- code: 'a { color: color( rgb( 0, 0, 0 ) lightness( 50%) ); }',
- fixed: 'a { color: color( rgb( 0, 0, 0 ) lightness( 50% ) ); }',
- message: messages.expectedClosingSingleLine,
- line: 1,
- column: 47,
- },
- {
- code: 'a { color: color( rgb( 0, 0, 0 ) lightness( 50% )); }',
- fixed: 'a { color: color( rgb( 0, 0, 0 ) lightness( 50% ) ); }',
- message: messages.expectedClosingSingleLine,
- line: 1,
- column: 49,
- },
- {
- code: 'a::before { content: attr(data-foo ); }',
- fixed: 'a::before { content: attr( data-foo ); }',
- message: messages.expectedOpeningSingleLine,
- line: 1,
- column: 27,
- },
- {
- code: 'a::before { content: attr( data-foo); }',
- fixed: 'a::before { content: attr( data-foo ); }',
- message: messages.expectedClosingSingleLine,
- line: 1,
- column: 35,
- },
- ],
- }),
-);
-
-testRule(
- mergeTestDescriptions(alwaysTests, {
- ruleName,
- config: ['never'],
- fix: true,
-
- accept: [
- {
- code: 'a::before { content: "(a) ( a )"; }',
- },
- {
- code: "a::before { background: url('asdf( Vcxvsd )ASD'); }",
- },
- {
- code: 'a::before { content: "(a) ( a )"; }',
- },
- {
- code: 'a { transform: translate(1, 1); }',
- },
- {
- code: 'a { color: color(rgb(0, 0, 0) lightness(50%)); }',
- },
- {
- code: '$map: ( key: value, key2: value2 )',
- description: 'SCSS map',
- },
- ],
-
- reject: [
- {
- code: 'a { transform: translate( 1, 1); }',
- fixed: 'a { transform: translate(1, 1); }',
- message: messages.rejectedOpening,
- line: 1,
- column: 26,
- },
- {
- code: 'a { transform: translate( 1, 1); }',
- fixed: 'a { transform: translate(1, 1); }',
- message: messages.rejectedOpening,
- line: 1,
- column: 26,
- },
- {
- code: 'a { transform: translate(1, 1 ); }',
- fixed: 'a { transform: translate(1, 1); }',
- message: messages.rejectedClosing,
- line: 1,
- column: 30,
- },
- {
- code: 'a { transform: translate(1, 1 ); }',
- fixed: 'a { transform: translate(1, 1); }',
- message: messages.rejectedClosing,
- line: 1,
- column: 31,
- },
- {
- code: 'a { color: color( rgb(0, 0, 0) lightness(50%)); }',
- fixed: 'a { color: color(rgb(0, 0, 0) lightness(50%)); }',
- message: messages.rejectedOpening,
- line: 1,
- column: 18,
- },
- {
- code: 'a { color: color(rgb( 0, 0, 0) lightness(50%)); }',
- fixed: 'a { color: color(rgb(0, 0, 0) lightness(50%)); }',
- message: messages.rejectedOpening,
- line: 1,
- column: 22,
- },
- {
- code: 'a { color: color(rgb(0, 0, 0 ) lightness(50%)); }',
- fixed: 'a { color: color(rgb(0, 0, 0) lightness(50%)); }',
- message: messages.rejectedClosing,
- line: 1,
- column: 29,
- },
- {
- code: 'a { color: color(rgb(0, 0, 0) lightness( 50%)); }',
- fixed: 'a { color: color(rgb(0, 0, 0) lightness(50%)); }',
- message: messages.rejectedOpening,
- line: 1,
- column: 41,
- },
- {
- code: 'a { color: color(rgb(0, 0, 0) lightness(50% )); }',
- fixed: 'a { color: color(rgb(0, 0, 0) lightness(50%)); }',
- message: messages.rejectedClosing,
- line: 1,
- column: 44,
- },
- {
- code: 'a { color: color(rgb(0, 0, 0) lightness(50%) ); }',
- fixed: 'a { color: color(rgb(0, 0, 0) lightness(50%)); }',
- message: messages.rejectedClosing,
- line: 1,
- column: 45,
- },
- {
- code: 'a::before { content: attr(data-foo ); }',
- fixed: 'a::before { content: attr(data-foo); }',
- message: messages.rejectedClosing,
- line: 1,
- column: 35,
- },
- {
- code: 'a::before { content: attr( data-foo); }',
- fixed: 'a::before { content: attr(data-foo); }',
- message: messages.rejectedOpening,
- line: 1,
- column: 27,
- },
- {
- code: 'a { transform: translate( 1,\n1); }',
- fixed: 'a { transform: translate(1,\n1); }',
- message: messages.rejectedOpening,
- line: 1,
- column: 26,
- },
- {
- code: 'a { transform: translate(1,\r\n 1\r\n); }',
- fixed: 'a { transform: translate(1,\r\n 1); }',
- description: 'CRLF',
- message: messages.rejectedClosing,
- line: 2,
- column: 5,
- },
- {
- code: 'a { color: color(rgb(0,\n0,\n0 ) lightness(50%)); }',
- fixed: 'a { color: color(rgb(0,\n0,\n0) lightness(50%)); }',
- message: messages.rejectedClosing,
- line: 3,
- column: 2,
- },
- {
- code: 'a { transform: translate( /*comment*/ 1, 1 /*comment*/ ); }',
- fixed: 'a { transform: translate(/*comment*/ 1, 1 /*comment*/); }',
- description: 'comments',
- warnings: [
- {
- message: messages.rejectedOpening,
- line: 1,
- column: 26,
- },
- {
- message: messages.rejectedClosing,
- line: 1,
- column: 55,
- },
- ],
- },
- ],
- }),
-);
-
-testRule(
- mergeTestDescriptions(alwaysTests, {
- ruleName,
- config: ['never-single-line'],
- fix: true,
-
- accept: [
- {
- code: 'a::before { content: "(a) ( a )"; }',
- },
- {
- code: "a::before { background: url('asdf( Vcxvsd )ASD'); }",
- },
- {
- code: 'a::before { content: "(a) ( a )"; }',
- },
- {
- code: 'a { transform: translate(1, 1); }',
- },
- {
- code: 'a { color: color(rgb(0, 0, 0) lightness(50%)); }',
- },
- {
- code: 'a { transform: translate( 1,\n1 ); }',
- },
- {
- code: 'a { transform: translate(\r\n 1,\r\n 1\r\n); }',
- description: 'CRLF',
- },
- {
- code: 'a { color: color(rgb(0,\n0,\n0 ) lightness(50%)); }',
- },
- {
- code: '$map: ( key: value, key2: value2 )',
- description: 'SCSS map',
- },
- ],
-
- reject: [
- {
- code: 'a { color: color(rgb(0,\n0,\n0) lightness( 50%)); }',
- fixed: 'a { color: color(rgb(0,\n0,\n0) lightness(50%)); }',
- message: messages.rejectedOpeningSingleLine,
- line: 3,
- column: 14,
- },
- {
- code: 'a { transform: translate( 1, 1); }',
- fixed: 'a { transform: translate(1, 1); }',
- message: messages.rejectedOpeningSingleLine,
- line: 1,
- column: 26,
- },
- {
- code: 'a { transform: translate( 1, 1); }',
- fixed: 'a { transform: translate(1, 1); }',
- message: messages.rejectedOpeningSingleLine,
- line: 1,
- column: 26,
- },
- {
- code: 'a { transform: translate(1, 1 ); }',
- fixed: 'a { transform: translate(1, 1); }',
- message: messages.rejectedClosingSingleLine,
- line: 1,
- column: 30,
- },
- {
- code: 'a { transform: translate(1, 1 ); }',
- fixed: 'a { transform: translate(1, 1); }',
- message: messages.rejectedClosingSingleLine,
- line: 1,
- column: 31,
- },
- {
- code: 'a { color: color( rgb(0, 0, 0) lightness(50%)); }',
- fixed: 'a { color: color(rgb(0, 0, 0) lightness(50%)); }',
- message: messages.rejectedOpeningSingleLine,
- line: 1,
- column: 18,
- },
- {
- code: 'a { color: color(rgb( 0, 0, 0) lightness(50%)); }',
- fixed: 'a { color: color(rgb(0, 0, 0) lightness(50%)); }',
- message: messages.rejectedOpeningSingleLine,
- line: 1,
- column: 22,
- },
- {
- code: 'a { color: color(rgb(0, 0, 0 ) lightness(50%)); }',
- fixed: 'a { color: color(rgb(0, 0, 0) lightness(50%)); }',
- message: messages.rejectedClosingSingleLine,
- line: 1,
- column: 29,
- },
- {
- code: 'a { color: color(rgb(0, 0, 0) lightness( 50%)); }',
- fixed: 'a { color: color(rgb(0, 0, 0) lightness(50%)); }',
- message: messages.rejectedOpeningSingleLine,
- line: 1,
- column: 41,
- },
- {
- code: 'a { color: color(rgb(0, 0, 0) lightness(50% )); }',
- fixed: 'a { color: color(rgb(0, 0, 0) lightness(50%)); }',
- message: messages.rejectedClosingSingleLine,
- line: 1,
- column: 44,
- },
- {
- code: 'a { color: color(rgb(0, 0, 0) lightness(50%) ); }',
- fixed: 'a { color: color(rgb(0, 0, 0) lightness(50%)); }',
- message: messages.rejectedClosingSingleLine,
- line: 1,
- column: 45,
- },
- {
- code: 'a::before { content: attr(data-foo ); }',
- fixed: 'a::before { content: attr(data-foo); }',
- message: messages.rejectedClosingSingleLine,
- line: 1,
- column: 35,
- },
- {
- code: 'a::before { content: attr( data-foo); }',
- fixed: 'a::before { content: attr(data-foo); }',
- message: messages.rejectedOpeningSingleLine,
- line: 1,
- column: 27,
- },
- ],
- }),
-);
diff --git a/lib/rules/function-parentheses-space-inside/index.js b/lib/rules/function-parentheses-space-inside/index.js
deleted file mode 100644
index 4974e7a235..0000000000
--- a/lib/rules/function-parentheses-space-inside/index.js
+++ /dev/null
@@ -1,175 +0,0 @@
-'use strict';
-
-const declarationValueIndex = require('../../utils/declarationValueIndex');
-const getDeclarationValue = require('../../utils/getDeclarationValue');
-const isSingleLineString = require('../../utils/isSingleLineString');
-const isStandardSyntaxFunction = require('../../utils/isStandardSyntaxFunction');
-const report = require('../../utils/report');
-const ruleMessages = require('../../utils/ruleMessages');
-const setDeclarationValue = require('../../utils/setDeclarationValue');
-const validateOptions = require('../../utils/validateOptions');
-const valueParser = require('postcss-value-parser');
-
-const ruleName = 'function-parentheses-space-inside';
-
-const messages = ruleMessages(ruleName, {
- expectedOpening: 'Expected single space after "("',
- rejectedOpening: 'Unexpected whitespace after "("',
- expectedClosing: 'Expected single space before ")"',
- rejectedClosing: 'Unexpected whitespace before ")"',
- expectedOpeningSingleLine: 'Expected single space after "(" in a single-line function',
- rejectedOpeningSingleLine: 'Unexpected whitespace after "(" in a single-line function',
- expectedClosingSingleLine: 'Expected single space before ")" in a single-line function',
- rejectedClosingSingleLine: 'Unexpected whitespace before ")" in a single-line function',
-});
-
-const meta = {
- url: 'https://stylelint.io/user-guide/rules/function-parentheses-space-inside',
- fixable: true,
- deprecated: true,
-};
-
-/** @type {import('stylelint').Rule} */
-const rule = (primary, _secondaryOptions, context) => {
- return (root, result) => {
- const validOptions = validateOptions(result, ruleName, {
- actual: primary,
- possible: ['always', 'never', 'always-single-line', 'never-single-line'],
- });
-
- if (!validOptions) {
- return;
- }
-
- root.walkDecls((decl) => {
- if (!decl.value.includes('(')) {
- return;
- }
-
- let hasFixed = false;
- const declValue = getDeclarationValue(decl);
- const parsedValue = valueParser(declValue);
-
- parsedValue.walk((valueNode) => {
- if (valueNode.type !== 'function') {
- return;
- }
-
- if (!isStandardSyntaxFunction(valueNode)) {
- return;
- }
-
- // Ignore function without parameters
- if (!valueNode.nodes.length) {
- return;
- }
-
- const functionString = valueParser.stringify(valueNode);
- const isSingleLine = isSingleLineString(functionString);
-
- // Check opening ...
-
- const openingIndex = valueNode.sourceIndex + valueNode.value.length + 1;
-
- if (primary === 'always' && valueNode.before !== ' ') {
- if (context.fix) {
- hasFixed = true;
- valueNode.before = ' ';
- } else {
- complain(messages.expectedOpening, openingIndex);
- }
- }
-
- if (primary === 'never' && valueNode.before !== '') {
- if (context.fix) {
- hasFixed = true;
- valueNode.before = '';
- } else {
- complain(messages.rejectedOpening, openingIndex);
- }
- }
-
- if (isSingleLine && primary === 'always-single-line' && valueNode.before !== ' ') {
- if (context.fix) {
- hasFixed = true;
- valueNode.before = ' ';
- } else {
- complain(messages.expectedOpeningSingleLine, openingIndex);
- }
- }
-
- if (isSingleLine && primary === 'never-single-line' && valueNode.before !== '') {
- if (context.fix) {
- hasFixed = true;
- valueNode.before = '';
- } else {
- complain(messages.rejectedOpeningSingleLine, openingIndex);
- }
- }
-
- // Check closing ...
-
- const closingIndex = valueNode.sourceIndex + functionString.length - 2;
-
- if (primary === 'always' && valueNode.after !== ' ') {
- if (context.fix) {
- hasFixed = true;
- valueNode.after = ' ';
- } else {
- complain(messages.expectedClosing, closingIndex);
- }
- }
-
- if (primary === 'never' && valueNode.after !== '') {
- if (context.fix) {
- hasFixed = true;
- valueNode.after = '';
- } else {
- complain(messages.rejectedClosing, closingIndex);
- }
- }
-
- if (isSingleLine && primary === 'always-single-line' && valueNode.after !== ' ') {
- if (context.fix) {
- hasFixed = true;
- valueNode.after = ' ';
- } else {
- complain(messages.expectedClosingSingleLine, closingIndex);
- }
- }
-
- if (isSingleLine && primary === 'never-single-line' && valueNode.after !== '') {
- if (context.fix) {
- hasFixed = true;
- valueNode.after = '';
- } else {
- complain(messages.rejectedClosingSingleLine, closingIndex);
- }
- }
- });
-
- if (hasFixed) {
- setDeclarationValue(decl, parsedValue.toString());
- }
-
- /**
- * @param {string} message
- * @param {number} offset
- */
- function complain(message, offset) {
- report({
- ruleName,
- result,
- message,
- node: decl,
- index: declarationValueIndex(decl) + offset,
- });
- }
- });
- };
-};
-
-rule.ruleName = ruleName;
-rule.messages = messages;
-rule.meta = meta;
-module.exports = rule;
diff --git a/lib/rules/function-whitespace-after/README.md b/lib/rules/function-whitespace-after/README.md
deleted file mode 100644
index e4be492a57..0000000000
--- a/lib/rules/function-whitespace-after/README.md
+++ /dev/null
@@ -1,82 +0,0 @@
-# function-whitespace-after
-
-> **Warning** This rule is deprecated and will be removed in the future. See [the migration guide](../../../docs/migration-guide/to-15.md).
-
-Require or disallow whitespace after functions.
-
-
-```css
-a { transform: translate(1, 1) scale(3); }
-/** ↑
- * This space */
-```
-
-This rule does not check for space immediately after `)` if the very next character is `,`, `)`, `/` or `}`, allowing some of the patterns exemplified below.
-
-The [`fix` option](../../../docs/user-guide/options.md#fix) can automatically fix all of the problems reported by this rule.
-
-## Options
-
-`string`: `"always"|"never"`
-
-### `"always"`
-
-There _must always_ be whitespace after the function.
-
-The following patterns are considered problems:
-
-
-```css
-a { transform: translate(1, 1)scale(3); }
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { transform: translate(1, 1) scale(3); }
-```
-
-
-```css
-a { transform: translate(1, 1) scale(3); }
-```
-
-
-```css
-a {
- transform:
- translate(1, 1)
- scale(3);
-}
-```
-
-
-```css
-/* notice the two closing parentheses without a space between */
-a { top: calc(1 * (1 + 3)); }
-```
-
-
-```css
-/* notice the ), with no space after the closing parenthesis */
-a { padding: calc(1 * 2px), calc(2 * 5px); }
-```
-
-### `"never"`
-
-There _must never_ be whitespace after the function.
-
-The following patterns are considered problems:
-
-
-```css
-a { transform: translate(1, 1) scale(3); }
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-a { transform: translate(1, 1)scale(3); }
-```
diff --git a/lib/rules/function-whitespace-after/__tests__/index.js b/lib/rules/function-whitespace-after/__tests__/index.js
deleted file mode 100644
index 5a42353a20..0000000000
--- a/lib/rules/function-whitespace-after/__tests__/index.js
+++ /dev/null
@@ -1,338 +0,0 @@
-'use strict';
-
-const { messages, ruleName } = require('..');
-
-testRule({
- ruleName,
- config: ['always'],
- fix: true,
-
- accept: [
- {
- code: 'a::before { content: "var(--hoot)color(blue)"; }',
- },
- {
- code: "a::before { background: url('var(--hoot)color(blue)'); }",
- },
- {
- code: 'a::before { content: attr(data-foo); }',
- },
- {
- code: 'a { transform: translate(1, 1); }',
- },
- {
- code: 'a { transform: translate(1, 1) }',
- },
- {
- code: 'a { transform: translate(1, 1)}',
- },
- {
- code: 'a { transform: translate(1, 1) scale(3); }',
- },
- {
- code: 'a { color: color(rgb(0,0,0) lightness(50%)) };',
- },
- {
- code: 'a { background-image: linear-gradient(#f3c, #4ec), linear-gradient(#f3c, #4ec); }',
- description: 'multiple comma-separated functions ',
- },
- {
- code: 'a { border-color: color(rgb(0,0,0) lightness(50%)) red pink orange; }',
- description: 'function within a function as one of multiple space-separated values',
- },
- {
- code: 'a { transform: translate(1, 1) scale(3); }',
- },
- {
- code: 'a { transform: translate(1, 1)\nscale(3); }',
- },
- {
- code: 'a { transform: translate(1, 1)\r\nscale(3); }',
- },
- {
- code: 'a { color: color(rgb(0,0,0) lightness(50%)) };',
- },
- {
- code: 'a { color: color(rgb(0,0,0)\nlightness(50%)) };',
- },
- {
- code: 'a { color: color(rgb(0,0,0)\r\nlightness(50%)) };',
- },
- {
- code: '@import url(example.css) screen;',
- },
- {
- code: '$list: (value, value2);$thingTwo: 0px',
- description: 'Sass list ignored',
- },
- {
- code: '.foo { $(x): calc(1px + 0px); }',
- description: 'postcss-simple-vars interpolation as property name',
- },
- {
- code: '.foo { border-$(x)-left: 10px; }',
- description: 'postcss-simple-vars interpolation within property name',
- },
- {
- code: '.foo { font: calc(16px + .2vw)/1 }',
- description: 'after calc in `font` property (line-height shorthand value)',
- },
- ],
-
- reject: [
- {
- code: 'a { transform: translate(1, 1)scale(3); }',
- fixed: 'a { transform: translate(1, 1) scale(3); }',
- message: messages.expected,
- line: 1,
- column: 31,
- },
- {
- code: 'a { color: color(rgb(0,0,0)lightness(50%)) };',
- fixed: 'a { color: color(rgb(0,0,0) lightness(50%)) };',
- message: messages.expected,
- line: 1,
- column: 28,
- },
- {
- code: '@import url(example.css)screen;',
- fixed: '@import url(example.css) screen;',
- message: messages.expected,
- line: 1,
- column: 25,
- },
- {
- code: 'a { transform: translateX(1)translateY(1)scale(3); }',
- fixed: 'a { transform: translateX(1) translateY(1) scale(3); }',
- warnings: [
- {
- message: messages.expected,
- line: 1,
- column: 29,
- },
- {
- message: messages.expected,
- line: 1,
- column: 42,
- },
- ],
- },
- {
- code: '@import url(example.css)scree/**/n;',
- fixed: '@import url(example.css) scree/**/n;',
- message: messages.expected,
- line: 1,
- column: 25,
- },
- {
- code: 'a { transform: translate(1/**/, 1)scale(3); }',
- fixed: 'a { transform: translate(1/**/, 1) scale(3); }',
- message: messages.expected,
- line: 1,
- column: 35,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['never'],
- fix: true,
-
- accept: [
- {
- code: 'a::before { content: "var(--hoot) color(blue)"; }',
- },
- {
- code: "a::before { background: url('var(--hoot) color(blue)'); }",
- },
- {
- code: 'a::before { content: attr(data-foo); }',
- },
- {
- code: 'a { transform: translate(1, 1); }',
- },
- {
- code: 'a { transform: translate(1, 1) }',
- },
- {
- code: 'a { transform: translate(1, 1)}',
- },
- {
- code: 'a { transform: translate(1, 1)scale(3); }',
- },
- {
- code: 'a { color: color(rgb(0,0,0)lightness(50%)) };',
- },
- {
- code: '.foo { font: calc(16px + .2vw)/1 }',
- description: 'after calc in `font` property (line-height shorthand value)',
- },
- ],
-
- reject: [
- {
- code: 'a { transform: translate(1, 1) scale(3); }',
- fixed: 'a { transform: translate(1, 1)scale(3); }',
- message: messages.rejected,
- line: 1,
- column: 31,
- },
- {
- code: 'a { transform: translate(1, 1) scale(3); }',
- fixed: 'a { transform: translate(1, 1)scale(3); }',
- message: messages.rejected,
- line: 1,
- column: 31,
- },
- {
- code: 'a { transform: translate(1, 1)\nscale(3); }',
- fixed: 'a { transform: translate(1, 1)scale(3); }',
- message: messages.rejected,
- line: 1,
- column: 31,
- },
- {
- code: 'a { transform: translate(1, 1)\r\nscale(3); }',
- fixed: 'a { transform: translate(1, 1)scale(3); }',
- description: 'CRLF',
- message: messages.rejected,
- line: 1,
- column: 31,
- },
- {
- code: 'a { color: color(rgb(0,0,0) lightness(50%)) };',
- fixed: 'a { color: color(rgb(0,0,0)lightness(50%)) };',
- message: messages.rejected,
- line: 1,
- column: 28,
- },
- {
- code: 'a { color: color(rgb(0,0,0) lightness(50%)) };',
- fixed: 'a { color: color(rgb(0,0,0)lightness(50%)) };',
- message: messages.rejected,
- line: 1,
- column: 28,
- },
- {
- code: 'a { color: color(rgb(0,0,0)\nlightness(50%)) };',
- fixed: 'a { color: color(rgb(0,0,0)lightness(50%)) };',
- message: messages.rejected,
- line: 1,
- column: 28,
- },
- {
- code: 'a { transform: translateX(1) translateY(1) scale(3); }',
- fixed: 'a { transform: translateX(1)translateY(1)scale(3); }',
- warnings: [
- {
- message: messages.rejected,
- line: 1,
- column: 29,
- },
- {
- message: messages.rejected,
- line: 1,
- column: 43,
- },
- ],
- },
- {
- code: 'a { transform: /**/ translateX(1) /**/ translateY(1) /**/ scale(3); }',
- fixed: 'a { transform: /**/ translateX(1)/**/ translateY(1)/**/ scale(3); }',
- warnings: [
- {
- message: messages.rejected,
- line: 1,
- column: 34,
- },
- {
- message: messages.rejected,
- line: 1,
- column: 53,
- },
- ],
- },
- {
- code: '@import url(example.css) screen;',
- fixed: '@import url(example.css)screen;',
- message: messages.rejected,
- line: 1,
- column: 25,
- },
- {
- code: '@import url(example.css) /**/ screen;',
- fixed: '@import url(example.css)/**/ screen;',
- message: messages.rejected,
- line: 1,
- column: 25,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['always'],
- customSyntax: 'postcss-scss',
- fix: true,
-
- accept: [
- {
- code: 'h1 { max-height: #{($line-height) * ($lines-to-show)}em; }',
- description: 'Sass-style interpolation with curly braces',
- },
- ],
-
- reject: [
- {
- code: 'a { padding:\n 10px\n /* comment one*/\n /* comment two*/\n var(--boo)orange}',
- fixed: 'a { padding:\n 10px\n /* comment one*/\n /* comment two*/\n var(--boo) orange}',
- message: messages.expected,
- line: 5,
- column: 13,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['always'],
- customSyntax: 'postcss-scss',
-
- reject: [
- {
- code: 'a { padding:\n 10px\n // comment one\n // comment two\n var(--boo)orange}',
- // can't fix on scss
- // fixed:
- // "a { padding:\n 10px\n // comment one\n // comment two\n var(--boo) orange}",
- message: messages.expected,
- line: 5,
- column: 13,
- },
- ],
-});
-
-testRule({
- ruleName,
- config: ['always'],
- customSyntax: 'postcss-less',
- fix: true,
-
- accept: [
- // temporarily disable this test until this is fully supported in stylelint
- // {
- // code: "h1 { max-height: ((@line-height) * (@lines-to-show))em; }",
- // description: "Less-style interpolation",
- // },
- ],
-
- reject: [
- {
- code: 'a { padding:\n 10px\n // comment one\n // comment two\n var(--boo)orange}',
- fixed: 'a { padding:\n 10px\n // comment one\n // comment two\n var(--boo) orange}',
- message: messages.expected,
- line: 5,
- column: 13,
- },
- ],
-});
diff --git a/lib/rules/function-whitespace-after/index.js b/lib/rules/function-whitespace-after/index.js
deleted file mode 100644
index 3e5e2aaa83..0000000000
--- a/lib/rules/function-whitespace-after/index.js
+++ /dev/null
@@ -1,194 +0,0 @@
-'use strict';
-
-const atRuleParamIndex = require('../../utils/atRuleParamIndex');
-const declarationValueIndex = require('../../utils/declarationValueIndex');
-const getDeclarationValue = require('../../utils/getDeclarationValue');
-const isWhitespace = require('../../utils/isWhitespace');
-const report = require('../../utils/report');
-const ruleMessages = require('../../utils/ruleMessages');
-const setDeclarationValue = require('../../utils/setDeclarationValue');
-const styleSearch = require('style-search');
-const validateOptions = require('../../utils/validateOptions');
-
-const ruleName = 'function-whitespace-after';
-
-const messages = ruleMessages(ruleName, {
- expected: 'Expected whitespace after ")"',
- rejected: 'Unexpected whitespace after ")"',
-});
-
-const meta = {
- url: 'https://stylelint.io/user-guide/rules/function-whitespace-after',
- fixable: true,
- deprecated: true,
-};
-
-const ACCEPTABLE_AFTER_CLOSING_PAREN = new Set([')', ',', '}', ':', '/', undefined]);
-
-/** @type {import('stylelint').Rule} */
-const rule = (primary, _secondaryOptions, context) => {
- return (root, result) => {
- const validOptions = validateOptions(result, ruleName, {
- actual: primary,
- possible: ['always', 'never'],
- });
-
- if (!validOptions) {
- return;
- }
-
- /**
- * @param {import('postcss').Node} node
- * @param {string} value
- * @param {number} nodeIndex
- * @param {((index: number) => void) | undefined} fix
- */
- function check(node, value, nodeIndex, fix) {
- styleSearch(
- {
- source: value,
- target: ')',
- functionArguments: 'only',
- },
- (match) => {
- checkClosingParen(value, match.startIndex + 1, node, nodeIndex, fix);
- },
- );
- }
-
- /**
- * @param {string} source
- * @param {number} index
- * @param {import('postcss').Node} node
- * @param {number} nodeIndex
- * @param {((index: number) => void) | undefined} fix
- */
- function checkClosingParen(source, index, node, nodeIndex, fix) {
- const nextChar = source.charAt(index);
-
- if (!nextChar) return;
-
- if (primary === 'always') {
- // Allow for the next character to be a single empty space,
- // another closing parenthesis, a comma, or the end of the value
- if (nextChar === ' ') {
- return;
- }
-
- if (nextChar === '\n') {
- return;
- }
-
- if (source.slice(index, index + 2) === '\r\n') {
- return;
- }
-
- if (ACCEPTABLE_AFTER_CLOSING_PAREN.has(nextChar)) {
- return;
- }
-
- if (fix) {
- fix(index);
-
- return;
- }
-
- report({
- message: messages.expected,
- node,
- index: nodeIndex + index,
- result,
- ruleName,
- });
- } else if (primary === 'never' && isWhitespace(nextChar)) {
- if (fix) {
- fix(index);
-
- return;
- }
-
- report({
- message: messages.rejected,
- node,
- index: nodeIndex + index,
- result,
- ruleName,
- });
- }
- }
-
- /**
- * @param {string} value
- */
- function createFixer(value) {
- let fixed = '';
- let lastIndex = 0;
- /** @type {(index: number) => void} */
- let applyFix;
-
- if (primary === 'always') {
- applyFix = (index) => {
- // eslint-disable-next-line prefer-template
- fixed += value.slice(lastIndex, index) + ' ';
- lastIndex = index;
- };
- } else if (primary === 'never') {
- applyFix = (index) => {
- let whitespaceEndIndex = index + 1;
-
- while (
- whitespaceEndIndex < value.length &&
- isWhitespace(value.charAt(whitespaceEndIndex))
- ) {
- whitespaceEndIndex++;
- }
-
- fixed += value.slice(lastIndex, index);
- lastIndex = whitespaceEndIndex;
- };
- } else {
- throw new Error(`Unexpected option: "${primary}"`);
- }
-
- return {
- applyFix,
- get hasFixed() {
- return Boolean(lastIndex);
- },
- get fixed() {
- return fixed + value.slice(lastIndex);
- },
- };
- }
-
- root.walkAtRules(/^import$/i, (atRule) => {
- const param = (atRule.raws.params && atRule.raws.params.raw) || atRule.params;
- const fixer = context.fix && createFixer(param);
-
- check(atRule, param, atRuleParamIndex(atRule), fixer ? fixer.applyFix : undefined);
-
- if (fixer && fixer.hasFixed) {
- if (atRule.raws.params) {
- atRule.raws.params.raw = fixer.fixed;
- } else {
- atRule.params = fixer.fixed;
- }
- }
- });
- root.walkDecls((decl) => {
- const value = getDeclarationValue(decl);
- const fixer = context.fix && createFixer(value);
-
- check(decl, value, declarationValueIndex(decl), fixer ? fixer.applyFix : undefined);
-
- if (fixer && fixer.hasFixed) {
- setDeclarationValue(decl, fixer.fixed);
- }
- });
- };
-};
-
-rule.ruleName = ruleName;
-rule.messages = messages;
-rule.meta = meta;
-module.exports = rule;
diff --git a/lib/rules/functionCommaSpaceChecker.js b/lib/rules/functionCommaSpaceChecker.js
deleted file mode 100644
index 1c004fa86b..0000000000
--- a/lib/rules/functionCommaSpaceChecker.js
+++ /dev/null
@@ -1,123 +0,0 @@
-'use strict';
-
-const declarationValueIndex = require('../utils/declarationValueIndex');
-const getDeclarationValue = require('../utils/getDeclarationValue');
-const isStandardSyntaxFunction = require('../utils/isStandardSyntaxFunction');
-const report = require('../utils/report');
-const setDeclarationValue = require('../utils/setDeclarationValue');
-const valueParser = require('postcss-value-parser');
-
-/** @typedef {import('postcss-value-parser').Node} ValueParserNode */
-/** @typedef {import('postcss-value-parser').DivNode} ValueParserDivNode */
-/** @typedef {(args: { source: string, index: number, err: (message: string) => void }) => void} LocationChecker */
-
-/**
- * @param {{
- * root: import('postcss').Root,
- * locationChecker: LocationChecker,
- * fix: ((node: ValueParserDivNode, index: number, nodes: ValueParserNode[]) => boolean) | null,
- * result: import('stylelint').PostcssResult,
- * checkedRuleName: string,
- * }} opts
- */
-module.exports = function functionCommaSpaceChecker(opts) {
- opts.root.walkDecls((decl) => {
- const declValue = getDeclarationValue(decl);
-
- let hasFixed;
- const parsedValue = valueParser(declValue);
-
- parsedValue.walk((valueNode) => {
- if (valueNode.type !== 'function') {
- return;
- }
-
- if (!isStandardSyntaxFunction(valueNode)) {
- return;
- }
-
- // Ignore `url()` arguments, which may contain data URIs or other funky stuff
- if (valueNode.value.toLowerCase() === 'url') {
- return;
- }
-
- const argumentStrings = valueNode.nodes.map((node) => valueParser.stringify(node));
-
- const functionArguments = (() => {
- // Remove function name and parens
- let result = valueNode.before + argumentStrings.join('') + valueNode.after;
-
- // 1. Remove comments including preceding whitespace (when only succeeded by whitespace)
- // 2. Remove all other comments, but leave adjacent whitespace intact
- // eslint-disable-next-line regexp/no-dupe-disjunctions -- TODO: Possible to simplify the regex.
- result = result.replace(/( *\/(\*.*\*\/(?!\S)|\/.*)|(\/(\*.*\*\/|\/.*)))/, '');
-
- return result;
- })();
-
- /**
- * Gets the index of the comma for checking.
- * @param {ValueParserDivNode} commaNode The comma node
- * @param {number} nodeIndex The index of the comma node
- * @returns {number} The index of the comma for checking
- */
- const getCommaCheckIndex = (commaNode, nodeIndex) => {
- let commaBefore =
- valueNode.before + argumentStrings.slice(0, nodeIndex).join('') + commaNode.before;
-
- // 1. Remove comments including preceding whitespace (when only succeeded by whitespace)
- // 2. Remove all other comments, but leave adjacent whitespace intact
- // eslint-disable-next-line regexp/no-dupe-disjunctions -- TODO: Possible to simplify the regex.
- commaBefore = commaBefore.replace(/( *\/(\*.*\*\/(?!\S)|\/.*)|(\/(\*.*\*\/|\/.*)))/, '');
-
- return commaBefore.length;
- };
-
- /** @type {{ commaNode: ValueParserDivNode, checkIndex: number, nodeIndex: number }[]} */
- const commaDataList = [];
-
- for (const [nodeIndex, node] of valueNode.nodes.entries()) {
- if (node.type !== 'div' || node.value !== ',') {
- continue;
- }
-
- const checkIndex = getCommaCheckIndex(node, nodeIndex);
-
- commaDataList.push({
- commaNode: node,
- checkIndex,
- nodeIndex,
- });
- }
-
- for (const { commaNode, checkIndex, nodeIndex } of commaDataList) {
- opts.locationChecker({
- source: functionArguments,
- index: checkIndex,
- err: (message) => {
- const index =
- declarationValueIndex(decl) + commaNode.sourceIndex + commaNode.before.length;
-
- if (opts.fix && opts.fix(commaNode, nodeIndex, valueNode.nodes)) {
- hasFixed = true;
-
- return;
- }
-
- report({
- index,
- message,
- node: decl,
- result: opts.result,
- ruleName: opts.checkedRuleName,
- });
- },
- });
- }
- });
-
- if (hasFixed) {
- setDeclarationValue(decl, parsedValue.toString());
- }
- });
-};
diff --git a/lib/rules/functionCommaSpaceFix.js b/lib/rules/functionCommaSpaceFix.js
deleted file mode 100644
index b4ad08c68a..0000000000
--- a/lib/rules/functionCommaSpaceFix.js
+++ /dev/null
@@ -1,49 +0,0 @@
-'use strict';
-
-/**
- * @param {{
- * div: import('postcss-value-parser').DivNode,
- * index: number,
- * nodes: import('postcss-value-parser').Node[],
- * expectation: string,
- * position: 'before' | 'after',
- * symb: string,
- * }} params
- * @returns {boolean}
- */
-module.exports = function functionCommaSpaceFix(params) {
- const { div, index, nodes, expectation, position, symb } = params;
-
- if (expectation.startsWith('always')) {
- div[position] = symb;
-
- return true;
- }
-
- if (expectation.startsWith('never')) {
- div[position] = '';
-
- for (let i = index + 1; i < nodes.length; i++) {
- const node = nodes[i];
-
- if (node === undefined) {
- continue;
- }
-
- if (node.type === 'comment') {
- continue;
- }
-
- if (node.type === 'space') {
- node.value = '';
- continue;
- }
-
- break;
- }
-
- return true;
- }
-
- return false;
-};
diff --git a/lib/rules/indentation/README.md b/lib/rules/indentation/README.md
deleted file mode 100644
index a954b14bbc..0000000000
--- a/lib/rules/indentation/README.md
+++ /dev/null
@@ -1,340 +0,0 @@
-# indentation
-
-> **Warning** This rule is deprecated and will be removed in the future. See [the migration guide](../../../docs/migration-guide/to-15.md).
-
-Specify indentation.
-
-
-```css
- |@media print {
- | a {
- | ↑ background-position: top left,
- | ↑ ↑ top right;
- | ↑}↑ ↑
- |}↑ ↑ ↑
-/** ↑ ↑ ↑
- * The indentation at these three points */
-```
-
-The [`fix` option](../../../docs/user-guide/options.md#fix) can automatically fix all of the problems reported by this rule.
-
-## Options
-
-`int|"tab"`, where `int` is the number of spaces
-
-### `2`
-
-Always indent at-rules, rules, comments, declarations, inside parentheses and multi-line values by 2 spaces.
-
-The following patterns are considered problems:
-
-
-```css
-@media print {
-a {
-background-position: top left,
-top right;
-}
-}
-```
-
-
-```css
-@media print {
-a {
- background-position: top left,
- top right;
- }
-}
-```
-
-
-```css
-@media print {
- a {
- background-position: top left,
- top right;
- }
-}
-```
-
-
-```css
-@media print {
- a,
- b {
- background-position: top left,
- top right;
- }
-}
-```
-
-
-```css
-a {
-/* blergh */
- color: pink;
-}
- /* blergh */
-```
-
-
-```css
-@media print,
-(-webkit-min-device-pixel-ratio: 1.25),
-(min-resolution: 120dpi) {}
-```
-
-
-```css
-a {
- color: rgb(
- 255,
- 255,
- 255
- );
- top: 0;
-}
-```
-
-The following patterns are _not_ considered problems:
-
-
-```css
-@media print {
- a {
- background-position: top left,
- top right;
- }
-}
-```
-
-
-```css
-@media print {
- a,
- b {
- background-position: top left,
- top right;
- }
-}
-```
-
-
-```css
-a {
- /* blergh */
- color: pink;
-}
-/* blergh */
-```
-
-
-```css
-@media print,
- (-webkit-min-device-pixel-ratio: 1.25),
- (min-resolution: 120dpi) {}
-```
-
-
-```css
-a {
- color: rgb(
- 255,
- 255,
- 255
- );
- top: 0;
-}
-```
-
-## Optional secondary options
-
-### `baseIndentLevel: int|"auto"`
-
-By default, the indent level of the CSS code block in non-CSS-like files is determined by the shortest indent of non-empty line. The setting `baseIndentLevel` allows you to define a relative indent level based on CSS code block opening or closing line.
-
-For example, with `[ 2, { baseIndentLevel: 1 } ]`, CSS should be indented 1 levels higher than `
-
-