Skip to content

Commit

Permalink
Fix no matching issue corner case for lint CI (opensearch-project#1317)…
Browse files Browse the repository at this point in the history
… (opensearch-project#1326)

* no matching corner case

* adjust some linting rules

* using bash array

* improve linter

* remove redundant check

---------

Signed-off-by: Eric <[email protected]>
(cherry picked from commit 9c15db0)
  • Loading branch information
mengweieric authored and A9 Swift Project User committed Jan 8, 2024
1 parent 8616102 commit 0c79cd6
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 18 deletions.
14 changes: 11 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ module.exports = {
'@elastic/eslint-config-kibana',
'plugin:@elastic/eui/recommended',
'plugin:react-hooks/recommended',
"eslint:recommended",
"plugin:cypress/recommended",
"plugin:import/recommended",
"prettier"
'plugin:jest/recommended',
'plugin:prettier/recommended',
],
env: {
'cypress/globals': true,
Expand All @@ -26,6 +25,14 @@ module.exports = {
'cypress',
],
rules: {
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
},
],
'@osd/eslint/no-restricted-paths': [
'error',
{
Expand All @@ -49,6 +56,7 @@ module.exports = {
{
files: ['**/*.{js,ts,tsx}'],
rules: {
'@typescript-eslint/no-explicit-any': 'warn',
'no-console': 0,
'@osd/eslint/require-license-header': [
'error',
Expand Down
37 changes: 24 additions & 13 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Lint

on: [push, pull_request]
on: [pull_request]

env:
PLUGIN_NAME: dashboards-observability
Expand All @@ -22,7 +22,8 @@ jobs:
- name: Checkout dashboards observability
uses: actions/checkout@v2
with:
path: OpenSearch-Dashboards/plugins/${{ env.PLUGIN_NAME }}
path: OpenSearch-Dashboards/plugins/${{ env.PLUGIN_NAME }}
fetch-depth: 0

- name: Get node and yarn versions
working-directory: ${{ env.WORKING_DIR }}
Expand All @@ -35,7 +36,7 @@ jobs:
uses: actions/setup-node@v1
with:
node-version: ${{ steps.versions_step.outputs.node_version }}
registry-url: 'https://registry.npmjs.org'
registry-url: "https://registry.npmjs.org"

- name: Install correct yarn version for OpenSearch Dashboards
run: |
Expand All @@ -44,18 +45,28 @@ jobs:
npm i -g yarn@${{ steps.versions_step.outputs.yarn_version }}
- name: Bootstrap the plugin
working-directory: OpenSearch-Dashboards/plugins/${{ env.PLUGIN_NAME }}
run:
yarn osd bootstrap
working-directory: OpenSearch-Dashboards/plugins/${{ env.PLUGIN_NAME }}
run: yarn osd bootstrap

- name: lint code base
- name: Get list of changed files
id: files
run: |
BASE_SHA="${{ github.event.pull_request.base.sha }}"
HEAD_SHA="${{ github.event.pull_request.head.sha }}"
git fetch origin $BASE_SHA
git diff --name-only $BASE_SHA...$HEAD_SHA > changed_files.txt
CHANGED_FILES=$(cat changed_files.txt | grep -E '\.(js|ts|tsx)$' || true)
echo "::set-output name=changed::${CHANGED_FILES}"
working-directory: OpenSearch-Dashboards/plugins/${{ env.PLUGIN_NAME }}

- name: Lint Changed Files
run: |
git fetch origin 2.x
CHANGED_FILES=$(git diff --name-only --diff-filter=ACMRTUXB origin/2.x | grep -E "\.(js|ts|tsx)$")
if [ -n "$CHANGED_FILES" ]; then
CHANGED_FILES="${{ steps.files.outputs.changed }}"
if [[ -n "$CHANGED_FILES" ]]; then
echo "Linting changed files..."
yarn lint $CHANGED_FILES
IFS=$'\n' read -r -a FILES_TO_LINT <<< "$CHANGED_FILES"
yarn lint "${FILES_TO_LINT[@]}"
else
echo "No JavaScript/TypeScript files changed."
fi
echo "No matched files to lint."
fi
working-directory: OpenSearch-Dashboards/plugins/${{ env.PLUGIN_NAME }}
4 changes: 2 additions & 2 deletions auto_sync_commit_metadata.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"last_github_commit": "3763bff7fd0ebc6745b6fdc3b17c26272efe8373",
"last_gitfarm_commit": "080b155b33f0f2962f97aaf7067385360440f77f"
"last_github_commit": "9c15db0e143efae2b0623f203e19c38f3a8efe99",
"last_gitfarm_commit": "8ad87f6b18c678c5ee401b3ee7d695a094d62d66"
}

0 comments on commit 0c79cd6

Please sign in to comment.