Skip to content

Commit e9a3116

Browse files
authored
Add lint script, workflow, and pre-commit hook (#25)
Signed-off-by: Tyler Ohlsen <ohltyler@amazon.com>
1 parent eab9065 commit e9a3116

10 files changed

+206
-9
lines changed
File renamed without changes.

.github/workflows/lint.yml

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Linting workflow
2+
on: [push, pull_request]
3+
env:
4+
OPENSEARCH_DASHBOARDS_VERSION: 'main'
5+
jobs:
6+
run-lint:
7+
name: Run lint script
8+
runs-on: ubuntu-latest
9+
if: github.repository == 'opensearch-project/opensearch-ai-flow-dashboards'
10+
steps:
11+
- name: Checkout OpenSearch Dashboards
12+
uses: actions/checkout@v2
13+
with:
14+
repository: opensearch-project/OpenSearch-Dashboards
15+
ref: ${{ env.OPENSEARCH_DASHBOARDS_VERSION }}
16+
path: OpenSearch-Dashboards
17+
- name: Setup Node
18+
uses: actions/setup-node@v3
19+
with:
20+
node-version-file: './OpenSearch-Dashboards/.nvmrc'
21+
registry-url: 'https://registry.npmjs.org'
22+
- name: Install Yarn
23+
# Need to use bash to avoid having a windows/linux specific step
24+
shell: bash
25+
run: |
26+
YARN_VERSION=$(node -p "require('./OpenSearch-Dashboards/package.json').engines.yarn")
27+
echo "Installing yarn@$YARN_VERSION"
28+
npm i -g yarn@$YARN_VERSION
29+
- run: node -v
30+
- run: yarn -v
31+
- name: Checkout plugin
32+
uses: actions/checkout@v2
33+
with:
34+
path: OpenSearch-Dashboards/plugins/opensearch-ai-flow-dashboards
35+
- name: Bootstrap the plugin
36+
run: |
37+
cd OpenSearch-Dashboards/plugins/opensearch-ai-flow-dashboards
38+
yarn osd bootstrap
39+
- name: Run lint script
40+
run: |
41+
cd OpenSearch-Dashboards/plugins/opensearch-ai-flow-dashboards
42+
yarn lint:es common/* public/* server/*

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ coverage
1515
offline-module-cache/v2/*
1616
offline-module-cache/v1/*
1717
target
18-
._.DS_Store
18+
._.DS_Store
19+
.eslintcache

common/constants.ts

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* Copyright OpenSearch Contributors
33
* SPDX-License-Identifier: Apache-2.0
44
*/
5+
56
export const PLUGIN_ID = 'aiFlowDashboards';
67

78
export const BASE_NODE_API_PATH = '/api/ai_flow';

package.json

+13-4
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,30 @@
88
"plugin_name": "aiFlowDashboards",
99
"plugin_zip_name": "ai-flow-dashboards"
1010
},
11-
"private": true,
1211
"scripts": {
1312
"plugin-helpers": "../../scripts/use_node ../../scripts/plugin_helpers",
1413
"osd": "../../scripts/use_node ../../scripts/osd",
15-
"opensearch": "node ../../scripts/opensearch",
16-
"lint": "node ../../scripts/eslint .",
14+
"opensearch": "../../scripts/use_node ../../scripts/opensearch",
15+
"lint:es": "../../scripts/use_node ../../scripts/eslint",
16+
"lint:es:precommit": "yarn lint:es common/* public/* server/*",
1717
"build": "yarn plugin-helpers build && echo Renaming artifact to $npm_package_config_plugin_zip_name-$npm_package_config_plugin_version.zip && mv ./build/$npm_package_config_plugin_name*.zip ./build/$npm_package_config_plugin_zip_name-$npm_package_config_plugin_version.zip"
1818
},
19+
"repository": {
20+
"type": "git",
21+
"url": "https://github.com/opensearch-project/opensearch-ai-flow-dashboards.git"
22+
},
23+
"pre-commit": [
24+
"lint:es:precommit"
25+
],
1926
"lint-staged": {
2027
"*.{ts,tsx,js,jsx,json,css,md}": [
2128
"prettier --write",
2229
"git add"
2330
]
2431
},
25-
"devDependencies": {},
2632
"dependencies": {},
33+
"devDependencies": {
34+
"pre-commit": "^1.2.2"
35+
},
2736
"resolutions": {}
2837
}

