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

Recursive option #13

Open
benjaminaudet opened this issue Aug 28, 2019 · 3 comments
Open

Recursive option #13

benjaminaudet opened this issue Aug 28, 2019 · 3 comments

Comments

@benjaminaudet
Copy link

Hey, I just discovered your tool, first of all, great job!

I think it could be cool to have a -r, --recursive option on the CLI to avoid that types of behavior : i18n-lint: ./components/base-components: is a directory

Thanks !

@jwarby
Copy link
Owner

jwarby commented Sep 10, 2019

Hi @benjaminaudet, apologies for the late reply. I won't really have any time to look at this in the near future, but happy to accept a PR for it if you want to have a go!

@ShetlandJ
Copy link

I have a fairly janky solution to this @benjaminaudet. I'm not sure if it will help you, but I ran this command against the directories I wanted to recursively check:

find ./ -type f 

That gave me a list of files, which I dropped into a text file. I then set up a new JS project and used this code to get the list:

const fs = require('fs');
const I18nLint = require('i18n-lint');

try {
    const data = fs.readFileSync('files_to_check.txt', 'utf8').split('\n');

    let baseDir = 'the path to the top level dir I wanted to recursively check through'

    data.forEach(file => {
        const errors = I18nLint(baseDir + file, {
            templateDelimiters: [['{{', '}}']], // I did this with a Vue repo
        });

        console.log(errors);
    })

} catch (e) {
    console.log('Error:', e.stack);
}

It outputs like this, so maybe not 100% ideal but it's enough for me to know the scope of the issues:

image

@tisoap
Copy link

tisoap commented Sep 11, 2023

You can still use a glob pattern to match all files in a directory tree, I.E.:

i18n-lint 'components/base-components/**/*.html'

If using inside a NPM script, don't forget to wrap the glob patter in quotation marks:
https://medium.com/@jakubsynowiec/you-should-always-quote-your-globs-in-npm-scripts-621887a2a784

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

No branches or pull requests

4 participants