From 8e07336ec277bad78bff83ac9d1c2e50c090758a Mon Sep 17 00:00:00 2001 From: acalcutt Date: Sun, 16 Mar 2025 13:00:39 -0400 Subject: [PATCH] update config --- .eslintignore | 1 - .eslintrc.cjs | 36 ------------------------------- eslint.config.js | 56 ++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 4 ++-- 4 files changed, 58 insertions(+), 39 deletions(-) delete mode 100644 .eslintignore delete mode 100644 .eslintrc.cjs create mode 100644 eslint.config.js diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index a48cf0d..0000000 --- a/.eslintignore +++ /dev/null @@ -1 +0,0 @@ -public diff --git a/.eslintrc.cjs b/.eslintrc.cjs deleted file mode 100644 index 149f0db..0000000 --- a/.eslintrc.cjs +++ /dev/null @@ -1,36 +0,0 @@ -module.exports = { - root: true, - env: { - browser: true, - node: true, - es6: true, - }, - parserOptions: { - parser: '@typescript-eslint/parser', - ecmaVersion: 2020, - sourceType: 'module', - lib: ['es2020'], - ecmaFeatures: { - jsx: true, - tsx: true, - }, - }, - plugins: ['prettier', 'jsdoc', 'security'], - extends: [ - 'prettier', - 'plugin:@typescript-eslint/recommended', - 'plugin:@typescript-eslint/eslint-recommended', - 'plugin:prettier/recommended', - 'plugin:jsdoc/recommended', - 'plugin:security/recommended', - ], - // add your custom rules here - rules: { - 'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off', - 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off', - '@typescript-eslint/no-unused-vars': [ - 'warn', - { argsIgnorePattern: 'next|err|info|reject' }, - ], - }, -}; diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 0000000..e951d82 --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,56 @@ +// eslint.config.js +import js from '@eslint/js'; +import eslintPluginPrettier from 'eslint-plugin-prettier'; +import tseslint from '@typescript-eslint/eslint-plugin'; +import security from 'eslint-plugin-security'; +import jsdoc from 'eslint-plugin-jsdoc'; +import globals from 'globals'; + +export default [ + { ignores: ['public'] }, + js.configs.recommended, + jsdoc.configs['flat/recommended'], + { + languageOptions: { + parserOptions: { + parser: '@typescript-eslint/parser', + ecmaVersion: 2020, + sourceType: 'module', + lib: ['es2020'], + ecmaFeatures: { + jsx: true, + tsx: true, + }, + }, + globals: { + ...globals.node, // Add Node.js globals + ...globals.browser, // Add browser globals + ...globals.es6, // Add ES6 globals (if not already included) + // ...js.configs.recommended.languageOptions?.globals, // Remove if you want to completely rely on globals package + }, + }, + }, + { + plugins: { + prettier: eslintPluginPrettier, + '@typescript-eslint': tseslint, + jsdoc: jsdoc, + security: security, + }, + }, + { + rules: { + ...tseslint.configs['recommended'].rules, + ...tseslint.configs['eslint-recommended'].rules, + 'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off', + 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off', + '@typescript-eslint/no-unused-vars': [ + 'warn', + { argsIgnorePattern: 'next|err|info|reject|^_' }, + ], + 'prettier/prettier': 'error', + 'jsdoc/require-description': 'warn', + 'security/detect-object-injection': 'warn', + }, + }, +]; diff --git a/package.json b/package.json index e6feda8..be55f82 100644 --- a/package.json +++ b/package.json @@ -17,8 +17,8 @@ "lint:yml": "yamllint --schema=CORE_SCHEMA *.{yml,yaml}", "lint:js": "npm run lint:eslint && npm run lint:prettier", "lint:js:fix": "npm run lint:eslint:fix && npm run lint:prettier:fix", - "lint:eslint": "eslint \"{,!(node_modules|dist|static|public)/**/}*.{js,ts,cjs,mjs}\" --ignore-path .gitignore", - "lint:eslint:fix": "eslint --fix \"{,!(node_modules|dist|static|public)/**/}*.{js,ts,cjs,mjs}\" --ignore-path .gitignore", + "lint:eslint": "eslint \"{,!(node_modules|dist|static|public)/**/}*.{js,ts,cjs,mjs}\" --ignore-pattern '.gitignore'", + "lint:eslint:fix": "eslint --fix \"{,!(node_modules|dist|static|public)/**/}*.{js,ts,cjs,mjs}\" --ignore-pattern '.gitignore'", "lint:prettier": "prettier --check \"{,!(node_modules|dist|static|public)/**/}*.{js,ts,cjs,mjs,json}\" --ignore-path .gitignore", "lint:prettier:fix": "prettier --write \"{,!(node_modules|dist|static|public)/**/}*.{js,ts,cjs,mjs,json}\" --ignore-path .gitignore", "docker": "docker build . && docker run --rm -i -p 8080:8080 $(docker build -q .)"