Skip Navigation

Scott Spence

Stylelint Configuration for use with Tailwind CSS

• 1 min read

1 person viewing this page live

Read to the end of the post for more stats

Hey! Thanks for stopping by! Just a word of warning, this post is over 2 years old, . If there's technical information in here it's more than likely out of date.

When using Tailwind CSS in a Toast project I got a CSS warning semi-colon expected css(css-semicolonexpected) when trying to use the Tailwind @apply directive.

A quick Google gave me a stackoverflow result for using it in Vue but the solution worked the same in Toast with one last configuration needed.

Add stylelint dependencies:

npm install --save-dev stylelint stylelint-config-standard

Create a stylelint config in stylelint.config.js in the root of the project:

module.exports = {
  extends: ['stylelint-config-standard'],
  rules: {
    'at-rule-no-unknown': [
      true,
      {
        ignoreAtRules: [
          'tailwind',
          'apply',
          'variants',
          'responsive',
          'screen',
        ],
      },
    ],
    'declaration-block-trailing-semicolon': null,
    'no-descending-specificity': null,
  },
}

Install VS Code extensions:

Add the following to a VS Code settings file:

"css.validate": false,
"less.validate": false,
"scss.validate": false,

If there’s not a file already add it with:

mkdir .vscode
touch .vscode/settings.json

Note using in Toast

With styling and using stylelint in Toast, rather than use the recommended stylelint.config.js use .stylelintrc and add in the configuration as a JSON object or add it directly to the package.json file.

{
  "name": "project-using-stylelint",
  "scripts": {},
  "dependencies": {},
  "devDependencies": {},
  "stylelint": {
    "extends": ["stylelint-config-standard"],
    "rules": {
      "at-rule-no-unknown": [
        true,
        {
          "ignoreAtRules": [
            "tailwind",
            "apply",
            "variants",
            "responsive",
            "screen"
          ]
        }
      ],
      "declaration-block-trailing-semicolon": null,
      "no-descending-specificity": null
    }
  }
}

With the module.exports syntax Toast will derp, see the SO question for configuration: How to solve semi-colon expected css(css-semicolonexpected)

There's a reactions leaderboard you can check out too.

Analytics Information

Daily analytics for this post

Views Today
10
Dec 3, 2023 3:40 AM
Visitors Today
9
Dec 3, 2023 3:40 AM
Entries Today
10
Dec 3, 2023 3:40 AM

Monthly analytics for this post

Views This Month
283
Dec 1, 2023 - Dec 3, 2023
Visitors This Month
187
Dec 1, 2023 - Dec 3, 2023
Entries This Month
195
Dec 1, 2023 - Dec 3, 2023

Yearly analytics for this post

Views This Year
5.5k
Jan 1, 2023 - Dec 3, 2023
Visitors This Year
3.1k
Jan 1, 2023 - Dec 3, 2023
Entries This Year
3.2k
Jan 1, 2023 - Dec 3, 2023

Copyright © 2017 - 2023 - All rights reserved Scott Spence