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

简介: 新项目制定规范接入了stylelint,并通过husky在git提交时去触发检测修复,因为使用的是NutUi,所以无法直接调整组件对应的类名称,只好在stylelint.config.js中加入相应的rules进行配置。

前言

新项目制定规范接入了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'",
      },
    ],
  },
};
目录
相关文章
|
23天前
|
开发工具 git
Stylelint——Unexpected unknown pseudo-class selector ":deep" selector-pseudo-class-no-unknown
新项目制定规范接入了stylelint,并通过husky在git提交时去触发检测修复,使用`:deep()`的时候却发现了报错;
48 1
|
1月前
|
CDN
Iconfont——Error: <path> attribute d: Expected number, "MNaNNaNaNaNNaNNaN…".
Iconfont——Error: <path> attribute d: Expected number, "MNaNNaNaNaNNaNNaN…".
29 0
【已解决】Error: Element type is invalid: expected a string (for built-in components) or a class/function
Error: Element type is invalid: expected a string (for built-in components) or a class/function
2517 0
【已解决】Error: Element type is invalid: expected a string (for built-in components) or a class/function
Unknown custom element: <add-employee> - did you register the component correctly? For red cursive c
原因: 1.组件名没写对(导入和注册不对应) 2.components少写了个s 3.组件命名最好是驼峰命名 4.导入时语法错误 5.代码中有两个components,后一个的值把前一个覆盖了 6.组件直接循环套用了
|
9月前
|
JavaScript
[Vue warn]: Unknown custom element: <Top> - did you register the component correctly?
[Vue warn]: Unknown custom element: <Top> - did you register the component correctly?
|
10月前
|
JavaScript
Element UI报错:Unknown custom element: <el-menu>
Element UI报错:Unknown custom element: <el-menu>
131 0
|
JavaScript 前端开发
成功解决Component template should contain exactly one root element
成功解决Component template should contain exactly one root element
Extraneous children found when component already has explicitly named default slot. These children
Extraneous children found when component already has explicitly named default slot. These children
1179 5
|
小程序
【微信小程序】tabbar报错Component is not found in path “custom-tab-bar/index“
【微信小程序】tabbar报错Component is not found in path “custom-tab-bar/index“
385 0