Skip to content

Commit 994ae0e

Browse files
authored
Signed-off-by: Eric <[email protected]>
1 parent 3c57327 commit 994ae0e

File tree

3 files changed

+99
-0
lines changed

3 files changed

+99
-0
lines changed

.eslintignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
node_modules
2+
/data
3+
/build
4+
/target
5+
/.eslintrc.js
6+
/cypress.config.js
7+
!.cypress/

.eslintrc.js

+31
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,37 @@ module.exports = {
1414
'@elastic/eslint-config-kibana',
1515
'plugin:@elastic/eui/recommended',
1616
'plugin:react-hooks/recommended',
17+
"eslint:recommended",
18+
"plugin:cypress/recommended",
19+
"plugin:import/recommended",
20+
"prettier"
1721
],
22+
env: {
23+
'cypress/globals': true,
24+
},
25+
plugins: [
26+
'cypress',
27+
],
28+
rules: {
29+
'@osd/eslint/no-restricted-paths': [
30+
'error',
31+
{
32+
basePath: __dirname,
33+
zones: [
34+
{
35+
target: ['(public|server)/**/*'],
36+
from: ['../../packages/**/*','packages/**/*'],
37+
},
38+
],
39+
},
40+
],
41+
// Add cypress specific rules here
42+
'cypress/no-assigning-return-values': 'error',
43+
'cypress/no-unnecessary-waiting': 'error',
44+
'cypress/assertion-before-screenshot': 'warn',
45+
'cypress/no-force': 'warn',
46+
'cypress/no-async-tests': 'error',
47+
},
1848
overrides: [
1949
{
2050
files: ['**/*.{js,ts,tsx}'],
@@ -29,4 +59,5 @@ module.exports = {
2959
},
3060
},
3161
],
62+
"ignorePatterns": ["**/*.d.ts"]
3263
};

.github/workflows/lint.yml

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Lint
2+
3+
on: [push, pull_request]
4+
5+
env:
6+
PLUGIN_NAME: dashboards-observability
7+
OPENSEARCH_DASHBOARDS_VERSION: 'main'
8+
9+
jobs:
10+
build:
11+
name: Lint
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout OpenSearch Dashboards
16+
uses: actions/checkout@v2
17+
with:
18+
repository: opensearch-project/Opensearch-Dashboards
19+
ref: ${{ env.OPENSEARCH_DASHBOARDS_VERSION }}
20+
path: OpenSearch-Dashboards
21+
22+
- name: Checkout dashboards observability
23+
uses: actions/checkout@v2
24+
with:
25+
path: OpenSearch-Dashboards/plugins/${{ env.PLUGIN_NAME }}
26+
27+
- name: Get node and yarn versions
28+
working-directory: ${{ env.WORKING_DIR }}
29+
id: versions_step
30+
run: |
31+
echo "::set-output name=node_version::$(cat ./OpenSearch-Dashboards/.nvmrc | cut -d"." -f1)"
32+
echo "::set-output name=yarn_version::$(node -p "(require('./OpenSearch-Dashboards/package.json').engines.yarn).match(/[.0-9]+/)[0]")"
33+
34+
- name: Setup node
35+
uses: actions/setup-node@v1
36+
with:
37+
node-version: ${{ steps.versions_step.outputs.node_version }}
38+
registry-url: 'https://registry.npmjs.org'
39+
40+
- name: Install correct yarn version for OpenSearch Dashboards
41+
run: |
42+
npm uninstall -g yarn
43+
echo "Installing yarn ${{ steps.versions_step.outputs.yarn_version }}"
44+
npm i -g yarn@${{ steps.versions_step.outputs.yarn_version }}
45+
46+
- name: Bootstrap the plugin
47+
working-directory: OpenSearch-Dashboards/plugins/${{ env.PLUGIN_NAME }}
48+
run:
49+
yarn osd bootstrap
50+
51+
- name: lint code base
52+
working-directory: OpenSearch-Dashboards/plugins/${{ env.PLUGIN_NAME }}
53+
run: |
54+
git fetch origin main
55+
CHANGED_FILES=$(git diff --name-only --diff-filter=ACMRTUXB origin/main | grep -E "\.(js|ts|tsx)$")
56+
if [ -n "$CHANGED_FILES" ]; then
57+
echo "Linting changed files..."
58+
yarn lint $CHANGED_FILES
59+
else
60+
echo "No JavaScript/TypeScript files changed."
61+
fi

0 commit comments

Comments
 (0)