Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
stylelint-config-skyscanner
Advanced tools
Skyscanner's stylelint config.
This stylelint config is based on stylelint-config-standard
with Skyscanner specific additions and is meant to be used with Backpack and backpack-react-scripts
. Rules encourage developers to leverage the Backpack design system and to outsource development dependencies to backpack-react-scripts
.
npm install --save-dev stylelint-config-skyscanner
Add "extends": "stylelint-config-skyscanner"
to your .stylelintrc
.
Don't prefix your CSS, write standards compliant code and let autoprefixer
automatically make it cross-browser compatible. Even better, autoprefixer
and a config aligned to current browser usage comes bundled with backpack-react-scripts
so you don't have to worry about it.
Rules: value-no-vendor-prefix
, at-rule-no-vendor-prefix
, media-feature-name-no-vendor-prefix
, property-no-vendor-prefix
, selector-no-vendor-prefix
CSS is global by default. Whenever you write a CSS selector and expose it on a page, it's immediately in competition with every other selector on that page. This means that every selector has the potential to have unintended side effects by targeting unwanted elements or clashing with other selectors already defined.
Use CSS modules to avoid conflicts between your selectors and any others on the page. CSS module supports comes with backpack-react-scripts
.
Avoid using top level universal selectors (*
). You will most likely be sharing the page with other components, and it will cause interference.
Never use top level type selectors. You will most likely be sharing the page with other components, and it will cause interference.
Rule: selector-max-type
Never use ids. The high specificity of ids can cause unexpected interactions between styles. Leave ids only for JavaScript bindings (e.g. React root elements).
Rule: selector-max-id
Class names should be in the Block Element Modifier (BEM) style. BEM makes CSS easier to maintain and reason about as it makes clear what the connection between styles and HTML is. It also encourages a compositional approach to writing modifiers.
Rule: selector-class-pattern
([A-Z][a-zA-Z0-9]+)
([a-z][a-z0-9]*(-[a-z0-9]+)*)
([a-z]+([A-Z][a-z0-9]+)*)
`(${pascalCase}|${kebabCase})` + // block
`(__(${camelCase}|${kebabCase}))?` + // element
`(--(${camelCase}|${kebabCase}))?$`, // modifier
_?${kebabCase}(__${kebabCase})?(--${kebabCase}?)?-?
Do not use more than two levels of compound selectors. SCSS nesting can make the structure of CSS harder to understand and change. Targeting specific elements can be done using BEM and CSS modules without requiring nesting. Leave nesting for situation where parent element changes affect their children (e.g. hovering a button changes the colour of an icon inside it).
Rule: selector-max-compound-selectors
Do not use !important
. It can cause unforeseen issues down the line as it breaks the cascading model of CSS. If you find yourself in a situation where !important
seems like a solution, it is probably a code smell. Try and refactor your code to avoid it instead.
Rule: declaration-no-important
Keep all styles pertaining to an element in one place. Media queries, RTL styles, pseudo-classes, and pseudo-elements should all live inside the SCSS class that targets the element. This way all the element's behaviour is easily understood by looking in one place. The order of rules is predicated on how they are likely to be overwritten.
The order of properties is in accordance to how much they affect the element. Consistent ordering and grouping is very important to quickly find properties, especially related properties like those that affect flex or grid behaviour.
Put properties above mixins, this will help you avoid inadvertently overriding properties from mixins and make you have to explicitly disable the ordering rule if you have to do it. Overriding too many rules from a mixin should make you question if that mixin is too specific or if it needs to be included. Avoid overriding Backpack mixins for a consistent UI across components.
Put mixins without a body above mixins with a body. The rules inside mixins with bodies may overwrite those included via bodyless mixins.
Nest @media
rules inside the block they modify to keep all styles that affect an element together. Keep @media
rules at the bottom of the page as inside them all other rules may be overwritten.
Use mixins whenever a media rule repeats itself for easier maintenance. Use the media query mixins in Backpack whenever possible.
Only use quotes where required: data URIs, import statements, and font names that contain white space, digits or punctuation characters other than hyphens. Use single quotes to align to the preferred usage in JavaScript (ESLint config).
Rules: string-quotes
, selector-attribute-quotes
, font-family-name-quotes
Avoid using px
values, use rem
for better scaling.
Avoid declaring your own font-size
and line-height
, use bpk-text-<size>
mixins from Backpack instead.
Avoid declaring your own colours, use bpk-color-<color>
SCSS variables from Backpack instead.
Rules: unit-disallowed-list
, scale-unlimited/declaration-strict-value
3.0.0 - Rule update and new linter updates.
unit-blacklist
with unit-disallowed-list
. unit-blacklist
was deprecated in stylelint v13.7.0.stylelint-plugin-backpack
to 1.1.0
backpack/use-colors
and backpack/use-tokens
ruleseslint-config-skyscanner
to 8.0.0
FAQs
Skyscanner's stylelint config.
The npm package stylelint-config-skyscanner receives a total of 8 weekly downloads. As such, stylelint-config-skyscanner popularity was classified as not popular.
We found that stylelint-config-skyscanner demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 9 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.