Coder Social home page Coder Social logo

Comments (6)

satazor avatar satazor commented on June 3, 2024 1

I've updated the patterns. I've removed .jsx support because it's a bad practice.

from eslint-config.

satazor avatar satazor commented on June 3, 2024

Actually this should be opt-in and not the default. Perhaps a different addon?

from eslint-config.

acostalima avatar acostalima commented on June 3, 2024

@satazor @andregoncalvesdev @AfonsoVReis

According to ESLint's docs, the configuration can be modified under overrides key in .eslintrc.*. I have been experimenting a bit and below is the best I've achieved so far.

  • I had to make the the top-level .eslintrc.json into .eslintrc.js instead:
module.exports = {
    'root': true,
    'extends': [
        './es5.js',
        './addons/node.js',
        './addons/jest.js',
    ],
    'rules': {
        'quote-props': [2, 'always'],
    },
    'overrides': [require('./addons/overrides/jest-test-dir')],
};

where jest-test-dir.js is:

'use strict';

module.exports = {
    'env': {
        'jest/globals': false,
    },
    'files': ['!test/**/*.js'],
    'rules': {
        'jest/no-disabled-tests': 0,
        'jest/no-focused-tests': 0,
        'jest/no-identical-title': 0,
        'jest/valid-expect': 0,
    },
};

The above works just fine, but has the following downsides/problems:

  • The ESLint config must be .js instead of .json, if we wish to use the override as a module
  • ESLint is not seeing changes made to jest-test-dir.js probably because we're using require, which is an inconvenient. I do not yet know how to fix this.

Feedback is welcome! 😄

from eslint-config.

acostalima avatar acostalima commented on June 3, 2024

I think I got it. I was not aware that it was possible to extend a config with overrides:

// ./addons/overrides/jest-test-files.js`
'use strict';

module.exports = {
    'overrides': [{
        'env': {
            'jest/globals': false,
        },
        'files': ['!test/**/*.js'],
        'rules': {
            'jest/no-disabled-tests': 0,
            'jest/no-focused-tests': 0,
            'jest/no-identical-title': 0,
            'jest/valid-expect': 0,
        },
    }],
};
// ./.eslintrc.json
{
    "root": true,
    "extends": [
        "./es5.js",
        "./addons/node.js",
        "./addons/jest.js",
        "./addons/overrides/jest-test-dir.js"
    ],
    "rules": {
        "quote-props": [2, "always"]
    }
}

What do you think?

from eslint-config.

satazor avatar satazor commented on June 3, 2024

I think we do not need to create jest-test-dir but put all of this in the addons/jest.js.

Regarding the files it should be based on the default patterns of jest + add a test folder because of utilities I mentioned above.

[
   '!**/__tests__/**/*.js',
   '!**/?(*.)(spec|test).js',
   '!test/**/*.js',
]

from eslint-config.

acostalima avatar acostalima commented on June 3, 2024

@satazor thanks! 👍
It is working already. I'm just finalizing the tests. I'll open a PR shortly.

from eslint-config.

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.