mardi 22 janvier 2019

XO complains about setupTests.js not being in kebab-case when used with create-react-app and enzyme

I created a react app using create-react-app, and I use xo as my linter. Since I wanted to write tests for components, I added enzyme and the required adapter, and also created a setupTests.js file as instructed here. Now, the tests run just fine, but the problem is, xo complains about the case of setupTests.js

src\setupTests.js:1:1
×  1:1  Filename is not in kebab case. Rename it to setup-tests.js.  unicorn/filename-case

I have tried adding the following to xo rules in package.json:

{
    ...,
    "xo": {
        ...,
        "rules": {
            ...,
            "unicorn/filename-case": [
                "error",
                {
                    "case": "kebabCase",
                    "allow": "src/setupTests.js"
                }
            ]
        }
    }
}

But xo would not ignore this file. How can I tell xo (or the eslint-unicorn-plugin) to ignore this file? The plugin's documentation does not help. Any help would be appreciated.

Aucun commentaire:

Enregistrer un commentaire