指定代码不使用lint

ESlint

可以给文件添加/* eslint-disable */,或者对某块代码禁用警告

/* eslint-disable */
alert(1);
/* eslint-enable */

/* eslint-disable no-alert, no-console */
alert(1);
console.log(2);
/* eslint-enable no-alert, no-console */

// 对某一行代码
alert(1); // eslint-disable-line

// eslint-disable-next-line no-alert
alert(1);

参考配置Configuring ESLint - ESLint - Pluggable JavaScript linter

Scss Lint

添加scss-lint:disable和需要禁用的lint规则,结束地方需要添加scss-lint:enable;使用scss-lint:disable all可以忽视所有规则

// scss-lint:disable ImportantRule, StringQuotes
p {
  text-decoration: none !important;  // No lint reported
  content: "hello"; // No lint reported
}
// scss-lint:enable ImportantRule, StringQuotes
div {
  text-decoration: none !important; // Lint reported
  content: "hello"; // Lint reported
}

或者添加在某个代码块内

p {
  // scss-lint:disable BorderZero
  border: none; // No lint reported
}

a {
  border: none; // Lint reported
}

参考GitHub - brigade/scss-lint: Configurable tool for writing clean and consistent SCSS

Comments
Write a Comment