Skip to content

Add ignore pattern option to no-raw-text rule #27

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

Closed
Niels-NTG opened this issue Aug 19, 2019 · 5 comments
Closed

Add ignore pattern option to no-raw-text rule #27

Niels-NTG opened this issue Aug 19, 2019 · 5 comments
Labels
Type: Feature Includes new features

Comments

@Niels-NTG
Copy link

The no-raw-text rule can be great to detect where I forgot to add a translatable string because I used a plain string instead. But sometimes I like to add spaces as a separator for inline content.

See below for an example. This creates a table cell with a person's name prefix and sortable last name. Naturally this should be separated by a space. The no-raw-text rule complains "raw text ' ' used".

                <b-table-column
                    :label="$t('lastName')"
                    field="sortableLastName"
                    sortable
                >
                    {{ column.row.prefix }} {{ column.row.sortableLastName }}
                </b-table-column>

I would like to propose an ignore pattern option for the no-raw-text rule:

"vue-i18n/no-row-text: [ "warn", {
  "ignorePattern": "^\s+$"
}]

or alternatively, since I suspect this is a common case:

"vue-i18n/no-row-text: [ "warn", {
  "ignoreWhitespace": true
}]
@kazupon kazupon added the Type: Feature Includes new features label Aug 19, 2019
@kazupon
Copy link
Member

kazupon commented Aug 19, 2019

related #25

@stevelacey
Copy link
Contributor

stevelacey commented Sep 30, 2019

Yep ignorePattern would be perfect here, and map well to the equivalents in the eslint core rules like no-unused-vars – I have both terms that will never need translating, as well as punctuation and braces used in templates.

My ignorePattern would look something like:

{
  ignorePattern: '#|:|\(|\)|-|_|USD'
}

Related: I'd also vote for trimming values prior to consideration, otherwise my above regex would need to be needlessly more complicated I expect

@stevelacey
Copy link
Contributor

stevelacey commented Sep 30, 2019

I added this along with node based ignores, to knock out icon keys etc ala Vuetify's v-icon, check out #31

@kazupon
Copy link
Member

kazupon commented Oct 2, 2019

I've juest released out v0.3.0

@kazupon kazupon closed this as completed Oct 2, 2019
@ghost
Copy link

ghost commented Apr 3, 2020

hi @kazupon

how can I make this work expressions inside the ignored tags?

this works

<v-icon>mdi-close</v-icon>

but this doesn't

<v-icon>{{ isOpen ? 'mdi-close' : 'mdi-open' }}</v-icon>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Feature Includes new features
Projects
None yet
Development

No branches or pull requests

3 participants