From 482139567b80d2528c082860bc7847082c745bba Mon Sep 17 00:00:00 2001 From: SimeonC <1085899+SimeonC@users.noreply.github.com> Date: Fri, 1 Dec 2023 12:31:35 +0900 Subject: [PATCH] fix: naming-convention errors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added some basic tests for current cases for naming-convention as it’s very complicated. --- packages/eslint-config/package.json | 3 --- packages/eslint-config/project.json | 20 +++++++++++++++++++ .../eslint-config/src/presets/typescript.ts | 2 +- .../src/rules/namingConvention.ts | 17 +++++++++++----- packages/eslint-config/tests/.eslintrc.cjs | 12 +++++++++++ .../tests/namingConvention.ts/variables.tsx | 13 ++++++++++++ packages/eslint-config/tests/tsconfig.json | 14 +++++++++++++ 7 files changed, 72 insertions(+), 9 deletions(-) create mode 100644 packages/eslint-config/tests/.eslintrc.cjs create mode 100644 packages/eslint-config/tests/namingConvention.ts/variables.tsx create mode 100644 packages/eslint-config/tests/tsconfig.json diff --git a/packages/eslint-config/package.json b/packages/eslint-config/package.json index d7b2dc80..233ba94d 100644 --- a/packages/eslint-config/package.json +++ b/packages/eslint-config/package.json @@ -56,9 +56,6 @@ "files": [ "dist" ], - "scripts": { - "build": "tsc -p ./tsconfig.build.json" - }, "dependencies": { "@emotion/eslint-plugin": "^11.11.0", "@nx/eslint-plugin": "^16.5.0", diff --git a/packages/eslint-config/project.json b/packages/eslint-config/project.json index 5892eb03..53983673 100644 --- a/packages/eslint-config/project.json +++ b/packages/eslint-config/project.json @@ -4,6 +4,26 @@ "sourceRoot": "packages/eslint-config/src", "projectType": "library", "targets": { + "build": { + "executor": "nx:run-commands", + "options": { + "command": "tsc -p packages/eslint-config/tsconfig.build.json" + } + }, + "test": { + "executor": "@nx/linter:eslint", + "outputs": ["{options.outputFile}"], + "dependsOn": ["build"], + "options": { + "noEslintrc": true, + "eslintConfig": "packages/eslint-config/tests/.eslintrc.cjs", + "reportUnusedDisableDirectives": "error", + "lintFilePatterns": [ + "packages/eslint-config/tests/**/*.ts", + "packages/eslint-config/tests/**/*.tsx" + ] + } + }, "quality": { "executor": "@tablecheck/nx:quality", "outputs": ["{options.outputFile}"], diff --git a/packages/eslint-config/src/presets/typescript.ts b/packages/eslint-config/src/presets/typescript.ts index 6e47a102..6910c8e3 100644 --- a/packages/eslint-config/src/presets/typescript.ts +++ b/packages/eslint-config/src/presets/typescript.ts @@ -22,6 +22,7 @@ module.exports = { ...promiseRules, ...emotionRules, ...namingRules, + 'no-unused-vars': 'off', '@typescript-eslint/explicit-module-boundary-types': 'off', }, }), @@ -30,7 +31,6 @@ module.exports = { rules: { 'import/no-default-export': 'off', 'vars-on-top': 'off', - 'no-unused-vars': 'off', '@typescript-eslint/no-unused-vars': 'off', '@typescript-eslint/no-empty-interface': 'warn', '@typescript-eslint/explicit-module-boundary-types': 'off', diff --git a/packages/eslint-config/src/rules/namingConvention.ts b/packages/eslint-config/src/rules/namingConvention.ts index 596c0e94..4c9dd012 100644 --- a/packages/eslint-config/src/rules/namingConvention.ts +++ b/packages/eslint-config/src/rules/namingConvention.ts @@ -1,16 +1,18 @@ import type { Linter } from 'eslint'; +const componentRegexpMatch = { + regex: '(?