CSS linter检测文件中是否使用了选择器

时间:2021-11-29 19:12:01

I am using css linter for sublime that detects syntax errors.

我正在使用css linter来检测语法错误的sublime。

Is there any linter that would scan html document and check if selector has corresponding DOM elements?

是否有任何linter会扫描html文档并检查选择器是否有相应的DOM元素?

That would help with eliminating typos with classes and IDs.

这有助于消除类和ID的拼写错误。

1 个解决方案

#1


2  

I dont believe that there are any sublime text plugins that curently do this, however there are several grunt tools that can do this, so an otion is:

我不相信有任何崇高的文本插件可以做到这一点,但有几个grunt工具可以做到这一点,所以一个otion是:

  1. use the grunt-sublime plugin to run grunt tasts through sublime

    使用grunt-sublime插件通过sublime运行grunt tasts

  2. set up a grunt job to use something like uncss to find css selectors you dont need

    设置一个咕噜咕噜的工作来使用像uncss这样的东西找到你不需要的css选择器

  3. run the task with grunt watch so that the css check is done on file save

    使用grunt watch运行任务,以便在文件保存时完成css检查

You'll get the output throguh sublime so you know if you have added a css selector that isnt in your html

你会得到输出throguh sublime所以你知道你是否添加了一个不在你的HTML中的CSS选择器

#1


2  

I dont believe that there are any sublime text plugins that curently do this, however there are several grunt tools that can do this, so an otion is:

我不相信有任何崇高的文本插件可以做到这一点,但有几个grunt工具可以做到这一点,所以一个otion是:

  1. use the grunt-sublime plugin to run grunt tasts through sublime

    使用grunt-sublime插件通过sublime运行grunt tasts

  2. set up a grunt job to use something like uncss to find css selectors you dont need

    设置一个咕噜咕噜的工作来使用像uncss这样的东西找到你不需要的css选择器

  3. run the task with grunt watch so that the css check is done on file save

    使用grunt watch运行任务,以便在文件保存时完成css检查

You'll get the output throguh sublime so you know if you have added a css selector that isnt in your html

你会得到输出throguh sublime所以你知道你是否添加了一个不在你的HTML中的CSS选择器