All files node.js

100% Statements 9/9
100% Branches 0/0
100% Functions 0/0
100% Lines 9/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87    1x 1x 1x 1x 1x 1x 1x 1x         1x                                                                                                                                                
'use strict'
 
const coreBestPractices = require('./src/core-best-practices')
const coreEcmaScript = require('./src/core-ecma-script')
const corePossibleErrors = require('./src/core-possible-errors')
const coreStylisticIssues = require('./src/core-stylistic-issues')
const coreVariables = require('./src/core-variables')
const imports = require('./src/imports')
const node = require('./src/node')
const envRuleSeverities = require('./src/env-rule-severities')
 
/**
 * Node.js services use the base ruleset extended with the Node ruleset.
 */
module.exports = {
  extends: ['prettier'],
 
  parser: 'babel-eslint',
 
  parserOptions: {
    ecmaVersion: 11,
    sourceType: 'script',
  },
 
  plugins: ['import', 'prettier'],
 
  settings: {
    // Increase import cache lifetime to 60s
    'import/cache': 60,
    'import/resolver': {
      node: {
        extensions: ['.mjs', '.js', '.json', '.jsx', '.ts', '.tsx'],
      },
    },
  },
 
  env: {
    es6: true,
    node: true,
  },
 
  rules: envRuleSeverities({
    // --- ESLint core rules configuration ---
    ...coreBestPractices,
    ...coreEcmaScript,
    ...corePossibleErrors,
    ...coreStylisticIssues,
    ...coreVariables,
 
    // Node specific rules
    ...node,
 
    // --- Plugin rules ---
 
    ...imports,
 
    // Prettier formatting enforcement via Prettier *plugin*
    // (this is different from the rule overrides set in the Prettier *config*)
    'prettier/prettier': 'error',
  }),
 
  // Report on unused eslint-disable comments
  reportUnusedDisableDirectives: true,
 
  // --- File overrides -----------------------------------
 
  overrides: [
    // ✅ Spec files - Adds Jest globals used by tests
    {
      files: ['*.spec.js'],
      parserOptions: {
        // Using Babel parser allows writing tests as ESModules now
        sourceType: 'module',
      },
      env: {
        jest: true,
      },
      rules: {
        // In Jest test files allow defining `jest.mock()` calls before imports
        // Under the hood Jest hoists these to the top of the file and it helps
        // visually distinguish modules that are being replaced with mocks
        'import/first': 'off',
      },
    },
  ],
}