Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@spaced-out/postcss-flexbugs-strict

spaced-out84MIT1.0.2

PostCSS plugin that tries to enforce unambiguous flexbox declarations

postcss, css, postcss-plugin, flexbugs, flexbox, flex

readme

PostCSS Flexbugs Strict

PostCSS plugin This project tries to encourage less ambiguous Flexbox CSS while fixing some of flexbug's issues.

Explanation

This started as a fork of postcss-flexbugs-fixes because I was not happy with some of the changes it made to support shorthand flex declarations. This is not the fault of that plugin (which is great!); it is an issue with the goal of supporting ambiguous declarations in browsers like IE and Safari. See https://github.com/luisrudge/postcss-flexbugs-fixes/issues/59

My solution was to change the goal. Instead of supporting declarations like flex: 100% 0; and flex: 1, we force users to declare all three values explicitly. Furthermore, we do not automatically translate any values from one unit to another. We force users to specify a unit that is compatible with all target browsers.

In my experience, most developers have no idea what the defaults of flex are let alone what flex: 1; means, and flex: 1 1 auto; is actually not much more code. It forces developers to think about exactly what they want.

Strict Behavior

flex declarations must contain 3 values.

Okay

.foo { flex: 1 0 0%; }

Bad

.foo { flex: 1; }

The grow and shrink values must be unit-less.

Bad

.foo { flex: 100% 1 0%; }

The basis value must have a unit, and cannot be 0px.

Bad

.foo { flex: 1 1 0px; }

Also bad

.foo { flex: 1 0 0; }

Translations

The calc check for flex-basis is benign so we still do it.

bug 8.1.a

Input

.foo { flex: 1 0 calc(1vw - 1px); }

Output

.foo {
  flex-grow: 1;
  flex-shrink: 0;
  flex-basis: calc(1vw - 1px);
}

Usage

postcss([require('@spaced-out/postcss-flexbugs-strict')]);

See PostCSS docs for examples for your environment.

changelog

4.2.0

  • Don't change values that reference custom props #64

4.1.0

  • Add option to disable bug fixes #53

4.0.0

  • upgrade to postcss 7

3.3.1

  • Autoremoval of 0% Basis #46. More context here

3.3.0

  • Revert Autoremoval of 0% Basis #43

3.2.0

  • Set flex basis if second value is not a number #41

3.1.0

  • Fix safari issues with flex-basis #38

3.0.0

  • upgrade to postcss 6

2.1.0

  • Prevent mutating value when flex value is one of ['none', 'auto', 'content', 'inherit', 'initial', 'unset']

2.0.0

  • upgrade to postcss 5

1.1.0

  • Ignore flex set to none #24
  • The default value of flex-basis is 0% #22

1.0

  • Initial release