question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

vscode-stylelint throws an using this as a plugin

See original GitHub issue

Firstly, I’m not sure if this is an issue with the vscode plugin or with stylelint-config-rational-order but I needed to start somewhere.

When I enable this by extending the stylelint config it works perfectly.

{
  "extends": [
    "stylelint-config-rational-order"
  ]
}

However if I enable it as a plugin and rule the vscode plugin throws an error about severity, see the below error.

{
  "plugins": [
    "stylelint-config-rational-order/plugin"
  ],
  "rules": {
    "plugin/rational-order": true
    // OR (both break)
    // "plugin/rational-order": [true, {
    //   "border-in-box-model": false,
    //   "empty-line-between-groups": false,
    // }]
  }
}
Error: `severity` property of a stylelint warning must be either 'error' or 'warning', but it was 'ignore' (string). at stylelintWarningToVscodeDiagnostic (/Users/ben/.vscode/extensions/shinnn.stylelint-0.48.0/node_modules/stylelint-warning-to-vscode-diagnostic/index.js:40:9) at Array.map (<anonymous>) at processResults (/Users/ben/.vscode/extensions/shinnn.stylelint-0.48.0/node_modules/stylelint-vscode/index.js:59:18) at stylelintVSCode (/Users/ben/.vscode/extensions/shinnn.stylelint-0.48.0/node_modules/stylelint-vscode/index.js:144:9)

I tried adding the severity option but the error is still throw. "plugin/rational-order": [true, { "severity": "warning" } ]

Any ideas where this problem exists or how to fix it?

BTW I love this project, thank you 😃

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

8reactions
constverumcommented, Apr 18, 2019

Ben, thank you for paying attention to this wrong behavior! My mistake =) The documentation was fixed. So to fix the error just follow the steps:

  1. add to dependencies all required packages: npm install --save-dev stylelint stylelint-order stylelint-config-rational-order
  2. add stylelint-order to plugins
  3. add "order/properties-order": [] to rules

That’s all =)

My actual project .stylelintrc is:

So it will look:

{
  "extends": [
    "stylelint-config-recommended",
    "stylelint-config-styled-components",
    "stylelint-config-rational-order",
    "stylelint-config-prettier"
  ],
  "plugins": [
    "stylelint-order",
    "stylelint-config-rational-order/plugin"
  ],
  "rules": {
    "order/properties-order": [],
    "plugin/rational-order": [true, {
      "border-in-box-model": true,
      "empty-line-between-groups": true,
    }]
  }
}

or (also will work):

{
  "extends": [
    "stylelint-config-recommended",
    "stylelint-config-styled-components",
    // "stylelint-config-rational-order",     <==== removed
    "stylelint-config-prettier"
  ],
  "plugins": [
    "stylelint-order",
    "stylelint-config-rational-order/plugin"
  ],
  "rules": {
    "order/properties-order": [],
    "plugin/rational-order": [true, {
      "border-in-box-model": true,
      "empty-line-between-groups": true,
    }]
  }
}
0reactions
davidjaldredcommented, May 3, 2019

If there are 11 or more rules, not placing "order/properties-order": [], first seems to still produce this error.

This .stylelintrc will show the ‘severity’ error:

{
  "plugins": ["stylelint-order", "stylelint-config-rational-order/plugin"],
  "rules": {
    "at-rule-name-case": "lower",
    "at-rule-name-newline-after": "always-multi-line",
    "at-rule-name-space-after": "always",
    "at-rule-no-unknown": true,
    "at-rule-no-vendor-prefix": true,
    "at-rule-semicolon-newline-after": "always",
    "at-rule-semicolon-space-before": "never",
    "block-closing-brace-empty-line-before": "never",
    "block-closing-brace-newline-after": "always",
    "order/properties-order": [],
    "plugin/rational-order": [
      true,
      {
        "border-in-box-model": true,
        "empty-line-between-groups": false
      }
    ]
  }
}

This .stylelintrc works fine ("order/properties-order": [], is first):

{
  "plugins": ["stylelint-order", "stylelint-config-rational-order/plugin"],
  "rules": {
    "order/properties-order": [],
    "at-rule-name-case": "lower",
    "at-rule-name-newline-after": "always-multi-line",
    "at-rule-name-space-after": "always",
    "at-rule-no-unknown": true,
    "at-rule-no-vendor-prefix": true,
    "at-rule-semicolon-newline-after": "always",
    "at-rule-semicolon-space-before": "never",
    "block-closing-brace-empty-line-before": "never",
    "block-closing-brace-newline-after": "always",
    "plugin/rational-order": [
      true,
      {
        "border-in-box-model": true,
        "empty-line-between-groups": false
      }
    ]
  }
}

This .stylelintrc also works fine (only 10 rules):

{
  "plugins": ["stylelint-order", "stylelint-config-rational-order/plugin"],
  "rules": {
    "at-rule-name-case": "lower",
    "at-rule-name-newline-after": "always-multi-line",
    "at-rule-name-space-after": "always",
    "at-rule-no-unknown": true,
    "at-rule-no-vendor-prefix": true,
    "at-rule-semicolon-newline-after": "always",
    "at-rule-semicolon-space-before": "never",
    "block-closing-brace-empty-line-before": "never",
    "order/properties-order": [],
    "plugin/rational-order": [
      true,
      {
        "border-in-box-model": true,
        "empty-line-between-groups": false
      }
    ]
  }
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

vscode-stylelint - Visual Studio Marketplace
This extension provides an action that you can use with VS Code's editor.codeActionsOnSave setting. If provided a source.fixAll.stylelint ...
Read more >
Options - Stylelint
... PostCSS plugin. You can use some of these options in the configuration object. ... Stylelint does not throw an error when glob...
Read more >
Can't get VS Code Stylelint extension to lint in .ts files
I've already opened an issue in the VS Code Github repo but it got closed immediately. The extension itself has disabled the possibility...
Read more >
Atom Integration with Prettier and Stylelint. | by Mark Kiptubei
... eslint and stylelint with VSCode a popular editor from Microsoft . ... Atom relies extensively on npm for its plugins so its...
Read more >
Tooling - styled-components
If you do not use this plugin and try to server-side render ... When using this processor a couple of stylelint rules throw...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found