public/app.tsx

+4-3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { Navigation, APP_PATH } from './utils';
1212
import { Overview, UseCases, Workflows } from './pages';
1313
import { CoreServicesConsumer } from './core_services';
1414

15+
// eslint-disable-next-line @typescript-eslint/no-empty-interface
1516
interface Props extends RouteComponentProps {}
1617

1718
export const AiFlowDashboardsApp = (props: Props) => {
@@ -58,16 +59,16 @@ export const AiFlowDashboardsApp = (props: Props) => {
5859
<Switch>
5960
<Route
6061
path={APP_PATH.USE_CASES}
61-
render={(props: RouteComponentProps) => <UseCases />}
62+
render={(routeProps: RouteComponentProps) => <UseCases />}
6263
/>
6364
<Route
6465
path={APP_PATH.WORKFLOWS}
65-
render={(props: RouteComponentProps) => <Workflows />}
66+
render={(routeProps: RouteComponentProps) => <Workflows />}
6667
/>
6768
{/* Defaulting to Overview page */}
6869
<Route
6970
path={`${APP_PATH.HOME}`}
70-
render={(props: RouteComponentProps) => <Overview />}
71+
render={(routeProps: RouteComponentProps) => <Overview />}
7172
/>
7273
</Switch>
7374
</EuiPageTemplate>

public/plugin.ts

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export class AiFlowDashboardsPlugin
2525
category: {
2626
id: 'opensearch',
2727
label: 'OpenSearch plugins',
28+
// TODO: this may change after plugin position is finalized
2829
order: 2000,
2930
},
3031
// TODO: can i remove this below order

public/render_app.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export const renderApp = (
2222
<AiFlowDashboardsApp {...props} />
2323
</CoreServicesContext.Provider>
2424
)}
25-
></Route>
25+
/>
2626
</Router>,
2727
element
2828
);

yarn.lock

+142
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,145 @@
22
# yarn lockfile v1
33

44

