diff --git a/CHANGELOG.md b/CHANGELOG.md index e7f06c4..1a51ed9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ # confectus +## 1.6.0 + +### Minor Changes + +- Update Eslint configurations to v9.x. + +## 1.5.0 + +### Minor Changes + +- Fix eslint configuration for Next.js and react using Javascript and Typescript. + ## 1.4.6 ### Patch Changes diff --git a/package.json b/package.json index cf5ca57..c31d51e 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "type": "module", "author": "Luan Victor de Souza Dutra", "main": "./dist/main.js", - "version": "1.4.6", + "version": "1.6.0", "license": "MIT", "keywords": [ "JavaScript", diff --git a/src/configs/depedenciesInstallerSetup/index.ts b/src/configs/depedenciesInstallerSetup/index.ts index f5ebd91..bb37340 100644 --- a/src/configs/depedenciesInstallerSetup/index.ts +++ b/src/configs/depedenciesInstallerSetup/index.ts @@ -36,13 +36,13 @@ export const backendDependeciesSetup: SettingsProps = { }, eslint: { configFiles: { - configFileName: '.eslintrc.json', + configFileName: 'eslint.config.mjs', configFilePath: [ 'backend', 'linters', 'eslint', 'javascript', - '.eslintrc.json', + 'eslint.config.mjs', ], }, dependencies: null, @@ -51,13 +51,13 @@ export const backendDependeciesSetup: SettingsProps = { }, eslintts: { configFiles: { - configFileName: '.eslintrc.json', + configFileName: 'eslint.config.mjs', configFilePath: [ 'backend', 'linters', 'eslint', 'typescript', - '.eslintrc.json', + 'eslint.config.mjs', ], }, @@ -107,13 +107,13 @@ export const backendDependeciesSetup: SettingsProps = { export const frontendDependeciesSetup: SettingsProps = { eslintts: { configFiles: { - configFileName: '.eslintrc.json', + configFileName: 'eslint.config.mjs', configFilePath: [ 'frontend', 'linters', 'typescript', 'eslint', - '.eslintrc.json', + 'eslint.config.mjs', ], }, dependencies: null, @@ -122,13 +122,13 @@ export const frontendDependeciesSetup: SettingsProps = { }, eslintjs: { configFiles: { - configFileName: '.eslintrc.json', + configFileName: 'eslint.config.mjs', configFilePath: [ 'frontend', 'linters', 'javascript', 'eslint', - '.eslintrc.json', + 'eslint.config.mjs', ], }, dependencies: null, @@ -136,80 +136,80 @@ export const frontendDependeciesSetup: SettingsProps = { }, eslintreact: { configFiles: { - configFileName: '.eslintrc.json', + configFileName: 'eslint.config.mjs', configFilePath: [ 'frontend', 'linters', 'react', 'eslint', 'javascript', - '.eslintrc.json', + 'eslint.config.mjs', ], }, dependencies: null, devDependencies: - 'eslint@8.56.0 eslint-plugin-react eslint-plugin-react-hooks prettier eslint-config-prettier eslint-plugin-prettier eslint-plugin-jsx-a11y eslint-config-standard', + 'eslint eslint-plugin-react eslint-plugin-react-hooks prettier eslint-config-prettier eslint-plugin-prettier eslint-plugin-jsx-a11y eslint-config-standard', }, eslintreactts: { configFiles: { - configFileName: '.eslintrc.json', + configFileName: 'eslint.config.mjs', configFilePath: [ 'frontend', 'linters', 'react', 'eslint', 'typescript', - '.eslintrc.json', + 'eslint.config.mjs', ], }, dependencies: null, devDependencies: - 'eslint@8.56.0 @typescript-eslint/eslint-plugin @typescript-eslint/parser eslint-plugin-react eslint-plugin-react-hooks prettier eslint-config-prettier eslint-plugin-prettier eslint-plugin-jsx-a11y eslint-config-standard', + 'eslint @typescript-eslint/eslint-plugin @typescript-eslint/parser eslint-plugin-react eslint-plugin-react-hooks prettier eslint-config-prettier eslint-plugin-prettier eslint-plugin-jsx-a11y eslint-config-standard', }, eslintnext: { configFiles: { - configFileName: '.eslintrc.json', + configFileName: 'eslint.config.mjs', configFilePath: [ 'frontend', 'linters', 'next', 'eslint', 'javascript', - '.eslintrc.json', + 'eslint.config.mjs', ], }, dependencies: null, devDependencies: - 'eslint@8.56.0 eslint-plugin-react eslint-plugin-react-hooks prettier eslint-config-prettier eslint-plugin-prettier eslint-plugin-jsx-a11y eslint-config-standard', + 'eslint eslint-plugin-react eslint-plugin-react-hooks prettier eslint-config-prettier eslint-plugin-prettier eslint-plugin-jsx-a11y eslint-config-standard', }, eslintnextts: { configFiles: { - configFileName: '.eslintrc.json', + configFileName: 'eslint.config.mjs', configFilePath: [ 'frontend', 'linters', 'next', 'eslint', 'typescript', - '.eslintrc.json', + 'eslint.config.mjs', ], }, dependencies: null, devDependencies: - 'eslint@8.56.0 eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-jsx-a11y @typescript-eslint/eslint-plugin @typescript-eslint/parser prettier eslint-config-prettier eslint-plugin-prettier eslint-config-standard', + 'eslint eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-jsx-a11y @typescript-eslint/eslint-plugin @typescript-eslint/parser prettier eslint-config-prettier eslint-plugin-prettier eslint-config-standard', }, eslintvue: { configFiles: { - configFileName: '.eslintrc.json', + configFileName: 'eslint.config.mjs', configFilePath: [ 'frontend', 'linters', 'vue', 'eslint', 'javascript', - '.eslintrc.json', + 'eslint.config.mjs', ], }, dependencies: null, @@ -218,20 +218,20 @@ export const frontendDependeciesSetup: SettingsProps = { }, eslintvuets: { configFiles: { - configFileName: '.eslintrc.json', + configFileName: 'eslint.config.mjs', configFilePath: [ 'frontend', 'linters', 'vue', 'eslint', 'typescript', - '.eslintrc.json', + 'eslint.config.mjs', ], }, dependencies: null, devDependencies: - 'eslint-config-prettier eslint@8.56.0 @typescript-eslint/parser@5.59.0 @typescript-eslint/eslint-plugin@5.59.0 @vue/eslint-config-typescript@13.0.0 eslint-plugin-vue@9.11.0 eslint-plugin-prettier@5.0.0 prettier@2.8.8', + 'eslint-config-prettier eslint @typescript-eslint/parser@5.59.0 @typescript-eslint/eslint-plugin@5.59.0 @vue/eslint-config-typescript@13.0.0 eslint-plugin-vue@9.11.0 eslint-plugin-prettier@5.0.0 prettier@2.8.8', }, biome: { configFiles: { diff --git a/src/templates/backend/linters/eslint/typescript/eslint.config.mjs b/src/templates/backend/linters/eslint/typescript/eslint.config.mjs index c9824ba..a1d6d97 100644 --- a/src/templates/backend/linters/eslint/typescript/eslint.config.mjs +++ b/src/templates/backend/linters/eslint/typescript/eslint.config.mjs @@ -1,19 +1,59 @@ -import globals from 'globals'; - import { FlatCompat } from '@eslint/eslintrc'; -import pluginJs from '@eslint/js'; -import path from 'path'; -import { fileURLToPath } from 'url'; +import js from '@eslint/js'; +import typescriptEslint from '@typescript-eslint/eslint-plugin'; +import tsParser from '@typescript-eslint/parser'; +import globals from 'globals'; +import path from 'node:path'; +import { fileURLToPath } from 'node:url'; -// mimic CommonJS variables -- not needed if using CommonJS const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); const compat = new FlatCompat({ baseDirectory: __dirname, - recommendedConfig: pluginJs.configs.recommended, + recommendedConfig: js.configs.recommended, + allConfig: js.configs.all, }); export default [ - { languageOptions: { globals: { ...globals.browser, ...globals.node } } }, - ...compat.extends('standard-with-typescript'), + ...compat.extends( + 'standard', + 'plugin:@typescript-eslint/recommended', + 'plugin:prettier/recommended', + ), + { + plugins: { + '@typescript-eslint': typescriptEslint, + }, + + languageOptions: { + globals: { + ...globals.node, + }, + + parser: tsParser, + ecmaVersion: 'latest', + sourceType: 'module', + }, + + settings: { + 'import/parsers': { + '@typescript-eslint/parser': ['.ts', '.tsx', '.d.ts'], + }, + }, + + rules: { + 'no-useless-constructor': 'off', + 'prettier/prettier': [ + 'error', + { + printWidth: 80, + tabWidth: 2, + singleQuote: true, + trailingComma: 'all', + arrowParens: 'always', + semi: true, + }, + ], + }, + }, ]; diff --git a/src/templates/backend/typescript/tests/vitest/tsconfig.json b/src/templates/backend/typescript/tests/vitest/tsconfig.json index 31867ed..94a3064 100644 --- a/src/templates/backend/typescript/tests/vitest/tsconfig.json +++ b/src/templates/backend/typescript/tests/vitest/tsconfig.json @@ -1,9 +1,11 @@ { "compilerOptions": { - "target": "es2018", - "module": "commonjs", - "lib": ["es2018"], + "target": "ESNext", + "module": "NodeNext", + "moduleResolution": "NodeNext", + "lib": ["ES2018", "ESNext"], "strict": true, + "allowSyntheticDefaultImports": true, "experimentalDecorators": true, "esModuleInterop": true, "skipLibCheck": true, diff --git a/src/templates/backend/typescript/tsconfig.json b/src/templates/backend/typescript/tsconfig.json index 5c6a039..c15e331 100644 --- a/src/templates/backend/typescript/tsconfig.json +++ b/src/templates/backend/typescript/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "target": "ESNext", + "target": "ESNext", "module": "NodeNext", "moduleResolution": "NodeNext", "lib": ["ES2018", "ESNext"], @@ -15,7 +15,14 @@ "resolveJsonModule": true, "baseUrl": "./src", "paths": { - "@/*": ["./*"] + "@shared/*": ["./shared/*"], + "@infra/*": ["./infra/*"], + "@config/*": ["./config/*"], + "@@types/*": ["./@types/*"], + "@constants/*": ["./constants/*"], + "@modules/*": ["./modules/*"], + "@providers/*": ["./providers/*"], + "@test/*": ["./test/*"] } }, "include": ["src/**/*.ts"], diff --git a/src/templates/frontend/linters/biome/biome.json b/src/templates/frontend/linters/biome/biome.json index 1983573..5c8cc7b 100644 --- a/src/templates/frontend/linters/biome/biome.json +++ b/src/templates/frontend/linters/biome/biome.json @@ -1,7 +1,7 @@ { - "$schema": "https://biomejs.dev/schemas/1.6.3/schema.json", + "$schema": "https://biomejs.dev/schemas/1.8.3/schema.json", "organizeImports": { - "enabled": false + "enabled": true }, "linter": { "enabled": true, diff --git a/src/templates/frontend/linters/next/eslint/javascript/.eslintrc.json b/src/templates/frontend/linters/next/eslint/javascript/.eslintrc.json deleted file mode 100644 index baf9818..0000000 --- a/src/templates/frontend/linters/next/eslint/javascript/.eslintrc.json +++ /dev/null @@ -1,49 +0,0 @@ -{ - "env": { - "browser": true, - "es2021": true - }, - "extends": [ - "standard", - "plugin:prettier/recommended" - ], - "parserOptions": { - "ecmaFeatures": { - "jsx": true - }, - "ecmaVersion": 2021, - "sourceType": "module" - }, - "plugins": [ - "jsx-a11y" - ], - "rules": { - "prettier/prettier": ["error", { - "printWidth": 80, - "tabWidth": 2, - "singleQuote": true, - "trailingComma": "all", - "arrowParens": "always", - "semi": true, - "endOfLine": "auto" - }], - "jsx-a11y/alt-text": [ - "warn", - { - "elements": ["img"], - "img": ["Image"] - } - ], - "jsx-a11y/aria-props": "warn", - "jsx-a11y/aria-proptypes": "warn", - "jsx-a11y/aria-unsupported-elements": "warn", - "jsx-a11y/role-has-required-aria-props": "warn", - "jsx-a11y/role-supports-aria-props": "warn", - "react/no-unknown-property": "error" - }, - "settings": { - "react": { - "version": "detect" - } - } -} diff --git a/src/templates/frontend/linters/next/eslint/javascript/eslint.config.mjs b/src/templates/frontend/linters/next/eslint/javascript/eslint.config.mjs new file mode 100644 index 0000000..cb0f2c8 --- /dev/null +++ b/src/templates/frontend/linters/next/eslint/javascript/eslint.config.mjs @@ -0,0 +1,64 @@ +import jsxA11Y from "eslint-plugin-jsx-a11y"; +import globals from "globals"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; +import js from "@eslint/js"; +import { FlatCompat } from "@eslint/eslintrc"; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); +const compat = new FlatCompat({ + baseDirectory: __dirname, + recommendedConfig: js.configs.recommended, + allConfig: js.configs.all +}); + +export default [...compat.extends("standard", "plugin:prettier/recommended"), { + plugins: { + "jsx-a11y": jsxA11Y, + }, + + languageOptions: { + globals: { + ...globals.browser, + }, + + ecmaVersion: 2021, + sourceType: "module", + + parserOptions: { + ecmaFeatures: { + jsx: true, + }, + }, + }, + + settings: { + react: { + version: "detect", + }, + }, + + rules: { + "prettier/prettier": ["error", { + printWidth: 80, + tabWidth: 2, + singleQuote: true, + trailingComma: "all", + arrowParens: "always", + semi: true, + endOfLine: "auto", + }], + + "jsx-a11y/alt-text": ["warn", { + elements: ["img"], + img: ["Image"], + }], + + "jsx-a11y/aria-props": "warn", + "jsx-a11y/aria-proptypes": "warn", + "jsx-a11y/aria-unsupported-elements": "warn", + "jsx-a11y/role-has-required-aria-props": "warn", + "jsx-a11y/role-supports-aria-props": "warn", + }, +}]; \ No newline at end of file diff --git a/src/templates/frontend/linters/next/eslint/typescript/.eslintrc.json b/src/templates/frontend/linters/next/eslint/typescript/.eslintrc.json deleted file mode 100644 index 4b938a0..0000000 --- a/src/templates/frontend/linters/next/eslint/typescript/.eslintrc.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "env": { - "browser": true, - "es2021": true - }, - "extends": [ - "standard", - "plugin:@typescript-eslint/recommended", - "plugin:prettier/recommended" - ], - "parser": "@typescript-eslint/parser", - "parserOptions": { - "ecmaFeatures": { - "jsx": true - }, - "ecmaVersion": "latest", - "sourceType": "module" - }, - "plugins": [ - "jsx-a11y", - "@typescript-eslint" - ], - "rules": { - "prettier/prettier": ["error", { - "printWidth": 80, - "tabWidth": 2, - "singleQuote": true, - "trailingComma": "all", - "arrowParens": "always", - "semi": false, - "endOfLine": "auto" - }], - "jsx-a11y/alt-text": [ - "warn", - { - "elements": ["img"], - "img": ["Image"] - } - ], - "jsx-a11y/aria-props": "warn", - "jsx-a11y/aria-proptypes": "warn", - "jsx-a11y/aria-unsupported-elements": "warn", - "jsx-a11y/role-has-required-aria-props": "warn", - "jsx-a11y/role-supports-aria-props": "warn", - "react/no-unknown-property": "error" - }, - "settings": { - "react": { - "version": "detect" - }, - "import/parsers": { - "@typescript-eslint/parser": [".ts", ".tsx", ".d.ts"] - } - } -} diff --git a/src/templates/frontend/linters/next/eslint/typescript/eslint.config.mjs b/src/templates/frontend/linters/next/eslint/typescript/eslint.config.mjs new file mode 100644 index 0000000..d2cc200 --- /dev/null +++ b/src/templates/frontend/linters/next/eslint/typescript/eslint.config.mjs @@ -0,0 +1,85 @@ +import { FlatCompat } from '@eslint/eslintrc'; +import js from '@eslint/js'; +import typescriptEslint from '@typescript-eslint/eslint-plugin'; +import tsParser from '@typescript-eslint/parser'; +import jsxA11Y from 'eslint-plugin-jsx-a11y'; +import globals from 'globals'; +import path from 'node:path'; +import { fileURLToPath } from 'node:url'; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); +const compat = new FlatCompat({ + baseDirectory: __dirname, + recommendedConfig: js.configs.recommended, + allConfig: js.configs.all, +}); + +export default [ + ...compat.extends( + 'standard', + 'plugin:@typescript-eslint/recommended', + 'plugin:prettier/recommended', + ), + { + plugins: { + 'jsx-a11y': jsxA11Y, + '@typescript-eslint': typescriptEslint, + }, + + languageOptions: { + globals: { + ...globals.browser, + }, + + parser: tsParser, + ecmaVersion: 'latest', + sourceType: 'module', + + parserOptions: { + ecmaFeatures: { + jsx: true, + }, + }, + }, + + settings: { + react: { + version: 'detect', + }, + + 'import/parsers': { + '@typescript-eslint/parser': ['.ts', '.tsx', '.d.ts'], + }, + }, + + rules: { + 'prettier/prettier': [ + 'error', + { + printWidth: 80, + tabWidth: 2, + singleQuote: true, + trailingComma: 'all', + arrowParens: 'always', + semi: true, + endOfLine: 'auto', + }, + ], + + 'jsx-a11y/alt-text': [ + 'warn', + { + elements: ['img'], + img: ['Image'], + }, + ], + + 'jsx-a11y/aria-props': 'warn', + 'jsx-a11y/aria-proptypes': 'warn', + 'jsx-a11y/aria-unsupported-elements': 'warn', + 'jsx-a11y/role-has-required-aria-props': 'warn', + 'jsx-a11y/role-supports-aria-props': 'warn', + }, + }, +]; diff --git a/src/templates/frontend/linters/react/eslint/javascript/.eslintrc.json b/src/templates/frontend/linters/react/eslint/javascript/.eslintrc.json deleted file mode 100644 index 739a2f8..0000000 --- a/src/templates/frontend/linters/react/eslint/javascript/.eslintrc.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "env": { - "browser": true, - "es2021": true - }, - "extends": [ - "plugin:react/recommended", - "plugin:react-hooks/recommended", - "standard", - "plugin:prettier/recommended" - ], - "parserOptions": { - "ecmaFeatures": { - "jsx": true - }, - "ecmaVersion": 2021, - "sourceType": "module" - }, - "plugins": [ - "react", - "jsx-a11y" - ], - "rules": { - "react/self-closing-comp": "error", - "prettier/prettier": ["error", { - "printWidth": 80, - "tabWidth": 2, - "singleQuote": true, - "trailingComma": "all", - "arrowParens": "always", - "semi": false, - "endOfLine": "auto" - }], - "react/react-in-jsx-scope": "off", - "react/prop-types": "off", - "jsx-a11y/alt-text": [ - "warn", - { - "elements": ["img"], - "img": ["Image"] - } - ], - "jsx-a11y/aria-props": "warn", - "jsx-a11y/aria-proptypes": "warn", - "jsx-a11y/aria-unsupported-elements": "warn", - "jsx-a11y/role-has-required-aria-props": "warn", - "jsx-a11y/role-supports-aria-props": "warn", - "react/no-unknown-property": "error" - }, - "settings": { - "react": { - "version": "detect" - } - }, - "ignorePatterns": [ - "node_modules" - ] -} diff --git a/src/templates/frontend/linters/react/eslint/javascript/eslint.config.mjs b/src/templates/frontend/linters/react/eslint/javascript/eslint.config.mjs new file mode 100644 index 0000000..730e80b --- /dev/null +++ b/src/templates/frontend/linters/react/eslint/javascript/eslint.config.mjs @@ -0,0 +1,79 @@ +import { fixupConfigRules, fixupPluginRules } from "@eslint/compat"; +import react from "eslint-plugin-react"; +import jsxA11Y from "eslint-plugin-jsx-a11y"; +import globals from "globals"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; +import js from "@eslint/js"; +import { FlatCompat } from "@eslint/eslintrc"; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); +const compat = new FlatCompat({ + baseDirectory: __dirname, + recommendedConfig: js.configs.recommended, + allConfig: js.configs.all +}); + +export default [{ + ignores: ["**/node_modules"], +}, ...fixupConfigRules(compat.extends( + "plugin:react/recommended", + "plugin:react-hooks/recommended", + "standard", + "plugin:prettier/recommended", +)), { + plugins: { + react: fixupPluginRules(react), + "jsx-a11y": jsxA11Y, + }, + + languageOptions: { + globals: { + ...globals.browser, + }, + + ecmaVersion: 2021, + sourceType: "module", + + parserOptions: { + ecmaFeatures: { + jsx: true, + }, + }, + }, + + settings: { + react: { + version: "detect", + }, + }, + + rules: { + "react/self-closing-comp": "error", + + "prettier/prettier": ["error", { + printWidth: 80, + tabWidth: 2, + singleQuote: true, + trailingComma: "all", + arrowParens: "always", + semi: false, + endOfLine: "auto", + }], + + "react/react-in-jsx-scope": "off", + "react/prop-types": "off", + + "jsx-a11y/alt-text": ["warn", { + elements: ["img"], + img: ["Image"], + }], + + "jsx-a11y/aria-props": "warn", + "jsx-a11y/aria-proptypes": "warn", + "jsx-a11y/aria-unsupported-elements": "warn", + "jsx-a11y/role-has-required-aria-props": "warn", + "jsx-a11y/role-supports-aria-props": "warn", + }, +}]; \ No newline at end of file diff --git a/src/templates/frontend/linters/react/eslint/typescript/.eslintrc.json b/src/templates/frontend/linters/react/eslint/typescript/.eslintrc.json deleted file mode 100644 index 39644a0..0000000 --- a/src/templates/frontend/linters/react/eslint/typescript/.eslintrc.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "env": { - "browser": true, - "es2021": true - }, - "extends": [ - "plugin:react/recommended", - "plugin:react-hooks/recommended", - "standard", - "plugin:@typescript-eslint/recommended", - "plugin:prettier/recommended" - ], - "parser": "@typescript-eslint/parser", - "parserOptions": { - "ecmaFeatures": { - "jsx": true - }, - "ecmaVersion": "latest", - "sourceType": "module" - }, - "plugins": [ - "react", - "jsx-a11y", - "@typescript-eslint" - ], - "rules": { - "react/self-closing-comp": "error", - "prettier/prettier": ["error", { - "printWidth": 80, - "tabWidth": 2, - "singleQuote": true, - "trailingComma": "all", - "arrowParens": "always", - "semi": true, - "endOfLine": "auto" - }], - "react/react-in-jsx-scope": "off", - "react/prop-types": "off", - "jsx-a11y/alt-text": [ - "warn", - { - "elements": ["img"], - "img": ["Image"] - } - ], - "jsx-a11y/aria-props": "warn", - "jsx-a11y/aria-proptypes": "warn", - "jsx-a11y/aria-unsupported-elements": "warn", - "jsx-a11y/role-has-required-aria-props": "warn", - "jsx-a11y/role-supports-aria-props": "warn", - "react/no-unknown-property": "error" - }, - "settings": { - "react": { - "version": "detect" - }, - "import/parsers": { - "@typescript-eslint/parser": [".ts", ".tsx", ".d.ts"] - } - }, - "ignorePatterns": [ - "node_modules" - ] -} diff --git a/src/templates/frontend/linters/react/eslint/typescript/eslint.config.mjs b/src/templates/frontend/linters/react/eslint/typescript/eslint.config.mjs new file mode 100644 index 0000000..f9a66f8 --- /dev/null +++ b/src/templates/frontend/linters/react/eslint/typescript/eslint.config.mjs @@ -0,0 +1,88 @@ +import { fixupConfigRules, fixupPluginRules } from "@eslint/compat"; +import react from "eslint-plugin-react"; +import jsxA11Y from "eslint-plugin-jsx-a11y"; +import typescriptEslint from "@typescript-eslint/eslint-plugin"; +import globals from "globals"; +import tsParser from "@typescript-eslint/parser"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; +import js from "@eslint/js"; +import { FlatCompat } from "@eslint/eslintrc"; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); +const compat = new FlatCompat({ + baseDirectory: __dirname, + recommendedConfig: js.configs.recommended, + allConfig: js.configs.all +}); + +export default [{ + ignores: ["**/node_modules"], +}, ...fixupConfigRules(compat.extends( + "plugin:react/recommended", + "plugin:react-hooks/recommended", + "standard", + "plugin:@typescript-eslint/recommended", + "plugin:prettier/recommended", +)), { + plugins: { + react: fixupPluginRules(react), + "jsx-a11y": jsxA11Y, + "@typescript-eslint": fixupPluginRules(typescriptEslint), + }, + + languageOptions: { + globals: { + ...globals.browser, + }, + + parser: tsParser, + ecmaVersion: "latest", + sourceType: "module", + + parserOptions: { + ecmaFeatures: { + jsx: true, + }, + }, + }, + + settings: { + react: { + version: "detect", + }, + + "import/parsers": { + "@typescript-eslint/parser": [".ts", ".tsx", ".d.ts"], + }, + }, + + rules: { + "react/self-closing-comp": "error", + + "prettier/prettier": ["error", { + printWidth: 80, + tabWidth: 2, + singleQuote: true, + trailingComma: "all", + arrowParens: "always", + semi: true, + endOfLine: "auto", + }], + + "react/react-in-jsx-scope": "off", + "react/prop-types": "off", + + "jsx-a11y/alt-text": ["warn", { + elements: ["img"], + img: ["Image"], + }], + + "jsx-a11y/aria-props": "warn", + "jsx-a11y/aria-proptypes": "warn", + "jsx-a11y/aria-unsupported-elements": "warn", + "jsx-a11y/role-has-required-aria-props": "warn", + "jsx-a11y/role-supports-aria-props": "warn", + }, +}]; \ No newline at end of file diff --git a/src/templates/frontend/linters/vue/eslint/javascript/.eslintrc.json b/src/templates/frontend/linters/vue/eslint/javascript/.eslintrc.json deleted file mode 100644 index 2bf211d..0000000 --- a/src/templates/frontend/linters/vue/eslint/javascript/.eslintrc.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "env": { - "browser": true, - "es2021": true - }, - "extends": [ - "eslint:recommended", - "plugin:vue/vue3-essential" - ], - "parserOptions": { - "ecmaVersion": "latest", - "sourceType": "module" - }, - "plugins": [ - "vue", - "prettier" -], -"rules": { - "prettier/prettier": [ - "error", - { - "printWidth": 80, - "tabWidth": 2, - "singleQuote": true, - "trailingComma": "all", - "arrowParens": "always", - "semi": true - } - ] -} -} \ No newline at end of file diff --git a/src/templates/frontend/linters/vue/eslint/javascript/eslint.config.mjs b/src/templates/frontend/linters/vue/eslint/javascript/eslint.config.mjs new file mode 100644 index 0000000..1ec377d --- /dev/null +++ b/src/templates/frontend/linters/vue/eslint/javascript/eslint.config.mjs @@ -0,0 +1,42 @@ +import vue from "eslint-plugin-vue"; +import prettier from "eslint-plugin-prettier"; +import globals from "globals"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; +import js from "@eslint/js"; +import { FlatCompat } from "@eslint/eslintrc"; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); +const compat = new FlatCompat({ + baseDirectory: __dirname, + recommendedConfig: js.configs.recommended, + allConfig: js.configs.all +}); + +export default [...compat.extends("eslint:recommended", "plugin:vue/vue3-essential"), { + plugins: { + vue, + prettier, + }, + + languageOptions: { + globals: { + ...globals.browser, + }, + + ecmaVersion: "latest", + sourceType: "module", + }, + + rules: { + "prettier/prettier": ["error", { + printWidth: 80, + tabWidth: 2, + singleQuote: true, + trailingComma: "all", + arrowParens: "always", + semi: true, + }], + }, +}]; \ No newline at end of file diff --git a/src/templates/frontend/linters/vue/eslint/typescript/.eslintrc.json b/src/templates/frontend/linters/vue/eslint/typescript/.eslintrc.json deleted file mode 100644 index 15da2bf..0000000 --- a/src/templates/frontend/linters/vue/eslint/typescript/.eslintrc.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "env": { - "browser": true, - "es2021": true - }, - "extends": [ - "eslint:recommended", - "plugin:vue/vue3-recommended", - "@vue/eslint-config-typescript/recommended", - "prettier" - ], - "parser": "vue-eslint-parser", - "parserOptions": { - "ecmaVersion": 2021, - "sourceType": "module" - }, - "plugins": [ - "vue", - "@typescript-eslint", - "prettier" - ], - "rules": { - "prettier/prettier": [ - "error", - { - "printWidth": 80, - "tabWidth": 2, - "singleQuote": true, - "trailingComma": "all", - "arrowParens": "always", - "semi": true - } - ] - } -} diff --git a/src/templates/frontend/linters/vue/eslint/typescript/eslint.config.mjs b/src/templates/frontend/linters/vue/eslint/typescript/eslint.config.mjs new file mode 100644 index 0000000..20d7416 --- /dev/null +++ b/src/templates/frontend/linters/vue/eslint/typescript/eslint.config.mjs @@ -0,0 +1,51 @@ +import vue from "eslint-plugin-vue"; +import typescriptEslint from "@typescript-eslint/eslint-plugin"; +import prettier from "eslint-plugin-prettier"; +import globals from "globals"; +import parser from "vue-eslint-parser"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; +import js from "@eslint/js"; +import { FlatCompat } from "@eslint/eslintrc"; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); +const compat = new FlatCompat({ + baseDirectory: __dirname, + recommendedConfig: js.configs.recommended, + allConfig: js.configs.all +}); + +export default [...compat.extends( + "eslint:recommended", + "plugin:vue/vue3-recommended", + "@vue/eslint-config-typescript/recommended", + "prettier", +), { + plugins: { + vue, + "@typescript-eslint": typescriptEslint, + prettier, + }, + + languageOptions: { + globals: { + ...globals.browser, + }, + + parser: parser, + ecmaVersion: 2021, + sourceType: "module", + }, + + rules: { + "prettier/prettier": ["error", { + printWidth: 80, + tabWidth: 2, + singleQuote: true, + trailingComma: "all", + arrowParens: "always", + semi: true, + }], + }, +}]; \ No newline at end of file