Giter Club home page Giter Club logo

css-declaration-sorter's Introduction

CSS declaration sorter logo

CSS Declaration Sorter

npm

A Node.js module and PostCSS plugin to sort CSS, SCSS or Less declarations based on their property names. Ensuring styling is organized, more consistent and in order... The goal of this package is to sort the source code of a project in the build process or to decrease the distributed CSS gzipped size.

Check out the Prettier plugin for usage with a variety of file formats.

Niceness

  • Up-to-date CSS properties fetched from the MDN Compatibility Data project.
  • Choose your wanted order or provide your own.
  • Nested rules sorting support.
  • SCSS and Less support when combined with either postcss-scss or postcss-less.
  • Thought-out sorting orders out of the box, approved by their authors.

Alphabetical example

Input:

body {
    display: block;
    animation: none;
    color: #C55;
    border: 0;
}

Output:

body {
    animation: none;
    border: 0;
    color: #C55;
    display: block;
}

Built-in sorting orders

  • Alphabetical
    alphabetical
    Default, order in a simple alphabetical manner from a - z.

  • SMACSS
    smacss
    Order from most important, flow affecting properties, to least important properties.

    1. Box
    2. Border
    3. Background
    4. Text
    5. Other
  • Concentric CSS
    concentric-css
    Order properties applying outside the box model, moving inward to intrinsic changes.

    1. Positioning
    2. Visibility
    3. Box model
    4. Dimensions
    5. Text

Usage

Following the PostCSS plugin guidelines, this package depends on PostCSS as a peer dependency:
npm install postcss css-declaration-sorter --save-dev

CLI

This module does not include its own CLI but works with the official PostCSS CLI. To use the examples below, the postcss-cli package is a required dependency.

Piping out result from file:
postcss input.css --use css-declaration-sorter | cat

Sorting multiple files by overwriting:
postcss *.css --use css-declaration-sorter --replace --no-map

Sorting all files in a directory with SCSS syntax using postcss-scss by overwriting:
postcss ./src/**/*.scss --syntax postcss-scss --use css-declaration-sorter --replace --no-map

Sorting all files in the directory with SCSS syntax and SMACSS order by overwriting, using package.json configuration:

"postcss": {
  "syntax": "postcss-scss",
  "map": false,
  "plugins": {
    "css-declaration-sorter": { "order": "smacss" }
  }
}

postcss ./src/**/*.scss --replace --config package.json

Vanilla JS

import postcss from 'postcss';
import { cssDeclarationSorter } from 'css-declaration-sorter';

postcss([cssDeclarationSorter({ order: 'smacss' })])
  .process('a { color: hyperblue; display: block; }', { from: undefined })
  .then(result => console.log(
    result.css === 'a { display: block; color: hyperblue; }'
  ));

View more usage examples in combination with other tools.


API

cssDeclarationSorter({ order, keepOverrides })

order

Type: string or function
Default: alphabetical
Options: alphabetical, smacss, concentric-css

Provide the name of one of the built-in sort orders or a comparison function that is passed to (Array.sort). This function receives two declaration names and is expected to return -1, 0 or 1 depending on the wanted order.

keepOverrides

Type: Boolean
Default: false

To prevent breaking legacy CSS where shorthand declarations override longhand declarations (also taking into account vendor prefixes) this option can enabled. For example animation-name: some; animation: greeting; will be kept in this order when keepOverrides is true.

css-declaration-sorter's People

Contributors

amiller-gh avatar andrewleedham avatar ben-eb avatar dependabot[bot] avatar depfu[bot] avatar lexich avatar ludofischer avatar rodrigotomees avatar siilwyn 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

css-declaration-sorter's Issues

Prefixed vendor rules

Would it be possible to keep prefixed vendor rules along with their non-prefixed siblings? Currently they get moved to the top of the block.

Sort scss with gulp

Hi!
First of all, thank you for your Great work on this plugin.
I have a question, in the readme we can find how to use the plugin with gulp:

const gulp = require('gulp');
const gulpPostcss = require('gulp-postcss');
const cssDeclarationSorter = require('css-declaration-sorter');

gulp.task('css', function () {
  return gulp.src('some.css')
    .pipe(gulpPostcss([cssDeclarationSorter({order: 'smacss'})]))
    .pipe(gulp.dest('./'));
});

But, if I want to sort scss declarations, how I can do that? I already know that I Need to install post scss plugin parser, but then how can I implement It? I cannot find something useful in the documentation.

