avajs / ava

Node.js test runner that lets you develop with confidence 🚀
MIT License
20.74k stars 1.41k forks source link

Ava v4 not recognized by ESLint (with AirBnb-base) #2935

Closed DavidVujic closed 2 years ago

DavidVujic commented 2 years ago

I upgraded Ava to v4 and ran into linting issues. I am developing a Node.js library. The config I use doesn't recognize ava when using require. See gifski generated animation below!

Not sure if it is an issue with Ava, or with AirBnb-base. But this was introduced when switching from Ava v3 to v4.

My current workaround is to have a custom rule in the "tests" folder, where I ignore the "missing imports" rule.

ava-eslint-airbnb-base

package.json (this is an example code, that reproduces the error):

{
  "name": "ava-eslint",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "ava"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "ava": "^4.0.0",
    "eslint": "^8.6.0",
    "eslint-config-airbnb-base": "^15.0.0",
    "eslint-plugin-ava": "^13.1.0",
    "eslint-plugin-import": "^2.25.4"
  },
  "ava": {
      "files": ["./test/**/*"]
  },
  "eslintConfig":{
      "parserOptions": {
          "ecmaVersion": "latest"
      },
      "env": {
          "node": true
      },
      "extends": [
          "airbnb-base"
      ]
  }
}
sindresorhus commented 2 years ago

The import plugin probably struggles with this:

https://github.com/avajs/ava/blob/9bc615e2c93b264b98bac009a897c09d59f72bc4/package.json#L12-L15

But that is a problem with the import ESLint plugin and not AVA.

DavidVujic commented 2 years ago

Thank you for clarifying!