@siemens/stylelint-config-scss

中文文档
5.0.0发布于 2026/08/05MIT零依赖构建来源已验证

Configuration for Stylelint using SCSS (Sass).

原始使用文档
文档目录9 节
  1. Installation
  2. ESLint
  3. Stylelint
  4. Commitlint
  5. Prettier
  6. ESLint Plugin
  7. Usage
  8. Contributing
  9. License

Siemens Lint

Siemens Lint helps you to improve and keep the code quality of your project on a high level. It provides presets and plugins for various linters used at Siemens.

We welcome contributions of further linting rules and configs to be added to this repo for various other programming languages and frameworks.

Presets available for following linters:

Plugins:

Installation

Install @siemens/*-config* and their peer dependencies in your project (whichever you need):

npm install @siemens/stylelint-config-scss --save-dev --save-exact
npm install @siemens/commitlint-config --save-dev --save-exact
npm install @siemens/prettier-config --save-dev --save-exact
npm install @siemens/eslint-config-typescript --save-dev --save-exact
npm install @siemens/eslint-config-angular --save-dev --save-exact

Note You should specify the exact versions of the packages above and their peer dependencies like eslint and its plugins, stylelint, stylelint-config-sass-guidelines and @commitlint/config-conventional. Rules will get changed in the patch releases.

ESLint

Our ESLint configurations does not include any formatting rules. Please use a formatter like Prettier or add a formatting ruleset for ESLint like ESLint Stylistic.

TypeScript

Include the ESLint preset in your root eslint.config.mjs:

import path from 'path';
import { fileURLToPath } from 'url';
import { defineConfig } from 'eslint/config';
import typescriptConfig from '@siemens/eslint-config-typescript';

// mimic CommonJS variables
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

export default defineConfig({
  extends: [...typescriptConfig],
  files: ['**/*.ts'],
  languageOptions: {
    parserOptions: {
      project: ['tsconfig.json', 'tsconfig.app.json', 'tsconfig.spec.json', 'e2e/tsconfig.json'],
      tsconfigRootDir: __dirname
    }
  }
});

Note: to use less strict rules, use the base rules, by importing { configBase } instead.

Angular

Include the ESLint preset in your root eslint.config.mjs:

import path from 'path';
import { fileURLToPath } from 'url';
import { defineConfig } from 'eslint/config';
import angularTypescriptConfig from '@siemens/eslint-config-angular';
import angularTemplateConfig from '@siemens/eslint-config-angular/template';

// mimic CommonJS variables
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

const tsConfig = defineConfig({
  extends: [...angularTypescriptConfig],
  files: ['**/*.ts'],
  languageOptions: {
    parserOptions: {
      project: ['tsconfig.json', 'tsconfig.app.json', 'tsconfig.spec.json', 'e2e/tsconfig.json'],
      tsconfigRootDir: __dirname
    }
  },
  rules: {
    '@angular-eslint/directive-selector': [
      'error',
      {
        type: 'attribute',
        prefix: 'app',
        style: 'camelCase'
      }
    ],
    '@angular-eslint/component-selector': [
      'error',
      {
        type: 'element',
        prefix: 'app',
        style: 'kebab-case'
      }
    ]
  }
});

const templateConfig = defineConfig({
  extends: [...angularTemplateConfig],
  files: ['**/*.html']
});

export default defineConfig(...tsConfig, ...templateConfig);

For libraries and other things in the projects directory, create an additional eslint.config.mjs for each project that looks like this:

import { defineConfig } from 'eslint/config';
import { tsConfig, templateConfig } from '../../eslint.config.mjs';

export default defineConfig(
  {
    extends: [...tsConfig],
    files: ['**/*.ts'],
    languageOptions: {
      parserOptions: {
        project: ['projects/element-ng/tsconfig.lib.json', 'projects/element-ng/tsconfig.spec.json']
      }
    },
    rules: {
      '@angular-eslint/component-selector': [
        'error',
        {
          type: 'element',
          prefix: 'si',
          style: 'kebab-case'
        }
      ],
      '@angular-eslint/directive-selector': [
        'error',
        {
          type: 'attribute',
          prefix: 'si',
          style: 'camelCase'
        }
      ]
    }
  },
  ...templateConfig
);