Thank you for reading

Get CSS descriptors too

CSS descriptors that exist inside At-rules such as unicode-range are not included at the moment. These descriptors exist inside subpages of elements tagged with At-rule and should be included as well. The descriptors should be filtered the same as properties. Some descriptor names are identical to property names and should only be included once.

Use a faster sorting algorithm

Instead of using JS built-in array.sort using a different sorting algorithm may increase the speed a considerable amount. This needs more research but TimSort looks very promising and could yield up to a factor of 90 times speed improvement!

An in-range update of postcss is breaking the build 🚨

Version 5.2.15 of postcss just got published.

Branch Build failing 🚨
Dependency postcss
Current Version 5.2.14
Type dependency

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

As postcss is a direct dependency of this project this is very likely breaking your project right now. If other packages depend on you it’s very likely also breaking them.
I recommend you give this issue a very high priority. I’m sure you can resolve this πŸ’ͺ


Status Details
  • ❌ continuous-integration/travis-ci/push The Travis CI build could not complete due to an error Details
Release Notes 5.2.15
Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

Is there a way to sort declarations before nestings?

It would be nice to have a config parameter to output declarations before nestings.

Example

Before:

.foo {
  .bar {
    display: block;
  }

  display: block;
}

After:

.foo {
  display: block;

  .bar {
    display: block;
  }
}

postcss 8 support ?

Hi,

We are using this plugin in cssnano's default preset here and as well as in our advance preset (though default)
As we are migrating to postcss 8 cssnano/cssnano#954, support for postcss 8 in this plugin might be a blocker for us.
Do you have any plan to support postcss 8 ? I can make a PR (by simply following the official migration guide) but as I am not familiar with the internal functionality of this plugin I think I might not be the best person do so.

Let me know if there is any consideration for this.

Version 6.1.0: Error [ERR_REQUIRE_ESM]: Must use import to load ES Module

Starting with version 6.1.0, we get the following error:

ERROR in ../css/theme.css
../css/theme.css from Css Minimizer
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: ../src/node_modules/css-declaration-sorter/orders/alphabetical.mjs
    at Module.load (internal/modules/cjs/loader.js:926:11)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at ../src/node_modules/css-declaration-sorter/src/main.cjs:313:87
    at async LazyResult.runAsync (../src/node_modules/postcss/lib/lazy-result.js:431:15)
    at async cssnanoMinify (eval at transform (../src/node_modules/css-minimizer-webpack-plugin/dist/minify.js:34:28), <anonymous>:51:18)
    at async minify (../src/node_modules/css-minimizer-webpack-plugin/dist/minify.js:15:26)
    at async Object.transform (../src/node_modules/css-minimizer-webpack-plugin/dist/minify.js:35:18)

@Siilwyn This is directly related to the refactoring that was done 2 days ago, replacing JSON with .mjs files.

Node version: 14.16.0 (LTS version).

Thank you.

ERROR: no such file or directory, open 'orders/smacss.json'

I have updated all dependencies to lastest version, and now I got an error:

[20:25:42] Error in plugin "gulp-postcss"
Message:
    ENOENT: no such file or directory, open 'orders/smacss.json'
Details:
    errno: -2
    code: ENOENT
    syscall: open
    path: orders/smacss.json
    fileName: /Users/alextur/Work/gulp-start-template/src/sass/main.css
    domainEmitter: [object Object]
    domainThrown: false

Stack:
Error: ENOENT: no such file or directory, open 'orders/smacss.json'

Plugins versions:

    "css-declaration-sorter": "^6.0.1",
    "gulp-postcss": "^9.0.0",
    "postcss": "^8.1.4"

Before the update everything was OK. I reinstalled all dependencies, tried to delete .lock file - no result.

Any ideas, what I am doing wrong?

To see all code you can go to my GULP start temlate and find gulp/tasks/sass.js, there you will find commented usage of this plugin at line 79. If you install all dependencies, uncomment this line, and trying to run gulp - you will get that error.

css-declaration-sorter breaks some border rules

Even with keepOverrides: true, css-declaration-sorter sometimes changes border styles.
Take this example.

a
{
  border-top: 1px solid;
  border-color: purple;
}

Even with keepOverrides: true, css-declaration-sorter turns it into:

a
{
  border-color: purple;
  border-top: 1px solid;
}

