From 8d970fbc32a7b51b29259fe9c27b2310ad5e2cec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Fern=C3=A1ndez=20Serrata?= Date: Wed, 6 Mar 2024 08:38:43 -0400 Subject: [PATCH] add jsconfig. convert .eslintrc from JSON to JS --- .eslintrc.js | 101 +++++++++++++++++++++++++++++++++++++++++++++++++ .eslintrc.json | 84 ---------------------------------------- jsconfig.json | 12 ++++++ src/main.js | 2 +- 4 files changed, 114 insertions(+), 85 deletions(-) create mode 100644 .eslintrc.js delete mode 100644 .eslintrc.json create mode 100644 jsconfig.json diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..f257c8c --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,101 @@ +'use strict' +//eslint-disable-next-line no-implicit-globals +const m = 'Use arrow fn instead.' + +//eslint-disable-next-line no-undef +module.exports = { + env: { + browser: true, + es2021: true + }, + extends: 'eslint:recommended', + parserOptions: { + ecmaVersion: 'latest' + }, + rules: { + 'no-magic-numbers': [ + 'warn', + { + ignore: [ + -1, + 0, + 1, + 2 + ], + ignoreArrayIndexes: true, + ignoreDefaultValues: true, + enforceConst: true + } + ], + 'no-unused-vars': [ + 'warn', + { + varsIgnorePattern: '^_$', + argsIgnorePattern: '^_$' + } + ], + 'no-param-reassign': 'error', + 'no-implicit-globals': [ + 'error', + { + lexicalBindings: true + } + ],/* + 'no-restricted-syntax': [ + 'error', + { + selector: 'FunctionDeclaration', + message: m + }, + { + selector: 'FunctionExpression', + message: m + } + ],*/ + 'no-empty-function': 'error', + 'no-loop-func': 'error', + 'no-lone-blocks': 'error', + 'no-constant-binary-expression': 'error', + 'no-self-compare': 'error', + 'no-unmodified-loop-condition': 'error', + 'no-unreachable-loop': 'error', + 'no-extra-label': 'error', + 'no-else-return': [ + 'error', + { + 'allowElseIf': false + } + ], + 'require-atomic-updates': 'error', + 'no-eval': 'error', + 'no-implied-eval': 'error', + 'dot-notation': 'error', + 'no-array-constructor': 'error', + 'max-depth': 'warn', + 'max-nested-callbacks': [ + 'error', + 3 + ], + 'max-params': [ + 'error', + 4 + ], + 'indent': [ + 'error', + 'tab' + ], + 'linebreak-style': [ + 'error', + 'unix' + ], + 'no-template-curly-in-string': 'warn', + 'quotes': [ + 'error', + 'single' + ], + 'semi': [ + 'error', + 'never' + ] + } +} diff --git a/.eslintrc.json b/.eslintrc.json deleted file mode 100644 index 30a39d0..0000000 --- a/.eslintrc.json +++ /dev/null @@ -1,84 +0,0 @@ -{ - "env": { - "browser": true, - "es2021": true - }, - "extends": "eslint:recommended", - "parserOptions": { - "ecmaVersion": "latest" - }, - "rules": { - "no-magic-numbers": [ - "warn", - { - "ignore": [ - -1, - 0, - 1, - 2 - ], - "ignoreArrayIndexes": true, - "ignoreDefaultValues": true, - "enforceConst": true - } - ], - "no-unused-vars": [ - "warn", - { - "varsIgnorePattern": "^_$", - "argsIgnorePattern": "^_$" - } - ], - "no-implicit-globals": [ - "error", - { - "lexicalBindings": true - } - ], - "no-empty-function": "error", - "no-loop-func": "error", - "no-lone-blocks": "error", - "no-constant-binary-expression": "error", - "no-self-compare": "error", - "no-unmodified-loop-condition": "error", - "no-unreachable-loop": "error", - "no-extra-label": "error", - "no-else-return": [ - "error", - { - "allowElseIf": false - } - ], - "require-atomic-updates": "error", - "no-eval": "error", - "no-implied-eval": "error", - "dot-notation": "error", - "no-array-constructor": "error", - "max-depth": "warn", - "max-nested-callbacks": [ - "error", - 3 - ], - "max-params": [ - "error", - 4 - ], - "indent": [ - "error", - "tab" - ], - "linebreak-style": [ - "error", - "unix" - ], - "no-template-curly-in-string": "warn", - "quotes": [ - "error", - "single" - ], - "semi": [ - "error", - "never" - ] - } -} \ No newline at end of file diff --git a/jsconfig.json b/jsconfig.json new file mode 100644 index 0000000..beaeaf4 --- /dev/null +++ b/jsconfig.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "target": "ES2022", + "module": "None", + "checkJs": true, + "strict": true, + "noUncheckedIndexedAccess": true + }, + "exclude": [ + "node_modules" + ] +} \ No newline at end of file diff --git a/src/main.js b/src/main.js index 1153ee7..875b93b 100644 --- a/src/main.js +++ b/src/main.js @@ -1,4 +1,3 @@ -//@ts-check 'use strict' // global/public, for debugging/testing purposes /*exported RGBDR_anim*/ @@ -21,6 +20,7 @@ const RGBDR_anim = (() => { /** @param {number} n */ + //eslint-disable-next-line no-restricted-syntax const range = function*(n) { for (let i = 0; i < n; i++) yield i