add jsdoc linting, address issues
[squeep-mystery-box] / eslint.config.js
1 'use strict';
2 const globals = require('globals');
3 const js = require('@eslint/js');
4 const jsdoc = require('eslint-plugin-jsdoc');
5 const node = require('eslint-plugin-n');
6 const security = require('eslint-plugin-security');
7 const sonarjs = require('eslint-plugin-sonarjs');
8
9 const { FlatCompat } = require('@eslint/eslintrc');
10 const compat = new FlatCompat();
11
12 module.exports = [
13 js.configs.recommended,
14 ...compat.config(node.configs.recommended),
15 security.configs.recommended,
16 ...compat.config(sonarjs.configs.recommended),
17 jsdoc.configs['flat/recommended'],
18 {
19 files: [ '**/*.js' ],
20 plugins: {
21 node,
22 security,
23 sonarjs,
24 jsdoc,
25 },
26 languageOptions: {
27 ecmaVersion: 2023,
28 sourceType: 'script',
29 },
30 rules: {
31 'array-element-newline': [
32 'error',
33 'consistent',
34 ],
35 'arrow-parens': [
36 'error',
37 'always',
38 ],
39 'arrow-spacing': [
40 'error',
41 {
42 'after': true,
43 'before': true,
44 },
45 ],
46 'block-scoped-var': 'error',
47 'block-spacing': 'error',
48 'brace-style': 'error',
49 'callback-return': 'error',
50 'camelcase': 'error',
51 'class-methods-use-this': 'error',
52 'comma-dangle': [
53 'error',
54 'always-multiline',
55 ],
56 'comma-spacing': [
57 'error',
58 {
59 'after': true,
60 'before': false,
61 },
62 ],
63 'comma-style': [
64 'error',
65 'last',
66 ],
67 'indent': [
68 'warn',
69 2,
70 {
71 'SwitchCase': 1,
72 },
73 ],
74 'sonarjs/cognitive-complexity': 'warn',
75 'keyword-spacing': 'error',
76 'linebreak-style': [
77 'error',
78 'unix',
79 ],
80 'no-unused-vars': [
81 'error', {
82 'varsIgnorePattern': '^_',
83 },
84 ],
85 'object-curly-spacing': [
86 'error',
87 'always',
88 ],
89 'prefer-const': 'error',
90 'quotes': [
91 'error',
92 'single',
93 ],
94 'semi': [
95 'error',
96 'always',
97 ],
98 'strict': 'error',
99 'vars-on-top': 'error',
100 },
101 },
102 {
103 files: ['test/**'],
104 languageOptions: {
105 globals: {
106 ...globals.mocha,
107 },
108 },
109 rules: {
110 "n/no-unpublished-require": "off",
111 },
112 },
113 ];