In the original CSS, the top border was purple, now it's not. This happens because the sorting does not take into account that some declarations override others even if they are not shorthand for each other. Originally reported as cssnano/cssnano#1054

Add logical semi-alphabetical order?

Wonder if people would be interested in an alphabetical order that is alphabetically sorted on the shorthand so that longhand properties aren't necessarily alphabetical but don't conflict with the shorthand. The alphabetical order is mainly used for the final build of CSS not for source code formatting.

It would prevent issues like #262 without keepOverrides set to true.

SMACSS ordering update

It would be great if the order for SMACSS could be made inline with the list that Stylelint uses (https://github.com/cahamilton/css-property-sort-order-smacss/blob/master/index.js). This same ordering is also used by SCSS-Lint.

I know that their isn't an official list available, but I guess if more packages use the same ordering a standard will be automatically created. Currently a lot of properties in the SMACSS ordering of this package are ordered alphabetically.

For people that don't lint their CSS this change wouldn't really make any difference.

implement `safe-alphabetically`

Using alphabetically has side effect (cssnano/cssnano#535).
Input:

.bounce {
	animation-name: bounce;
	animation: bounce2 1s ease;
	z-index: 1442;
}

Output:

.bounce{
	animation: bounce2 1s ease;
	animation-name: bounce;
	z-index:1442
}

It is break code. Looks only animation-*, list-style-*, grid-*, counter-* are affected.

Drop Node.js 10 support

  • Replace timsort with stable native array sorting
  • Update Node.js version in package.json engines field
  • Update Node.js version in GH Actions

6.1.2 introduces breaking bug for tailwind projects

My project uses postcss + tailwind, and once 6.1.2 went live I noticed my builds were failing with this error:

[vite:css] Cannot read property 'includes' of undefined
file: /Users/mattjennings/dev/sveltekit-blog-template/src/app.css
> Cannot read property 'includes' of undefined
TypeError: Cannot read property 'includes' of undefined
    at /Users/mattjennings/dev/sveltekit-blog-template/src/app.css:1:1
    at /Users/mattjennings/dev/sveltekit-blog-template/node_modules/.pnpm/[email protected][email protected]/node_modules/css-declaration-sorter/src/main.cjs:333:46
    at /Users/mattjennings/dev/sveltekit-blog-template/node_modules/.pnpm/[email protected]/node_modules/postcss/lib/container.js:55:18
    at Root.each (/Users/mattjennings/dev/sveltekit-blog-template/node_modules/.pnpm/[email protected]/node_modules/postcss/lib/container.js:41:16)
    at Root.walk (/Users/mattjennings/dev/sveltekit-blog-template/node_modules/.pnpm/[email protected]/node_modules/postcss/lib/container.js:52:17)
    at processCss (/Users/mattjennings/dev/sveltekit-blog-template/node_modules/.pnpm/[email protected][email protected]/node_modules/css-declaration-sorter/src/main.cjs:327:7)
    at /Users/mattjennings/dev/sveltekit-blog-template/node_modules/.pnpm/[email protected][email protected]/node_modules/css-declaration-sorter/src/main.cjs:314:33
    at async LazyResult.runAsync (/Users/mattjennings/dev/sveltekit-blog-template/node_modules/.pnpm/[email protected]/node_modules/postcss/lib/lazy-result.js:431:15)
    at async compileCSS (/Users/mattjennings/dev/sveltekit-blog-template/node_modules/.pnpm/[email protected]/node_modules/vite/dist/node/chunks/dep-1be34a63.js:34139:27)
    at async Object.transform (/Users/mattjennings/dev/sveltekit-blog-template/node_modules/.pnpm/[email protected]/node_modules/vite/dist/node/chunks/dep-1be34a63.js:33729:50)
    at async ModuleLoader.addModuleSource (/Users/mattjennings/dev/sveltekit-blog-template/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/shared/rollup.js:19708:30)

I believe this is the breaking change as it removed the safety check for node.raws.before:

528be4a

The error occurs when @tailwind base; is used in the .css file. Removing it, or downgrading to 6.1.1 fixes the error. I also added a console log to that node before the error happens and this is the problematic one:

Comment {
  raws: {},
  type: 'comment',
  text: '! tailwindcss v2.2.9 | MIT License | https://tailwindcss.com',
  source: {
    start: { offset: 0, line: 1, column: 1 },
    input: Input {
      css: '@tailwind base;\n',
      hasBOM: false,
      file: '/Users/mattjennings/dev/sveltekit-blog-template/src/app.css',
      [Symbol(fromOffsetCache)]: [Array]
    },
    end: { offset: 14, line: 1, column: 15 }
  },
  parent: Root {
    raws: { semicolon: true, after: '' },
    type: 'root',
    nodes: [
      [Circular *1], [Comment], [Rule], [Rule],
      [Rule],        [Rule],    [Rule], [Rule],
      [Rule],        [Rule],    [Rule], [Rule],
      [Rule],        [Rule],    [Rule], [Rule],
      [Rule],        [Rule],    [Rule], [Rule],
      [Rule],        [Rule],    [Rule], [Rule],
      [Rule],        [Rule],    [Rule], [Rule],
      [Rule],        [Rule],    [Rule], [Rule],
      [Rule],        [Rule],    [Rule], [Rule],
      [Rule],        [Rule],    [Rule], [Rule],
      [Rule],        [Rule],    [Rule], [Rule],
      [Rule],        [Rule],    [Rule], [Rule],
      [Rule],        [Rule],    [Rule], [Rule],
      [Rule],        [Rule],    [Rule], [Rule],
      [Rule],        [Rule],    [Rule], [Rule],
      [Rule],        [Rule],    [Rule], [Rule],
      [Rule],        [Rule],    [Rule], [Rule],
      [Rule],        [Rule],    [Rule], [AtRule],
      [AtRule]
    ],
    source: { input: [Input], start: [Object] },
    lastEach: 64,
    indexes: { '64': 0 },
    _autoprefixerDisabled: false,
    _autoprefixerPrefix: false,
    _autoprefixerGridStatus: false,
    rawCache: {
      beforeDecl: '\n',
      indent: '\t',
      commentLeft: '',
      commentRight: ' ',
      beforeOpen: '',
      semicolon: true,
      colon: ':',
      beforeClose: '\n',
      beforeRule: '\n\n'
    },
    [Symbol(isClean)]: false,
    [Symbol(my)]: true
  },
  [Symbol(isClean)]: false,
  [Symbol(my)]: true,
  [Symbol(my)]: true,
  [Symbol(isClean)]: true
}

Hopefully that's enough info, otherwise I can create a repro for you if needed.

Make css-declaration-sorter run in browser

In order to create a complete online playground for cssnano (as requested in cssnano/cssnano#1162), I would need to run css-declaration-sorter in thr browser.

I propose converting the JSON to a module exporting an array.

Last time I've checked it was not possible because it uses fs.readFile to read a JSON file which contains the order:

return fs.readFile(path.resolve(currentDirectory, '..', 'orders', order) + '.json')

But fs.readFile will not work in the browser. That would also require adapting property-scraper.mjs. Using import with a JSON file works with a bundler but would need an experimental flag to run it in Node.js.

How to use with .less/.scss when using the CLI?

First of all, thanks for a great tool!!

I can't find out how to use the cssdeclsort CLI command for .less/.scss files. It works great for .css files, but even when I install postcss-less I can't make the CLI pick it up. Any ideas?

engine version conflict

We've got node v10.3.0 running here, can't install css-declaration-sorter 4.0.0 due to the engine constraint in package.json :s

TypeError: Cannot read property 'insertAfter' of undefined

Hi, I keep getting this error.
I did "yarn cache clean"
Reinstalled everything and still cannot figure out why this is failing.

Done in 38.91s.
Compiling...
Compilation failed:
warning package.json: No license field
TypeError: Cannot read property 'insertAfter' of undefined
    at node_modules/optimize-css-assets-webpack-plugin/node_modules/css-declaration-sorter/src/main.cjs:372:22
    at Array.forEach (<anonymous>)
    at processCss (node_modules/optimize-css-assets-webpack-plugin/node_modules/css-declaration-sorter/src/main.cjs:369:12)
    at node_modules/optimize-css-assets-webpack-plugin/node_modules/css-declaration-sorter/src/main.cjs:304:21
    at async LazyResult.runAsync (node_modules/optimize-css-assets-webpack-plugin/node_modules/postcss/lib/lazy-result.js:431:15)
    at async Promise.all (index 0)

Drop Node.js 12 support

Release Status Codename Initial Release Active LTS Start Maintenance Start End-of-life
12.x Maintenance Erbium 2019-04-23 2019-10-21 2020-11-30 2022-04-30
  • Remove CommonJS export and rollup build setup
  • Update export fields in package.json
  • Update Node.js version in package.json engines field
  • Update Node.js version in GH Actions

Add named exports

Think it would be nice to have named exports that are also used in the docs & examples. Keep the default export so it's not a breaking change.

Add an example to set the order in CLI

Hi

It's so simple I'm ashamed of asking here, but could we add an example on how to set the order variable using the CLI?

I tried --order, but it's not working.

Any idea?

Logical border width properties don't retain override order

I seem to have run in to a bug via cssnano, which I have traced back to here. I have logical border width properties overriding a reset of the border width, but the order of the override is not being retained. So given:

div {
    background: grey;
    border-width: 0;
    border-top-width: 1px;
    border-inline-start-width: 1px;
 }

I am getting:

div {
    background: grey;
    border-inline-start-width: 1px;
    border-width: 0;
    border-top-width: 1px;
}

This means the border-inline-start-width is ignored because the border-width overrides it.

I created a minimal repro with the above code to demonstrate the issue: https://runkit.com/embed/zdr51an9amcj.

Provide an example about how to provide a custom order

Hi!
I have a small question regarding the function that can be passed to order option.
Now, as mentioned in the documentation:

Provide the name of one of the built-in sort orders or a comparison function that is passed to (Array.sort). This function receives two declaration names and is expected to return -1, 0 or 1 depending on the wanted order.

I think that Is pretty clear, however I have hard time figure out how to to do this mainly because I don't know Js, and maybe some peoples can be in my situation too.

It wouldn't be useful to include an example in the readme.md on how to do this?

Thank you very much! πŸ™

Compilation Error

Hi @Siilwyn,

after upgrading to the latest version I realized that there is a compilation error.

Failed to compile.
static/css/main.b90420c1.css from Css Minimizer plugin
TypeError: Cannot read property 'insertAfter' of undefined
    at Array.forEach (<anonymous>)

It occurs in the following code block:

  comments.forEach(node => {
    const pairedNode = node.pairedNode;
    node.comment.remove();
    pairedNode.parent['insert' + node.insertPosition](pairedNode, node.comment);
  });

It happens in case the pairedNode has no parent.
Then pairedNode.parent['insert' + node.insertPosition](pairedNode, node.comment); fails.

Refactor test structure

The tests are written in a way that avoids duplicate code: starting with a small amount of tests this was fine. However at this point it is hard to only test specific assertions. When doing this it would also be interesting to see if the time it takes for all tests to run can be decreased. Maybe by using ava instead of tape...

TypeError: Cannot read property 'indexOf' of undefined

Module build failed (from ../node_modules/@kaliber/build/webpack-loaders/css-loader.js):
TypeError: Cannot read property 'indexOf' of undefined
    at /Users/dkropf/Documents/Sites/projectname/node_modules/css-declaration-sorter/src/index.js:47:47
    at /Users/dkropf/Documents/Sites/projectname/node_modules/postcss/lib/container.js:144:26
    at Root.each (/Users/dkropf/Documents/Sites/projectname/node_modules/postcss/lib/container.js:110:22)
    at Root.walk (/Users/dkropf/Documents/Sites/projectname/node_modules/postcss/lib/container.js:143:21)
    at processCss (/Users/dkropf/Documents/Sites/projectname/node_modules/css-declaration-sorter/src/index.js:41:7)
    at /Users/dkropf/Documents/Sites/projectname/node_modules/css-declaration-sorter/src/index.js:22:14
    at initializePlugin (/Users/dkropf/Documents/Sites/projectname/node_modules/cssnano/dist/index.js:35:51)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)

A fix would be:

const isNewlineNode = ~node.raws.before.indexOf('\n');

to

const isNewlineNode = node.raws.before && ~node.raws.before.indexOf('\n');

For now it is not possible for us to upgrade to postcss 7. So this means I cannot create a pull request for the current master branch (version 4.*).

My question; Is it possible to create a 3.0.2 version with this fix? Or is possible to create a 3.x branch so I can create a pull request?

`keepOverrides` failing to preserve ordering of border style declarations

Description

Unexpected reordering of border style declarations are breaking certain styles.

Example

cssDeclarationSorter will take this CSS:

.border-test {
  border-width: 0;
  border-radius: 0;
  border-bottom: 1px;
}

And turn it into:

.border-test {
  border-bottom: 1px;
  border-radius: 0;
  border-width: 0;
}

This may be expected, but what is not expected is if you pass { keepOverrides: true }. You get the same result.

Here is a repo/branch proving the issue. Checkout the fix/border branch and run npm test to see the failing test.

Expected behavior:

Passing { keepOverrides: true } would retain the style declaration ordering.

Workaround:

My current workaround is to provide cssDeclarationSorter with the option:

{
  order: ()=> 0 // preseve style declaration ordering
}

This is necessary for me in a craco project which depends on cssnano which uses this repo, which passes the { keepOverrides: true } by default.

Thanks!

Support @include for scss code

At the moment the plugin can change a position of @include rule for scss code which is not safe and can lead to a wrong result.
Example:
Input

a {
 @include bla;

 color: red;
 display: block;
}

Output

a {
  display: block;

  color: red;
  @include bla;
}

It'd be really good to preserve the position of @include rule.

Properties after @include sass don't be sorted

Hi! Once again me πŸ˜…

Take this piece of code as example (I use smacss as sort order):

.circle-bg {
  padding: 1rem;
  border-radius: 50%;
  background-color: color(primary);
  @include max-size(36rem, 34.5rem);
  height: 84.2vw;
}

The result will be after sortering:

.circle-bg {
  padding: 1rem;
  border-radius: 50%;
  background-color: color(primary);
  @include max-size(36rem, 34.5rem);
  height: 84.2vw;
}

Note that height isn't sortered, very strange.
But after removing @include max-height...
Before:

.circle-bg {
  padding: 1rem;
  border-radius: 50%;
  background-color: color(primary);
  height: 84.2vw;
}

Results:

.circle-bg {
  height: 84.2vw;
  padding: 1rem;
  border-radius: 50%;
  background-color: color(primary);
}

In this case, all work fine.
This is my configuration:

// to simplify I removed importing, ecc
 return src(file, {
            base: './'
          })
          .pipe(postCss([cssDeclarationSorter({
            order: 'smacss'
          })], {
            syntax: postCssScss
          }))
          .pipe(dest('./'));

Missing declarations and some ordering in concentric-css.json

I'm wondering if there's a reason the below isn't included in the sorter:

      grid-gap
      grid-row-gap
      grid-column-gap
      zoom
      block-overflow
      overflow-anchor
      overscroll-behavior
      text-underline-offset
      line-clamp
      word-wrap
      fill
      font-smoothing
      font-display
      contain
      offset-anchor
      offset-distance
      offset-path
      offset-rotate

I realise some or the majority of the above declarations are or maybe experimental, but what happens to those above that are not included, are they removed from the stylesheet? For now, I'm adding them to the end of the file to be sure they don't get removed from my stylesheets.

Also, I'm wondering if it makes more sense for some of the declarations to be ordered in the precendece of their shorthand counterparts, for e.g. background: <color> <url> <repeat> <position>; is a well known shorthand, I'm wondering if the declarations could, or should be sorted according to their shorthand version, mainly to make it easier to condense declaration values later on for brevity? (just a thought).

Support nested rules

Nested rules might be a reality in the next CSS specification release, on top of that almost all CSS preprocessors enable it and so does postcss-nesting.

Things to investigate before implementing this:

  • How does this affect the speed of the module?
  • How to handle newlines before and after nested selectors?

`src` and `font-display` properties missing

Hi,
I notice that the src property and font-display is missing in the smacss order (I haven't controlled other sortings).

Take, for example this code:

@font-face {
  font-family: "Acumin-pro";
  src: url("../../fonts/acumin-pro/acumin-pro-bold.woff2") format("woff2"), url("../../fonts/acumin-pro/acumin-pro-bold.woff") format("woff"), url("../../fonts/acumin-pro/acumin-pro-bold.ttf") format("truetype");
  font-style: normal;
  font-weight: 800;
  font-display: fallback;
}

it will be after sortering :

/* Acumin Pro */
@font-face {
  src: url("../../fonts/acumin-pro/acumin-pro-bold.woff2") format("woff2"), url("../../fonts/acumin-pro/acumin-pro-bold.woff") format("woff"), url("../../fonts/acumin-pro/acumin-pro-bold.ttf") format("truetype");
  font-display: fallback;
  font-family: "Acumin-pro";
  font-style: normal;
  font-weight: 800;
}

Not the best as you can see.
You can add those missing properties to the sort order?
Thank you very much

Support for inserting new lines?

Hi!
I'm wondering, if there are any plans to allow reorder function to insert empty line between some styles group?

Best regards

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.