bmatcuk / eslint-plugin-postcss-modules

Checks that you are using the classes exported by your css modules using postcss.
MIT License
21 stars 7 forks source link

I use to annotate in the less file, eslint will block and cannot be used #35

Open lvzegeng opened 1 year ago

lvzegeng commented 1 year ago

.eslintrc.js

module.exports = {
  parser: '@babel/eslint-parser',
  plugins: ['postcss-modules'],
  settings: {
    'postcss-modules': {
      // 用于确定应该为 css-module 导出解析哪些文件。任何匹配 include 但不匹配 exclude 的文件都将被解析
      include: '**/*.less',
      // 用于确定不应为 css-module 导出解析哪些文件。任何匹配 include 但不匹配 exclude 的文件都将被解析
      exclude: '**/node_modules/**/*',
    },
  },
  rules: {
    'postcss-modules/no-undef-class': 'error',
    'postcss-modules/no-unused-class': 'error',
  },
};

index.module.less

//.container {
//  padding: 40px;
//}
bmatcuk commented 1 year ago

I'm not sure I understand what the problem is you are running into, but, have you configured postcss to use the less syntax? See https://www.npmjs.com/package/postcss-less

MateuszGroth commented 1 year ago

He meant that your plugin crushes on comments (// comment). It works with the natively supported by css format tho (/ comment /)