5+
buffer-from@^1.0.0:
6+
version "1.1.2"
7+
resolved "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz"
8+
integrity sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==
9+
10+
concat-stream@^1.4.7:
11+
version "1.6.2"
12+
resolved "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz"
13+
integrity sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==
14+
dependencies:
15+
buffer-from "^1.0.0"
16+
inherits "^2.0.3"
17+
readable-stream "^2.2.2"
18+
typedarray "^0.0.6"
19+
20+
core-util-is@~1.0.0:
21+
version "1.0.3"
22+
resolved "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz"
23+
integrity sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==
24+
25+
cross-spawn@^5.0.1:
26+
version "5.1.0"
27+
resolved "https://registry.npmjs.org/cross-spawn/-/cross-spawn-5.1.0.tgz"
28+
integrity sha512-pTgQJ5KC0d2hcY8eyL1IzlBPYjTkyH72XRZPnLyKus2mBfNjQs3klqbJU2VILqZryAZUt9JOb3h/mWMy23/f5A==
29+
dependencies:
30+
lru-cache "^4.0.1"
31+
shebang-command "^1.2.0"
32+
which "^1.2.9"
33+
34+
inherits@^2.0.3, inherits@~2.0.3:
35+
version "2.0.4"
36+
resolved "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz"
37+
integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==
38+
39+
isarray@~1.0.0:
40+
version "1.0.0"
41+
resolved "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz"
42+
integrity sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==
43+
44+
isexe@^2.0.0:
45+
version "2.0.0"
46+
resolved "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz"
47+
integrity sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==
48+
49+
lru-cache@^4.0.1:
50+
version "4.1.5"
51+
resolved "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.5.tgz"
52+
integrity sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g==
53+
dependencies:
54+
pseudomap "^1.0.2"
55+
yallist "^2.1.2"
56+
57+
os-shim@^0.1.2:
58+
version "0.1.3"
59+
resolved "https://registry.npmjs.org/os-shim/-/os-shim-0.1.3.tgz"
60+
integrity sha512-jd0cvB8qQ5uVt0lvCIexBaROw1KyKm5sbulg2fWOHjETisuCzWyt+eTZKEMs8v6HwzoGs8xik26jg7eCM6pS+A==
61+
62+
pre-commit@^1.2.2:
63+
version "1.2.2"
64+
resolved "https://registry.yarnpkg.com/pre-commit/-/pre-commit-1.2.2.tgz#dbcee0ee9de7235e57f79c56d7ce94641a69eec6"
65+
integrity sha512-qokTiqxD6GjODy5ETAIgzsRgnBWWQHQH2ghy86PU7mIn/wuWeTwF3otyNQZxWBwVn8XNr8Tdzj/QfUXpH+gRZA==
66+
dependencies:
67+
cross-spawn "^5.0.1"
68+
spawn-sync "^1.0.15"
69+
which "1.2.x"
70+
71+
process-nextick-args@~2.0.0:
72+
version "2.0.1"
73+
resolved "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz"
74+
integrity sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==
75+
76+
pseudomap@^1.0.2:
77+
version "1.0.2"
78+
resolved "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz"
79+
integrity sha512-b/YwNhb8lk1Zz2+bXXpS/LK9OisiZZ1SNsSLxN1x2OXVEhW2Ckr/7mWE5vrC1ZTiJlD9g19jWszTmJsB+oEpFQ==
80+
81+
readable-stream@^2.2.2:
82+
version "2.3.8"
83+
resolved "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz"
84+
integrity sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==
85+
dependencies:
86+
core-util-is "~1.0.0"
87+
inherits "~2.0.3"
88+
isarray "~1.0.0"
89+
process-nextick-args "~2.0.0"
90+
safe-buffer "~5.1.1"
91+
string_decoder "~1.1.1"
92+
util-deprecate "~1.0.1"
93+
94+
safe-buffer@~5.1.0, safe-buffer@~5.1.1:
95+
version "5.1.2"
96+
resolved "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz"
97+
integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==
98+
99+
shebang-command@^1.2.0:
100+
version "1.2.0"
101+
resolved "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz"
102+
integrity sha512-EV3L1+UQWGor21OmnvojK36mhg+TyIKDh3iFBKBohr5xeXIhNBcx8oWdgkTEEQ+BEFFYdLRuqMfd5L84N1V5Vg==
103+
dependencies:
104+
shebang-regex "^1.0.0"
105+
106+
shebang-regex@^1.0.0:
107+
version "1.0.0"
108+
resolved "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz"
109+
integrity sha512-wpoSFAxys6b2a2wHZ1XpDSgD7N9iVjg29Ph9uV/uaP9Ex/KXlkTZTeddxDPSYQpgvzKLGJke2UU0AzoGCjNIvQ==
110+
111+
spawn-sync@^1.0.15:
112+
version "1.0.15"
113+
resolved "https://registry.npmjs.org/spawn-sync/-/spawn-sync-1.0.15.tgz"
114+
integrity sha512-9DWBgrgYZzNghseho0JOuh+5fg9u6QWhAWa51QC7+U5rCheZ/j1DrEZnyE0RBBRqZ9uEXGPgSSM0nky6burpVw==
115+
dependencies:
116+
concat-stream "^1.4.7"
117+
os-shim "^0.1.2"
118+
119+
string_decoder@~1.1.1:
120+
version "1.1.1"
121+
resolved "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz"
122+
integrity sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==
123+
dependencies:
124+
safe-buffer "~5.1.0"
125+
126+
typedarray@^0.0.6:
127+
version "0.0.6"
128+
resolved "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz"
129+
integrity sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==
130+
131+
util-deprecate@~1.0.1:
132+
version "1.0.2"
133+
resolved "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz"
134+
integrity sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==
135+
136+
which@1.2.x, which@^1.2.9:
137+
version "1.2.14"
138+
resolved "https://registry.npmjs.org/which/-/which-1.2.14.tgz"
139+
integrity sha512-16uPglFkRPzgiUXYMi1Jf8Z5EzN1iB4V0ZtMXcHZnwsBtQhhHeCqoWw7tsUY42hJGNDWtUsVLTjakIa5BgAxCw==
140+
dependencies:
141+
isexe "^2.0.0"
142+
143+
yallist@^2.1.2:
144+
version "2.1.2"
145+
resolved "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz"
146+
integrity sha512-ncTzHV7NvsQZkYe1DW7cbDLm0YpzHmZF5r/iyP3ZnQtMiJ+pjzisCiMNI+Sj+xQF5pXhSHxSB3uDbsBTzY/c2A==

0 commit comments

Comments
 (0)