A couple of things that might help.
Consider putting some of that code into functions - I know it seems weird to have functions inside a function node
but it is often helpful to break up the code into smaller, logical chunks.
Also, you might want to consider setting up the full VS Code app. If you do, create a testbed folder to work in, initialise it as an npm module using npm init -y
, then install eslint
and some of its exensions. And finally add a file called eslint.config.mjs
perhaps with a config something like this:
// @ts-nocheck
/**
* https://www.npmjs.com/search?q=eslint-config
* https://www.npmjs.com/search?q=keywords:eslint
*
* npm init @eslint/config@latest -- --config eslint-config-standard
* https://eslint.org/docs/latest/rules
*
* npx @eslint/config-inspector@latest
* npx eslint --debug somefile.js
* npx eslint --print-config file.js
*/
import globals from 'globals' // https://www.npmjs.com/package/globals
// @ts-ignore
import pluginImport from 'eslint-plugin-import' // https://www.npmjs.com/package/eslint-plugin-import
import pluginPromise from 'eslint-plugin-promise' // https://www.npmjs.com/package/eslint-plugin-promise
import jsdoc from 'eslint-plugin-jsdoc'// https://github.com/gajus/eslint-plugin-jsdoc
import node from 'eslint-plugin-n' // https://www.npmjs.com/package/eslint-plugin-n, node.js only
import stylistic from '@stylistic/eslint-plugin' // https://eslint.style
import js from '@eslint/js'
/** @type {import('eslint').Linter.Config[]} */
const conf = [
js.configs.recommended,
jsdoc.configs['flat/recommended'],
pluginPromise.configs['flat/recommended'],
pluginImport.flatConfigs.recommended,
...node.configs['flat/recommended-script'],
{
plugins: {
'@stylistic': stylistic,
},
rules: {
'jsdoc/check-alignment': 'off',
// "jsdoc/check-indentation": ["warn", {"excludeTags":['example', 'description']}],
'jsdoc/check-indentation': 'off',
'jsdoc/check-param-names': 'warn',
'jsdoc/check-tag-names': ['warn', {
definedTags: ['typicalname', 'element', 'memberOf', 'slot', 'csspart'],
}],
'jsdoc/multiline-blocks': ['error', {
noZeroLineText: false,
}],
'jsdoc/no-multi-asterisk': 'off',
'jsdoc/no-undefined-types': ['error', {
'definedTypes': ['NodeListOf', 'ProxyHandler'],
}],
'jsdoc/tag-lines': 'off',
'@stylistic/comma-dangle': ['error', {
'arrays': 'only-multiline',
'objects': 'always',
'imports': 'never',
'exports': 'always-multiline',
'functions': 'never',
'importAttributes': 'never',
'dynamicImports': 'never',
}],
'@stylistic/eol-last': ['error', 'always'],
'@stylistic/indent': ['error', 4, {
'SwitchCase': 1,
}],
'@stylistic/linebreak-style': ['error', 'unix'],
'@stylistic/lines-between-class-members': 'off',
'@stylistic/newline-per-chained-call': ['error', {
'ignoreChainWithDepth': 2,
}],
'@stylistic/no-confusing-arrow': 'error',
'@stylistic/no-extra-semi': 'error',
'@stylistic/no-mixed-spaces-and-tabs': 'error',
'@stylistic/no-trailing-spaces': 'error',
'@stylistic/semi': ['error', 'never'],
'@stylistic/quotes': ['error', 'single', {
'avoidEscape': true,
'allowTemplateLiterals': 'always',
}],
'new-cap': 'error',
'no-else-return': 'error',
'no-empty': ['error', {
allowEmptyCatch: true,
}],
'no-unused-vars': 'off',
'no-useless-escape': 'off',
'no-var': 'warn',
'prefer-const': 'error',
},
settings: {
jsdoc: {
mode: 'jsdoc',
},
node: {
version: '18.0.0',
}
},
languageOptions: {
sourceType: 'commonjs',
// Will be overridden by the n plugin which detects the correct node.js version from package.json
ecmaVersion: 'latest',
// Node.js globals are provided by the n plugin
// globals: globals.browser,
},
},
]
export default conf
Then you can paste you code into a file and eslint will check it for you.
Some of the rules listed are my preferences but they are easily adjusted.