@ecosia/stylelint-config-property-sort-order-smacss

中文文档
2.0.0发布于 2025/06/26SEE LICENSE IN 'LICENSE.md'ES Module近 30 天下载 14.1万

Stylelint config for Property Sort Ordering based on the SMACSS methodology

原始使用文档
文档目录7 节
  1. Related Packages
  2. Usage
  3. Advanced
  4. Options
  5. Examples
  6. Contributing
  7. License

@ecosia/stylelint-config-property-sort-order-smacss

Stylelint config for Property Sort Ordering based on the SMACSS methodology.

Usage

The following patterns are considered violations:

a {
  color: red;
  top: 0;
}
a {
  top: 0;
  color: black;
  position: absolute;
  display: block;
}

The following patterns are not considered violations:

a {
  top: 0;
  color: red;
}
a {
  display: block;
  position: absolute;
  top: 0;
  color: black;
}

Refer to css-property-sort-order-smacss for the comprehensive list of property orders.

For more information on configuring Stylelint, check out the configuration guide.

Advanced

This is currently only possible with an exported JavaScript configuration.

The basic usage outlined above, will enforce that properties are strictly sorted within their groups (box, border, background etc). Given this configuration makes use of stylelint-order under the hood, there's a couple extra bits of functionality that can be configured. This will require manually generating the configuration - but passing in extra options as seen fit. These will be applied to each property group.

Options

Refer to the properties-order documentation for a list of available options.

All options except properties and groupName can be modified.

Examples

Flexible Ordering

This will allow properties within the same group to be in any order.

Given:

// stylelint.config.js

const sortOrderSmacss = require('stylelint-config-property-sort-order-smacss/generate');

module.exports = {
  plugins: ['stylelint-order'],
  rules: {
    'order/properties-order': [
      sortOrderSmacss()
    ],
  },
};

The following patterns are considered violations:

a {
  top: 0;
  position: absolute;
  display: block;
  color: black;
}

Given:

// stylelint.config.js

const sortOrderSmacss = require('stylelint-config-property-sort-order-smacss/generate');

module.exports = {
  plugins: ['stylelint-order'],
  rules: {
    'order/properties-order': [
      sortOrderSmacss({ order: 'flexible' })
    ],
  },
};

The following patterns are not considered violations:

a {
  top: 0;
  position: absolute;
  display: block;
  color: black;
}

Empty Line After Property Group

This will allow an empty line after each property group:

Given:

// stylelint.config.js

const sortOrderSmacss = require('stylelint-config-property-sort-order-smacss/generate');

module.exports = {
  plugins: ['stylelint-order'],
  rules: {
    'order/properties-order': [
      sortOrderSmacss({ emptyLineBefore: 'never' })
    ],
  },
};

The following patterns are considered violations:

a {
  display: block;
  position: absolute;
  top: 0;

  color: black;
}

Given:

// stylelint.config.js

const sortOrderSmacss = require('stylelint-config-property-sort-order-smacss/generate');

module.exports = {
  plugins: ['stylelint-order'],
  rules: {
    'order/properties-order': [
      sortOrderSmacss({ emptyLineBefore: 'always' })
    ],
  },
};

The following patterns are not considered violations:

a {
  display: block;
  position: absolute;
  top: 0;

  color: black;
}

Contributing

See CONTRIBUTING.md for contribution guidelines.

License

See LICENSE.md for license information.

版本与发布记录

@ecosia/stylelint-config-property-sort-order-smacss 共发布 2 个版本,首次发布于 2025/06/26;过去 12 个月发布了 0 个版本。

版本发布日期距今
2.0.0latest2025/06/261.4 年前
1.0.02025/06/261.4 年前

关于 @ecosia/stylelint-config-property-sort-order-smacss 的常见问题

@ecosia/stylelint-config-property-sort-order-smacss 是什么?

Stylelint config for Property Sort Ordering based on the SMACSS methodology

如何安装 @ecosia/stylelint-config-property-sort-order-smacss?

在项目目录运行 npm install @ecosia/stylelint-config-property-sort-order-smacss,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:stylelint(^14.0.0 || ^15.0.0 || ^16.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@ecosia/stylelint-config-property-sort-order-smacss 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/ecosia__stylelint-config-property-sort-order-smacss 是否存在。

@ecosia/stylelint-config-property-sort-order-smacss 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@ecosia/stylelint-config-property-sort-order-smacss 可以商用吗?

@ecosia/stylelint-config-property-sort-order-smacss 使用 SEE LICENSE IN 'LICENSE.md' 许可。许可条款写在包内的独立文件中,请阅读该文件确认可否商用。以上为概括,不构成法律意见,请以许可原文为准。

@ecosia/stylelint-config-property-sort-order-smacss 的下载量有多少?

根据 npm 官方下载统计,@ecosia/stylelint-config-property-sort-order-smacss 在 2026/10/13 – 2026/11/11 这 30 天内被下载 141,438 次,日均约 4,715 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@ecosia/stylelint-config-property-sort-order-smacss 还在维护吗?

最新版本 2.0.0 发布于 2025/06/26(1.4 年前);至今共发布 2 个版本,其中过去 12 个月发布了 0 个;首次发布于 2025/06/26。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。