Giter Club home page Giter Club logo

stylelint-config-standard's Introduction

stylelint-config-standard

NPM version Build Status

The standard shareable config for Stylelint.

It extends stylelint-config-recommended and turns on additional rules to enforce modern conventions found in the CSS specifications.

To see the rules that this config uses, please read the config itself.

Example

@import url("foo.css");
@import url("bar.css");

@custom-media --foo (min-width: 30em);

/**
 * Multi-line comment
 */

:root {
  --brand-red: hsl(5deg 10% 40%);
}

/* Single-line comment */

.class-foo:not(a, div) {
  margin: 0;
  top: calc(100% - 2rem);
}

/* Flush single line comment */
@media (width >= 60em) {
  #id-bar {
    /* Flush to parent comment */
    --offset: 0px;

    color: #fff;
    font-family: Helvetica, "Arial Black", sans-serif;
    left: calc(var(--offset) + 50%);
  }

  /* Flush nested single line comment */
  a::after {
    display: block;
    content: "→";
    background-image: url("x.svg");
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

Note: the config is tested against this example, as such the example contains plenty of CSS syntax and features.

Installation

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

Usage

Set your Stylelint config to:

{
  "extends": "stylelint-config-standard"
}

Extending the config

Add a "rules" key to your config, then add your overrides and additions there.

You can turn off rules by setting its value to null. For example:

{
  "extends": "stylelint-config-standard",
  "rules": {
    "selector-class-pattern": null
  }
}

Or lower the severity of a rule to a warning using the severity secondary option. For example:

{
  "extends": "stylelint-config-standard",
  "rules": {
    "property-no-vendor-prefix": [
      true,
      {
        "severity": "warning"
      }
    ]
  }
}

Or to add a rule, For example, the unit-allowed-list one:

{
  "extends": "stylelint-config-standard",
  "rules": {
    "unit-allowed-list": ["em", "rem", "s"]
  }
}

We recommend adding more of Stylelint's rules to your config as these rules need to be configured to suit your specific needs.

stylelint-config-standard's People

Contributors

amilajack avatar arcanemagus avatar coliff avatar danielbayerlein avatar davidtheclark avatar dependabot-preview[bot] avatar dependabot[bot] avatar ezhlobo avatar greenkeeper[bot] avatar hudochenkov avatar jeddy3 avatar karlhorky avatar m-allanson avatar mattxwang avatar mouvedia avatar ntwb avatar ota-meshi avatar steffenweber avatar ybiquitous avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

stylelint-config-standard's Issues

Consider add the rule 'property-no-unknown'

It would be good to add the "property-no-unknown": true , in order to check properties defined in the CSS Specifications and browser specific properties to be known. I think this rule is basic.

Now without that rule you will not have errors with the following css:

.myClass {
   colr: #fff;
   bakgroun: #fff;
   pepe: #fff;
}

What do you think?

An in-range update of eslint-config-stylelint is breaking the build 🚨

The devDependency eslint-config-stylelint was updated from 8.2.0 to 8.3.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

eslint-config-stylelint is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Release Notes for 8.3.0
  • Changed: eslint-plugin-jest rules to error
Commits

The new version differs by 3 commits.

  • 76293bf Prepare 8.3.0
  • c579256 Update CHANGELOG.md
  • c4a2e71 Switch eslint-plugin-jest rules from warn to error (#54)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

at-rule-empty-line-before should ignore else

at-rule-empty-line-before currently only ignores after-comment. It should also ignore else blocks.

The below is considered an error, and it shouldn't be. I have never seen if / else blocks separated by newlines.

@if (...) {
  ...
}
@else (...) {

}

block-no-empty rule

I would expect block-no-empty: true to be in there. @jeddy3, Did you consider that rule controversial in some way?

Is it good to set `number-leading-zero` to ["never"]?

Read common rules listed in README for leading zero and here are what I find:

Personally I like non leading zero more as it's neater.

List rules that are *NOT* included

I think it would be helpful to me and other consumers of this module to have an up-to-date list of all the stylelint rules that are not included in this config. That way I know which ones I need to think about configuring on my own.

Add value-keyword-case

Clearly describe the bug

It seems to me that value-keyword-case is probably missing in stylelint-config-standard. It is not called out in the readme as not included, and all of the other *-case options are included and set to lower.

Which rule, if any, is the bug related to?

value-keyword-case

What CSS is needed to reproduce the bug?

What stylelint configuration is needed to reproduce the bug?

Which version of stylelint are you using?

How are you running stylelint: CLI, PostCSS plugin, Node.js API?

Does the bug relate to non-standard syntax (e.g. SCSS, Less etc.)?

What did you expect to happen?

I expect value-keyword-case to be included in stylelint-config-standard for consistency.

What actually happened (e.g. what warnings or errors did you get)?

value-keyword-case is not included in stylelint-config-standard.

Error: Undefined rule font-family-no-missing-generic-family-keyword

Command
$ stylelint --formatter 'verbose' 'public/**/*.css' 'src/**/*.css'

Error

Error: Undefined rule font-family-no-missing-generic-family-keyword
    at module.exports (/usr/local/lib/node_modules/stylelint/lib/utils/configurationError.js:8:28)
    at Object.keys.forEach.ruleName (/usr/local/lib/node_modules/stylelint/lib/augmentConfig.js:302:13)
    at Array.forEach (native)
    at normalizeAllRuleSettings (/usr/local/lib/node_modules/stylelint/lib/augmentConfig.js:297:29)
    at augmentConfigBasic.then.then.then.augmentedConfig (/usr/local/lib/node_modules/stylelint/lib/augmentConfig.js:91:14)

Versions

  • "angular/cli": "^1.5.5",
  • "angular/cdk": "5.0.1",
  • "angular/compiler-cli": "^5.0.4",
  • "stylelint": "^8.3.1",
  • "stylelint-config-standard": "^18.0.0",

Trouble with auto format scss

My code before saving:

screen1

Code after saving:

screen shot 2018-10-31 at 5 52 56 pm

How I can leave my code without changes in similar situations?
P.S. The same problem with line:

screen shot 2018-10-31 at 6 01 42 pm

'Expected "dummyValue" to be "dummyvalue"' error after update to 20.0.0

Clearly describe the bug

After updating to v20.0.0 the following error is thrown multiple times. All styling is done with styled-components
It seems that the error appears when i check component props or use styling from a variable (please see example below)

14:37  ✖  Expected "dummyValue" to be "dummyvalue"   value-keyword-case
29:19  ✖  Expected "dummyValue" to be "dummyvalue"   value-keyword-case

Which rule, if any, is the bug related to?

value-keyword-case

What CSS is needed to reproduce the bug?

14  ${props => props.icon && css`
15    align-items: center;
16    display: inline-flex;
17    line-height: 1;
18    vertical-align: middle;
19  `}
28  const ExternalLink = styled.a`
29    ${linkStyling}
30  `

What configuration is needed to reproduce the bug?

{
  "processors": ["stylelint-processor-styled-components"],
  "plugins": [
    "stylelint-order"
  ],
  "extends": [
    "stylelint-config-standard",
    "stylelint-config-styled-components"
  ],
  "rules": {
    "order/properties-alphabetical-order": true
  }
}

Which version of stylelint are you using?

20.0.0

How are you running stylelint: CLI, PostCSS plugin, Node.js API?

cross-env stylelint 'src/**/*.js

Does the bug relate to non-standard syntax (e.g. SCSS, Less etc.)?

styled-components

What did you expect to happen?

No warnings to be flagged.

What actually happened (e.g. what warnings or errors did you get)?

The following warnings were flagged:

14:37  ✖  Expected "dummyValue" to be "dummyvalue"   value-keyword-case
29:19  ✖  Expected "dummyValue" to be "dummyvalue"   value-keyword-case

Fix maximum range on peerDependency

Describe the issue. Is it a bug or a feature request (new rule, new option, etc.)?

The current peerDependency definition has no maximum to the allowed range, allowing some potential future version of stylelint that isn't actually compatible to be "compatible" but broken.

"peerDependencies": {
"stylelint": ">=10.1.0"
},

Which rule, if any, is this issue related to?

N/A

What CSS is needed to reproduce this issue?

N/A

What stylelint configuration is needed to reproduce this issue?

N/A

Which version of stylelint are you using?

N/A

How are you running stylelint: CLI, PostCSS plugin, Node API?

N/A

Does your issue relate to non-standard syntax (e.g. SCSS, nesting, etc.)?

N/A

What did you expect to happen?

A maximum range to be specified preventing future incompatible versions from being used.

What actually happened (e.g. what warnings or errors you are getting)?

No maximum range is specified.

Unknown rule named-grid-areas-no-invalid

Clearly describe the bug

Unknown rule named-grid-areas-no-invalid

What steps are needed to reproduce the bug?

  1. Update to stylelint 13.12.0, update stylelint-config-standard to 21.0.0
  2. See stylelint complain about unknown rule.

What did you expect to happen?

For stylelint to be aware of the new rule

What actually happened (e.g. what warnings or errors did you get)?

An error in the IDE saying it doesn't know about the rule

Additional information:

If I comment out the extends - stylelint-config-standard stylelint stops complaining about the issue.

All rules have default "error" severity

Feature request:

I think it would be great if the default configuration could specify a severity for each rule, instead of just setting "error" for all of them.

Not all rules are errors, some are minor warning (like the maximum number of blank spaces). In my opinion, the default configuration should have a severity set intelligently for each rule.

This would probably be trivial to implement by adding an extra configuration option for each rule.

Turn stylelint-config-standard into an actual standard

It favours flexibility over strictness for things like multi-line lists and single-line rulesets, and tries to avoid potentially divisive rules.

Is fine and all, but it's not a standard.

Flexible != Standard

You should rename this repo to stylelint-config-flexible and create an actual standard.

That's kind of the whole point behind linting anything to enforce strict rules for code quality.

Please take a page out of https://github.com/feross/standard handbook and become the one standard to rule them all.

Prettier conflicts with block-closing-backtick-space-before rule

When using prettier with styled-components

const Outer = styled.div`
    text-align: center;
`;

gets converted into

const Outer = styled.div`text-align: center;`;

and this construct violates block-closing-backtick-space-before rule

Expected single space after "{" of a single-line block (block-opening-backtick-space-after)
Expected single space before "}" of a single-line block (block-closing-backtick-space-before)

Given the prettier becomes more and more popular, I would like to see block-opening-backtick-space-after and block-closing-backtick-space-before rules loosened a bit, so that the changes by prettier don't violate it.

`selector-class-pattern` pattern does not allow for BEM selector names

What steps are needed to reproduce the bug?

Use classes such as these from the AirBnB style guide:

.ListingCard { }
.ListingCard--featured { }
.ListingCard__title { }
.ListingCard__content { }

What did you expect to happen?

These selectors should not report any issues with the selector-class-pattern rule.

What actually happened?

Output:

Expected class selector to be kebab-case  selector-class-pattern

It appears the pattern only allows for single dashes as separators.

Usage example doesn't work.

I have a .stylelintrc like this:
https://github.com/stylelint/stylelint-config-standard#usage

$ stylelint /home/user/path/css/*.css
Error: Could not find "stylelint-config-standard". Do you need a `configBasedir`?
    at exports.default (/usr/local/lib/node_modules/stylelint/dist/utils/configurationError.js:8:13)
    at getModulePath (/usr/local/lib/node_modules/stylelint/dist/buildConfig.js:120:39)
    at loadExtendedConfig (/usr/local/lib/node_modules/stylelint/dist/buildConfig.js:93:22)
    at /usr/local/lib/node_modules/stylelint/dist/buildConfig.js:82:14

Rule ordering?

No opinion about this? Is this considered a divisive rule?

Can rule order affect anything?

update stylelint-config-recommended to support stylelint 9

Hi
I see that you've updated to support stylelint 9, but still requires a dependency on stylelint-config-recommended 2.0.0, which has a dependency on stylelint < 8.
Should update dependency to stylelint-config-recommended 2.1.0

Thanks.

at-rule-no-unknown

FYI: With the new at-rule-no-unknown things like @include or @mixin are considered errors in SCSS.

Undefined rule "block-closing-brace-empty-line-before"

Seems like a dependency is missing:

Error: Undefined rule "block-closing-brace-empty-line-before"
    at exports.default (/usr/local/lib/node_modules/stylelint/dist/utils/configurationError.js:8:13)
    at /usr/local/lib/node_modules/stylelint/dist/postcssPlugin.js:113:47
    at Array.forEach (native)
    at /usr/local/lib/node_modules/stylelint/dist/postcssPlugin.js:111:33

Version 10 of node.js has been released

Version 10 of Node.js (code name Dubnium) has been released! 🎊

To see what happens to your code in Node.js 10, Greenkeeper has created a branch with the following changes:

  • Added the new Node.js version to your .travis.yml

If you’re interested in upgrading this repo to Node.js 10, you can open a PR with these changes. Please note that this issue is just intended as a friendly reminder and the PR as a possible starting point for getting your code running on Node.js 10.

More information on this issue

Greenkeeper has checked the engines key in any package.json file, the .nvmrc file, and the .travis.yml file, if present.

  • engines was only updated if it defined a single version, not a range.
  • .nvmrc was updated to Node.js 10
  • .travis.yml was only changed if there was a root-level node_js that didn’t already include Node.js 10, such as node or lts/*. In this case, the new version was appended to the list. We didn’t touch job or matrix configurations because these tend to be quite specific and complex, and it’s difficult to infer what the intentions were.

For many simpler .travis.yml configurations, this PR should suffice as-is, but depending on what you’re doing it may require additional work or may not be applicable at all. We’re also aware that you may have good reasons to not update to Node.js 10, which is why this was sent as an issue and not a pull request. Feel free to delete it without comment, I’m a humble robot and won’t feel rejected 🤖


FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

List compatible stylelint versions as a peerDependency

Can the package.json be expanded to list the compatible versions of stylelint as a peerDependency? Currently this is only listed as a devDependency, which is correct as that isused for testing, but when something lists this package as a dependency there is no way to know what versions it will work with.

No value for selector-list-comma-space-after

What is the problem you're trying to solve?

selector-list-comma-space-after is the only *-comma-space-after rule not present. I'm not sure if this is for some reason I'm not aware of, but it seems odd to be missing when all other *-comma-space-after, *-comma-space-before, and *-comma-newline-after permutations seem to be present.

What solution would you like to see?

Rule Added Commit
"selector-list-comma-space-after": "always-single-line", https://github.com/dylanzt/stylelint-config-standard/commit/bdf6198518b854723c13a4d370c56546b2ee8b1d

Use standard config as default?

How about having the setting 'Use standard' checked by default and 'Disable when no config file is found' unchecked by default?

This is to ensure that it works 'out of the box' and the users can then apply their own config file if they feel the need for it.

Switch to enforcing single quotes

Single quotes are a better for three main reasons:

  1. Consistency with the most popular PHP and JS style guides (see eslint-config-standard).
  2. Easier to type (no shift key press). This allows faster typing and reduces the risk of RSI.
  3. Visually less noise. Single quotes are a simpler symbol and are cleaner to look at.

Rules to tweak:

  • font-family-name-quotes
  • function-url-quotes
  • string-quotes

Remove declaration-block-trailing-semicolon?

So the config works out-of-the-box with SugarSS.

Looking back through the styleguides it seems some enforce the optional semi, most don't mention it and one suggests not adding it.

I'm happy to remove this one stylistic rule if it means out-of-the-box support for another syntax. Especially as we've been adding "catch subtle coding mistakes" rules to the config recently.

Ref: stylelint/stylelint#978 (comment)

If we decide to do this, then I suggest we roll this change in with the pending PR to remove the quote rules. And release them together.

@davidtheclark Thoughts?

Why `number-leading-zero` rule is set as `always`?

Readme says:

It is derived from the common rules found within a handful of CSS styleguides, including:

But Google's CSS Style Guide and @mdo's Code Guide says:

Omit leading “0”s in values.
Do not use put 0s in front of values or lengths between -1 and 1.
font-size: .8em;

Don't prefix property values or color parameters with a leading zero (e.g., .5 instead of 0.5 and -.5px instead of -0.5px).

Github's PrimerCSS Guidelines just do not use leading zero in examples

And other guides do not mention the leading zero.

So, maybe change number-leading-zero rule to never or at least to null?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.