Skip to content
This repository has been archived by the owner on Apr 19, 2022. It is now read-only.

Bug: Inline tags #[...] cause false reports #170

Open
shadow-light opened this issue Apr 7, 2022 · 1 comment
Open

Bug: Inline tags #[...] cause false reports #170

shadow-light opened this issue Apr 7, 2022 · 1 comment

Comments

@shadow-light
Copy link

Info

Tool Version
Plugin v1.0.0-alpha.20
Eslint v8.2.0
Node v14.19.0
OS linux

Eslint config

{

module.exports = {
    root: true,
    parser: 'vue-eslint-parser',
    parserOptions: {
        parser: '@typescript-eslint/parser',
        // vue-eslint-parser passes all options to @typescript-eslint/parser instead
        tsconfigRootDir: __dirname,
        // Treat all files using component tsconfig, and node for everything else
        project: [
            './tsconfig.json',
            './app/src/tsconfig.json',
            './displayer/src/tsconfig.json',
            './tsconfig_base.jsonc',  // Hack for still parsing non-matching (eg .js files)
        ],
        extraFileExtensions: ['.vue'],
    },
    plugins: [
        '@typescript-eslint',
        'import',
    ],
    extends: [
        'eslint:recommended',
        'plugin:@typescript-eslint/recommended',
        'plugin:@typescript-eslint/recommended-requiring-type-checking',
        'plugin:import/recommended',
        'plugin:import/typescript',
        'plugin:vue/recommended',
        'plugin:vue/vue3-recommended',
        'plugin:vue-pug-sfc/recommended',
    ],
    rules: {

        // Enable as errors
        'no-promise-executor-return': 'error',
        'no-template-curly-in-string': 'error',
        'no-unreachable-loop': 'error',
        'no-constructor-return': 'error',
        'eqeqeq': 'error',
        'no-eval': 'error',

        // Enable as warnings
        'max-len': ['warn', {code: 100, ignoreUrls: true, ignoreTemplateLiterals: true}],
        'indent': ['warn', 4, {
            SwitchCase: 1,
            FunctionDeclaration: {parameters: 2},
            // eslint doesn't handle class methods well yet, so ignore identing of their params
            ignoredNodes: ['MethodDefinition Identifier'],
        }],
        'comma-dangle': ['warn', 'always-multiline'],
        'semi': ['warn', 'never', {beforeStatementContinuationChars: 'always'}],
        'no-console': ['warn', {allow: ['warn', 'error', 'info', 'debug']}],  // Non-log allowed

        // Disable as are not problems at all
        '@typescript-eslint/no-extra-semi': 'off',  // Conflicts with 'semi' rule
        '@typescript-eslint/no-empty-interface': 'off',  // Empty interfaces may be expanded later
        '@typescript-eslint/no-non-null-assertion': 'off',  // trailing ! can be useful
        '@typescript-eslint/require-await': 'off',  // Some fns async to match spec or await later
        '@typescript-eslint/no-empty-function': 'off',  // Empty fns may be used to match a spec
        '@typescript-eslint/explicit-module-boundary-types': 'off',  // TS auto detect saves time

        // Disable as already covered by other audits (such as tsc)
        'import/no-unresolved': 'off',  // Vite imports complex and already handled by tsc

        // Default to error but should be warnings
        'no-empty': 'warn',
        '@typescript-eslint/no-unsafe-call': 'warn',
        '@typescript-eslint/no-unsafe-member-access': 'warn',
        '@typescript-eslint/no-unsafe-assignment': 'warn',
        '@typescript-eslint/no-unsafe-argument': 'warn',
        '@typescript-eslint/no-unsafe-return': 'warn',
        '@typescript-eslint/no-floating-promises': 'warn',
        '@typescript-eslint/ban-ts-comment': 'warn',
        '@typescript-eslint/ban-types': 'warn',
        // TODO revert below to error once 'any' type cases dealt with, as also checks invalid code
        '@typescript-eslint/restrict-template-expressions': 'warn',

        // Need customisation
        'vue/prop-name-casing': ['warn', 'snake_case'],  // Not camel case
        'no-constant-condition': ['error', {checkLoops: false}],  // while (true) useful at times
        'prefer-const': ['warn', {destructuring: 'all'}],  // Allows `let [a, b]` if only `a` const
        '@typescript-eslint/no-unused-vars': ['warn', {args: 'none'}],  // Unused args (eg event) ok
        '@typescript-eslint/no-misused-promises': ['error', {checksVoidReturn: false}],
            // Trying to refactor async fns to please checksVoidReturn is more trouble than worth
        '@typescript-eslint/ban-ts-comment': ['error', {'ts-ignore': 'allow-with-description'}],
            // There are some issues (such as Vue 2/3 compatibility) that can't be solved otherwise
    },
}

}

Input

<template lang="pug">

div
    div(v-if='something') Some #[em emphasis]
    dev(v-else) Something else

</template>

Output or Error

14:9  error  'v-else' directives require being preceded by the element which has a 'v-if' or 'v-else-if' directive  vue-pug-sfc/valid-v-else

Expected Output

Nothing

Additional Context

Applies to v-else-if as well. Works fine when #[...] is removed.

@Shinigami92
Copy link
Owner

I would like to wait for https://github.com/rashfael/eslint-plugin-vue-pug so we do not need to double-implement anything

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants