From 1a9620d7fc225c788946db09c8b5b05fb84adb70 Mon Sep 17 00:00:00 2001 From: Eric Date: Fri, 15 Dec 2023 17:04:15 +0000 Subject: [PATCH] CI linting Signed-off-by: Eric --- .eslintignore | 7 +++++++ .eslintrc.js | 31 +++++++++++++++++++++++++------ .github/workflows/lint.yml | 4 ---- 3 files changed, 32 insertions(+), 10 deletions(-) create mode 100644 .eslintignore diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000000..126c839647 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,7 @@ +node_modules +/data +/build +/target +/.eslintrc.js +/cypress.config.js +!.cypress/ \ No newline at end of file diff --git a/.eslintrc.js b/.eslintrc.js index eebbc05703..6ba689e332 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -14,6 +14,10 @@ module.exports = { '@elastic/eslint-config-kibana', 'plugin:@elastic/eui/recommended', 'plugin:react-hooks/recommended', + "eslint:recommended", + "plugin:cypress/recommended", + "plugin:import/recommended", + "prettier" ], env: { 'cypress/globals': true, @@ -21,6 +25,26 @@ module.exports = { plugins: [ 'cypress', ], + rules: { + '@osd/eslint/no-restricted-paths': [ + 'error', + { + basePath: __dirname, + zones: [ + { + target: ['(public|server)/**/*'], + from: ['../../packages/**/*','packages/**/*'], + }, + ], + }, + ], + // Add cypress specific rules here + 'cypress/no-assigning-return-values': 'error', + 'cypress/no-unnecessary-waiting': 'error', + 'cypress/assertion-before-screenshot': 'warn', + 'cypress/no-force': 'warn', + 'cypress/no-async-tests': 'error', + }, overrides: [ { files: ['**/*.{js,ts,tsx}'], @@ -32,13 +56,8 @@ module.exports = { licenses: [LICENSE_HEADER], }, ], - // Add cypress specific rules here - 'cypress/no-assigning-return-values': 'error', - 'cypress/no-unnecessary-waiting': 'error', - 'cypress/assertion-before-screenshot': 'warn', - 'cypress/no-force': 'warn', - 'cypress/no-async-tests': 'error', }, }, ], + "ignorePatterns": ["**/*.d.ts"] }; diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 9d7a547c1b..270de891de 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -10,7 +10,6 @@ jobs: permissions: contents: read packages: read - # To report GitHub Actions status checks statuses: write steps: @@ -53,11 +52,8 @@ jobs: - name: lint code base run: | cd OpenSearch-Dashboards/plugins/dashboards-observability - # Find changed JavaScript/TypeScript files in this PR - git remote -v git fetch origin main CHANGED_FILES=$(git diff --name-only --diff-filter=ACMRTUXB origin/main | grep -E "\.(js|ts|tsx)$") - echo "$CHANGED_FILES" if [ -n "$CHANGED_FILES" ]; then echo "Linting changed files..." yarn lint $CHANGED_FILES