root: true
extends:
  - semistandard
  - plugin:prettier/recommended
env:
  node: true
  browser: true
  es6: true
parserOptions:
  ecmaVersion: 2018
  ecmaFeatures:
    jsx: false
  sourceType: script
rules:
  no-var: 0
  strict:
    - error
    - safe
overrides:
  - files:
      - 'docs/js/**/*.js'
    env:
      node: false
  - files:
      - '.eleventy.js'
      - '.wallaby.js'
      - 'package-scripts.js'
      - 'karma.conf.js'
      - 'bin/*'
      - 'docs/_data/**/*.js'
      - 'lib/cli/**/*.js'
      - 'lib/nodejs/**/*.js'
      - 'scripts/**/*.js'
      - 'test/**/*.js'
      - 'test/node-unit/**/*.js'
    env:
      browser: false
  - files:
      - lib/nodejs/esm-utils.js
      - rollup.config.js
      - scripts/pick-from-package-json.js
    parserOptions:
      ecmaVersion: 2018
      sourceType: module
      requireConfigFile: false # for @babel/eslint-parser
    parser: '@babel/eslint-parser'
    env:
      browser: false
  - files:
      - test/**/*.{js,mjs}
    env:
      mocha: true
    globals:
      expect: readonly
  - files:
      - bin/*
      - lib/**/*.js
    rules:
      no-restricted-globals:
        - error
        - name: setTimeout
          message: &GH-237 See https://github.com/mochajs/mocha/issues/237
        - name: clearTimeout
          message: *GH-237
        - name: setInterval
          message: *GH-237
        - name: clearInterval
          message: *GH-237
        - name: setImmediate
          message: *GH-237
        - name: clearImmediate
          message: *GH-237
        - name: Date
          message: *GH-237
      no-restricted-modules:
        - error
        - timers
      no-restricted-syntax:
        - error
        # disallow `global.setTimeout()`, `global.setInterval()`, etc.
        - selector: 'CallExpression[callee.object.name=global][callee.property.name=/(set|clear)(Timeout|Immediate|Interval)/]'
          message: *GH-237
        # disallow `new global.Date()`
        - selector: 'NewExpression[callee.object.name=global][callee.property.name=Date]'
          message: *GH-237
        # disallow property access of `global.<timer>.*`
        - selector: '*[object.object.name=global][object.property.name=/(Date|(set|clear)(Timeout|Immediate|Interval))/]:expression'
          message: *GH-237
  - files:
      - test/**/*.mjs
    parserOptions:
      ecmaVersion: 2018
      sourceType: module

  - files:
      - lib/reporters/*.js
    rules:
      no-restricted-syntax:
        - error
        # disallow Reporters using `console.log()`
        - selector: 'CallExpression[callee.object.name=console][callee.property.name=log]'
          message: &GH-3604 See https://github.com/mochajs/mocha/issues/3604
