Stylelint—— Expected class selector ".nut-popup--top" to be kebab-case selector-class-pattern

前言

新项目制定规范接入了stylelint,并通过husky在git提交时去触发检测修复,stylelint版本信息如下:

    "stylelint": "^16.8.1",
    "stylelint-config-standard": "^36.0.1",
    "stylelint-less": "^3.0.1",
    "stylelint-order": "^6.0.4",

内容

因为使用的是NutUi,所以无法直接调整组件对应的类名称,只好在stylelint.config.js中加入相应的rules进行配置;

module.exports = {
  defaultSeverity: 'error',
  extends: ['stylelint-config-standard'],
  plugins: ['stylelint-less'],
  overrides: [
    {
      files: ['**/*.html', '**/*.vue'],
      customSyntax: 'postcss-html',
    },
    {
      files: ['**/*.less'],
      customSyntax: 'postcss-less',
    },
  ],
  rules: {
    'selector-pseudo-class-no-unknown': [
      true,
      {
        ignorePseudoClasses: ['deep'],
      },
    ],
    'selector-class-pattern': [
      '^((?!\\.nut).)*$',
      {
        message: "Expected class selector not to start with '.nut'",
      },
    ],
  },
};
posted @ 2024-08-27 09:51:27 王洋 阅读(93) 评论(0)
发表评论
昵称
邮箱
网址