1. 程式人生 > >指定檔案、指定行、指定程式碼塊不使用 ESLint 語法檢查

指定檔案、指定行、指定程式碼塊不使用 ESLint 語法檢查

整個檔案範圍內禁止規則出現警告
將/* eslint-disable */放置於檔案最頂部

/* eslint-disable */
alert('foo');
在檔案中臨時禁止規則出現警告
將需要忽略的程式碼塊用註釋包裹起來

/* eslint-disable */
alert('foo');
/* eslint-enable */
對指定規則的啟用或者禁用警告
將需要忽略的程式碼塊用註釋包裹起來

/* eslint-disable no-alert, no-console */
alert('foo');
console.log('bar');
/* eslint-enable no-alert, no-console */
對指定行禁用規則警告
此方法,有兩種形式,參見下方。

alert('foo'); // eslint-disable-line
 
// eslint-disable-next-line
alert('foo');
在指定行上禁用指定的某個規則
alert('foo'); // eslint-disable-line no-alert
 
// eslint-disable-next-line no-alert
alert('foo');
在某個特定的行上禁用多個規則
alert('foo'); // eslint-disable-line no-alert, quotes, semi
 
// eslint-disable-next-line no-alert, quotes, semi
alert('foo');
 

--------------------- 
作者:毅江 
來源:CSDN 
原文:https://blog.csdn.net/u013362969/article/details/81215336 
版權宣告:本文為博主原創文章,轉載請附上博文連結!