Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vue/no-bare-strings-in-template "allowlist" not always taken into account #2681

Closed
fabienmacko opened this issue Feb 11, 2025 · 3 comments · Fixed by #2682
Closed

vue/no-bare-strings-in-template "allowlist" not always taken into account #2681

fabienmacko opened this issue Feb 11, 2025 · 3 comments · Fixed by #2682
Labels

Comments

@fabienmacko
Copy link

fabienmacko commented Feb 11, 2025

Hello,

My .eslintrc.cjs config file explicitly set an "allowlist" for the rule "vue/no-bare-strings-in-template". Those are Google Icons.

For some reasons it's working for most of them, but "edit_note" trigger an error even tho I add it to the allowlist as you can see below.

When I run yarn lint --fix i'm getting:

  104:57  error  Unexpected non-translated string used  vue/no-bare-strings-in-template

As a workaround I did {{ 'edit_note' }} but looks weired.
What could cause this error ? Is it a bug or a mistake in my usage ?

.eslintrc.cjs

'vue/no-bare-strings-in-template': [
            'error',
            {
                allowlist: [
                    '(',
                    ')',
                    ',',
                    '.',
                    '&',
                    '+',
                    '-',
                    '=',
                    '*',
                    '/',
                    '#',
                    '%',
                    '!',
                    '?',
                    ':',
                    '[',
                    ']',
                    '{',
                    '}',
                    '<',
                    '>',
                    '\u00b7',
                    '\u2022',
                    '\u2010',
                    '\u2013',
                    '\u2014',
                    '\u2212',
                    '|',
                    //Allow all google icons
                    'waving_hand',
                    'check_circle',
                    'error',
                    'arrow_drop_up',
                    'arrow_drop_down',
                    'visibility',
                    'edit',
                    'content_copy',
                    'archive',
                    'unarchive',
                    'publish',
                    'arrow_back_ios',
                    'keyboard_arrow_down',
                    'delete',
                    'arrow_upward',
                    'arrow_downward',
                    'edit_note',
                    'close',
                ],
                attributes: {
                    '/.+/': ['title', 'aria-label', 'aria-placeholder', 'aria-roledescription', 'aria-valuetext'],
                    input: ['placeholder'],
                    img: ['alt'],
                },
                directives: ['v-text'],
            },
        ],
Usage in the code

<span class="material-symbols-outlined">edit_note</span>
                                           ^^^^^^^^ Trigger the error

Thanks

@FloEdelmann
Copy link
Member

Could you please add a link to your repository, or a Stackblitz/CodeSandbox reproduction?

@FloEdelmann FloEdelmann added the needs repro Need a repository that can reproduce the problem, or a link to DEMO. label Feb 11, 2025
@fabienmacko
Copy link
Author

Unfortunately I can't link any repo since the concerned project is private for a client. But I managed to solve the issue by moving the string 'edit_note' in "allowlist" array. It was penultimate, and putting it behind 'visibility' solved it... Can't explain why.

Thanks for the fast answer anyway.

@FloEdelmann
Copy link
Member

Interesting. edit_note probably has to be before edit in the allowlist. That sounds like a bug though that should be possible to fix without a reproduction.

@FloEdelmann FloEdelmann added bug and removed needs repro Need a repository that can reproduce the problem, or a link to DEMO. labels Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants