GithubHelp home page GithubHelp logo

Comments (9)

ceisele-r avatar ceisele-r commented on June 10, 2024 2

@MikeMcC399 ah, thank you!

This eslint/eslintrc#148 (comment) seems to do the trick.

So if anyone else encounters this, what seems to be working is the following:

{
  ...,
  ...compat
    .config({
      extends: ["plugin:cypress/recommended"],
      parserOptions: {
        ecmaVersion: 2020,
        sourceType: "module",
        project: "./cypress/tsconfig.json",
      },
    })
    .map((config) => ({ ...config, files: ["cypress/**/*"] })), // Add the files property to every array entry to restrict it to only be applied to these files.
  ...
}

Thanks again for the tip!

from eslint-plugin-cypress.

MikeMcC399 avatar MikeMcC399 commented on June 10, 2024 1

@ceisele-r

It's great that solved your issue. 🎉 This should probably go into the documentation as it will be a common problem for those upgrading and used to having a specific eslintrc* file in the cypress directory.

from eslint-plugin-cypress.

MikeMcC399 avatar MikeMcC399 commented on June 10, 2024

@ceisele-r
Thank you for re-posting your question!
Please say which version of eslint and eslint-plugin-cypress you are using.
Also to complete the picture, it is helpful to know which operating system you are using and which version of Node.js.

from eslint-plugin-cypress.

codeflorist avatar codeflorist commented on June 10, 2024

Each config object of the flat config can have it's own files definition (see docs here). So this should be possible (not tested):

  ...
  ,
  ...compat.config({
    extends: ["plugin:cypress/recommended"],
    parserOptions: {
      ecmaVersion: 2020,
      sourceType: "module",
      project: "./cypress/tsconfig.json",
    },
    files: ["cypress/**/*.js"],
  }),
  ...
        

from eslint-plugin-cypress.

ceisele-r avatar ceisele-r commented on June 10, 2024

@MikeMcC399 thanks, I'm on eslint 8.57.0 and eslint-plugin-cypress 3.2.0.

@codeflorist that's what I already tried before, but unfortunately, there is no files property for ...compat.config(...) objects:

Object literal may only specify known properties, and 'files' does not exist in type 'Config<RulesRecord, RulesRecord>'.ts(2353)

So that's unfortunately no solution.

from eslint-plugin-cypress.

MikeMcC399 avatar MikeMcC399 commented on June 10, 2024

@ceisele-r

In the https://github.com/cypress-io/cypress-example-kitchensink repo there is a script defined as

"lint": "eslint --fix cypress app/assets/js/scripts.js"

so that only lints cypress (and one other JavaScript file)

Would that be a workaround for you?

from eslint-plugin-cypress.

ceisele-r avatar ceisele-r commented on June 10, 2024

@MikeMcC399 unfortunately not.
It's a larger project where cypress is only one part.
Therefore, there is one new flat eslint.config.js that should cover everything (regular code, other tests, cypress tests etc.) with one lint script (as well as that VS Code picks up that single config for IDE support).

This used to work by having multiple eslintrc.js files in respective directories that extended the main config.
According to my understanding of the new eslint.config.js, this is now all to be flattened in that single config (to only ever have 1 eslint config file).
Therefore, there is the files property in there now so that we can do something like:

{
...
  {
    files: ["src/whatever/**/*"],
    rules: {
      "@typescript-eslint/promise-function-async": "error",
    },
  },
...
}

to enforce specific rules/plugin configurations for specific directories/files.
But for your recommended compat solution using compat.config, this does not seem to be an option (or I missed the correct syntax how to specify the files this compat.config should be applied to).

from eslint-plugin-cypress.

MikeMcC399 avatar MikeMcC399 commented on June 10, 2024

@ceisele-r

Would you take a look at eslint/eslintrc#148 to see if this explains it?

You're welcome to take the question over to the ESLint experts in their Discord channel https://eslint.org/chat as well since it concerns how to use their @eslint/eslintrc library.

I will also see in parallel if I can get this working.

from eslint-plugin-cypress.

MikeMcC399 avatar MikeMcC399 commented on June 10, 2024

I'm going to close this issue now as v3.3.0 removes the reliance on the Flat mode compatibility utility.

from eslint-plugin-cypress.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.