Skip to content

The Jared Wilcurt's Jest/Vitest ESLint rules

License

Notifications You must be signed in to change notification settings

tjw-lint/eslint-config-tjw-jest

Repository files navigation

eslint-config-tjw-jest

The Jared Wilcurt's Jest/Vitest ESLint rules

Using this

  1. npm install --save-dev eslint-config-tjw-jest
  2. In your .eslitrc.js add tjw-jest to your extends like so:
    module.exports = {
      'extends': [
        'tjw-jest'
      ]
    };

If you already have a no-restricted-syntax rule, you can merge the ones that come with this config with your own, like so:

// .eslintrc.js
const jestRestrictedSyntax = require('eslint-config-tjw-jest/no-restricted-syntax.json');

module.exports = {
  extends: [
    'tjw-jest'
  ],
  rules: {
    'no-restricted-syntax': [
      'error',
      ...jestRestrictedSyntax,
      // your custom rules
    ]
  }
};

Custom rules:

module.exports = {
  extends: [
    'tjw-jest'
  ],
  rules: {
    'capitalize-test-names': 'error',
    'newline-before-expect-assertion': 'error',
    'test-names-avoid-should': 'error'
  }
};
{
  "scripts": {
    "lint": "eslint --rulesdir=./node_modules/eslint-config-tjw-jest/custom-eslint-rules"
  }
}

See also: