Làm thế nào để sử dụng mã Visual Studio để lint tệp JavaScript dựa trên quy tắc stage-0 babel/ES7?VSCode Linter ES6 ES7 Babel linter
Tôi chỉ cần mã lint. Tôi đã có webpack transpiling Js file.
Làm thế nào để sử dụng mã Visual Studio để lint tệp JavaScript dựa trên quy tắc stage-0 babel/ES7?VSCode Linter ES6 ES7 Babel linter
Tôi chỉ cần mã lint. Tôi đã có webpack transpiling Js file.
Làm thế nào tôi tiến hành:
npm install -g eslint
npm install --save-dev babel-eslint
npm install --save-dev eslint-plugin-react
{
"env": {
"browser": true,
"node": true,
"es6": true,
"jest": true,
"jquery": true
},
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"ecmaFeatures": {
"arrowFunctions": true,
"binaryLiterals": true,
"blockBindings": true,
"classes": true,
"defaultParams": true,
"destructuring": true,
"forOf": true,
"generators": true,
"modules": true,
"objectLiteralComputedProperties": true,
"objectLiteralDuplicateProperties": true,
"objectLiteralShorthandMethods": true,
"objectLiteralShorthandProperties": true,
"octalLiterals": true,
"regexUFlag": true,
"regexYFlag": true,
"spread": true,
"superInFunctions": true,
"templateStrings": true,
"unicodeCodePointEscapes": true,
"globalReturn": true,
"jsx": true,
"experimentalObjectRestSpread": true
}
},
"plugins": [
"react"
],
"rules": {
"strict": 0
}
}
{
//disable default javascript validator replaced by eslint
"javascript.validate.enable" : false
}
Bây giờ, nó nên lint như muốn đang ES7 của bạn . Nếu có bất kỳ vấn đề nào với cấu hình eslint đọc VSC, bạn có thể thấy nó trong giao diện điều khiển VSC (ctrl-shift-U).
Kết quả là, mã ES7 (lây lan khai thác trong các đối tượng chẳng hạn) cũng được linted:
PS: có thể .eslintrc tôi sử dụng một số dữ liệu thêm vô ích cho ES7 linting nên cảm thấy tự do để xoá bỏ nó:)
tôi nên đặt tệp .eslintrc ở đâu? trong thư mục chính của tôi? hoặc thư mục "root" –
Trong thư mục gốc của dự án của bạn, thư mục bạn chọn với VSCode khi sử dụng 'openFolder'. –
Cảm ơn bạn. Đây có phải là cách tốt nhất để đi về nó? Chủ đề VSCode trên github chưa được đóng –