simple2025
0D
V2EX  ›  Vue.js

关于 vue3 lint 的问题

  •  
  •   simple2025 · Dec 14, 2021 · 1875 views
    This topic created in 1631 days ago, the information mentioned may be changed or developed.

    我的 .eslintrc.js 是这样的

    module.exports = {
    	root: true,
    	parserOptions: {
    		sourceType: 'module'
    	},
    	parser: 'vue-eslint-parser',
    	extends: ['plugin:vue/vue3-essential', 'plugin:vue/vue3-strongly-recommended', 'plugin:vue/vue3-recommended'],
    	env: {
    		browser: true,
    		node: true,
    		es6: true
    	},
    	rules: {
    		// 'comma-dangle': 'off',
    		'no-console': 'off',
    		'vue/prop-name-casing': 'off',
    		"vue/max-attributes-per-line": "off",
    		"vue/html-closing-bracket-newline":"off",
    		"vue/no-setup-props-destructure": "off",
    		'comma-dangle': 'off' //禁止使用拖尾逗号
    	}
    }
    

    也能跑

    但是有问题

    因为我的 vue 代码还是有问题,Uncaught (in promise) ReferenceError: message is not defined 但是 eslint 检查不出来? 有什么办法可见检测这种东西吗? 总不可能我一定要上 ts 把!

    6 replies    2021-12-15 10:43:37 +08:00
    noe132
        1
    noe132  
       Dec 14, 2021
    你这是运行时错误,eslint 只检查语法错误。
    simple2025
        2
    simple2025  
    OP
       Dec 14, 2021
    @noe132 我的意思是我这个 message 明显没有 import 呀,难道 eslint 检查不出来? eslint 这么弱吗?
    noe132
        3
    noe132  
       Dec 14, 2021   ❤️ 1
    @chenqh 你配置了相应规则吗?使用未定义变量需要配置 no-undef 规则。你也可以找配置好的 preset 直接使用
    simple2025
        4
    simple2025  
    OP
       Dec 14, 2021
    @noe132 噗,我还以为 no-undef 一开始就是自带的呢,郁闷
    simple2025
        5
    simple2025  
    OP
       Dec 14, 2021
    @noe132 添加了 ` no-undef ` 就好了,谢谢大佬,我还以为 no-undef 本来就好开的呢
    gadfly3173
        6
    gadfly3173  
       Dec 15, 2021   ❤️ 1
    自带什么规则和你加了什么 plugin extends 有关。vue 这几个都没有常规 js 的检查,推荐再搞个 airbnb 之类的。我自己是 extends: ['plugin:vue/vue3-recommended', '@vue/airbnb'] ,然后自己再根据需要对着代码一行行改得配置了一些规则
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3386 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 11:12 · PVG 19:12 · LAX 04:12 · JFK 07:12
    ♥ Do have faith in what you're doing.