The @angular-eslint/builder will not automatically pick up the library config location, manually provide it in angular.json:

@@ -122,15 +125,11 @@
          }
        },
        "lint": {
          "builder": "@angular-eslint/builder:lint",
          "options": {
            "lintFilePatterns": [
              "src/**/*.ts",
              "src/**/*.html"
            ],
+           "eslintConfig": "path/to/project/eslint.config.mjs"
          }
        },

Migration from TSLint

Also in angular.json, make sure to replace the TSLint related entries like this:

@@ -122,15 +125,11 @@
          }
        },
        "lint": {
-         "builder": "@angular-devkit/build-angular:tslint",
+         "builder": "@angular-eslint/builder:lint",
          "options": {
-           "tsConfig": [
-             "tsconfig.app.json",
-             "tsconfig.spec.json",
-             "e2e/tsconfig.json"
-           ],
-           "exclude": [
-             "**/node_modules/**"
+           "lintFilePatterns": [
+             "src/**/*.ts",
+             "src/**/*.html"
            ]
          }
        },

Note: to use less strict rules, which are derived from the upstream Angular recommendation and more geared towards applications, use the base rules, by importing { configBase } instead.

Stylelint

Include the stylelint preset in your .stylelintrc.yml:

extends:
  - '@siemens/stylelint-config-scss/stylelintrc.yml'

Commitlint

Include the commitlint preset in your package.json:

  "commitlint": {
    "extends": [
      "@siemens/commitlint-config/.commitlintrc.js"
    ]
  },

// Optional: Pre-commit hook using husky: https://github.com/typicode/husky
  "husky": {
      "hooks": {
        "commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
      }
    },

Prettier

Include the shared Prettier config in your package.json:

"prettier": "@siemens/prettier-config",

ESLint Plugin

The usage of the ESLint plugin is documented here.

Usage

The preset will now be automatically used by eslint and ng lint. Please refer to the Angular ESLint and ng lint documentation for more details.

Add the commitlint, ESlint and stylelint scripts to your package.json:

"scripts": {
  "lint": "ng lint",
  "lint:sass": "stylelint **.scss",
  "lint:commit": "commitlint --from=origin/main",
  "lint:all": "npm run lint:commit && npm run lint && npm run lint:sass"
}

To fix ESLint issues automatically use:

"scripts": {
  "lint:fix": "ng lint --fix"
}

To fix stylelint issues automatically use:

"scripts": {
  "lint:sass:fix": "stylelint --fix **.scss"
}

Make sure to call the linters in your CI build chain in .gitlab-ci.yml:

lint:
  stage: tests
  script:
    - npm install
    - npm run lint:all

Note: To make commitlint work in Gitlab CI, one needs to set the Git shallow clone setting to 0 (found in project settings > CI / CD). That way GitLab CI fetches all branches and tags each time.

Contributing

Improvements are always welcome! Feel free to log a bug, write a suggestion or contribute code by creating a pull request. All details are listed in our contribution guide.

See CONTRIBUTING.md.

License

Code and documentation Copyright (c) Siemens 2018 - 2026.

See LICENSE.md.

版本与发布记录

@siemens/stylelint-config-scss 共发布 29 个版本,首次发布于 2024/12/23;过去 12 个月发布了 11 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
5.0.0latest2026/08/052 个月前
4.4.22026/06/224 个月前
4.4.12026/06/144 个月前
4.4.02026/06/094 个月前
4.3.12026/06/064 个月前
4.3.02026/06/025 个月前

其他发布通道:next → 2.0.0-next.3。

关于 @siemens/stylelint-config-scss 的常见问题

@siemens/stylelint-config-scss 是什么?

使用SCSS (Sass)配置Stylelint。

如何安装 @siemens/stylelint-config-scss?

在项目目录运行 npm install @siemens/stylelint-config-scss,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:stylelint(^16.8.1 || ^17.0.0)、postcss-scss(^4.0.0)、stylelint-scss(^6.5.1 || ^7.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@siemens/stylelint-config-scss 支持 TypeScript 吗?

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

@siemens/stylelint-config-scss 可以商用吗?

@siemens/stylelint-config-scss 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@siemens/stylelint-config-scss 还在维护吗?

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