summaryrefslogtreecommitdiffstats
path: root/eslint.config.js
blob: 89824292b297be1d0f8f05189fc88e9568ba9a3f (plain)
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
'use strict';

const js = require('@eslint/js');
const globals = require('globals');

module.exports = [
  js.configs.recommended,
  {
    rules: {
      // Possible Errors
      //
      // The following rules point out areas where you might have made mistakes.

      // disallow or enforce trailing commas
      'comma-dangle': ['error', 'never'],

      // disallow use of console
      'no-console': 'warn',

      // Best Practices
      //
      // These are rules designed to prevent you from making mistakes.
      // They either prescribe a better way of doing something or help you avoid footguns.

      // require the use of === and !==
      'eqeqeq': ['error', 'always'],

      // disallow the use of alert, confirm, and prompt
      'no-alert': 'error',

      // disallow use of eval()
      'no-eval': 'error',

      // disallow use of multiple spaces
      'no-multi-spaces': 'error',

      // Strict Mode
      //
      // These rules relate to using strict mode.

      // controls location of Use Strict Directives
      'strict': ['error', 'global'],

      // Stylistic Issues
      //
      // These rules are purely matters of style and are quite subjective.

      // this option sets a 2-space indentation for your code
      'indent': ['warn', 2],

      // enforce one true brace style (1tbs)
      'brace-style': 'warn',

      // require camel case names
      'camelcase': 'warn',

      // enforce spacing before and after comma
      'comma-spacing': ['warn', { 'before': false, 'after': true }],

      // enforce one true comma style
      'comma-style': ['warn', 'last'],

      // enforce newline at the end of file, with no multiple empty lines
      'eol-last': ['warn', 'always'],

      // specify whether double or single quotes should be used
      'quotes': ['warn', 'single'],

      // require or disallow use of semicolons instead of ASI
      'semi': ['warn', 'always'],

      // enforce spacing before and after semicolons
      'semi-spacing': ['warn', { 'before': false, 'after': true }],

      // sort variables within the same declaration block
      'sort-vars': 'warn',

      // ECMAScript 6
      //
      // These rules are only relevant to ES6 environments.

      // require let or const instead of var
      'no-var': 'error'
    },

    languageOptions: {
      // Specify the version of ECMAScript syntax you want to use
      'ecmaVersion': 'latest',

      globals: {
        // Browser global variables
        ...globals.browser
      }
    },

    linterOptions: {
      // Report unused eslint-disable comments
      reportUnusedDisableDirectives: true
    }
  },
  {
    files: ['eslint.config.js'],
    languageOptions: {
      'sourceType': 'commonjs'
    }
  }
];