Skip to content

Commit 874838d

Browse files
author
Martha Cryan
authored
Add linter to CI (#113)
* Run linter on all code * Add lint CI check * Add lint CI check * Add lint CI check * Add lint CI check * Add lint CI check * Add lint CI check * Resolve dependencies to prevent install errors * Add pre-commit lint * Add config for lint-staged
1 parent 969977c commit 874838d

25 files changed

+857
-705
lines changed

.github/workflows/lint.yml

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#
2+
# Copyright 2018-2022 Elyra Authors
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
17+
name: Validate
18+
19+
on: [push, pull_request]
20+
21+
jobs:
22+
lint:
23+
name: Lint
24+
runs-on: ubuntu-latest
25+
steps:
26+
- uses: actions/checkout@v2
27+
- uses: actions/setup-node@v2
28+
with:
29+
node-version: '*'
30+
- name: Install
31+
run: npm install
32+
- name: Check format
33+
run: npm run format:check

.lintstagedrc

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"**/*{.ts,.tsx,.js,.jsx,.css,.json}": [
3+
"prettier --write",
4+
"git add"
5+
]
6+
}

Seer-Core/aql-processor/user-data-in/.gitignore

-4
This file was deleted.

package.json

+11-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"adm-zip": "^0.5.9",
1010
"axios": "^0.26.0",
1111
"carbon-components": "^10.52.0",
12-
"carbon-components-react": "^7.52.0",
12+
"carbon-components-react": "^7.50.0",
1313
"carbon-icons": "^7.0.7",
1414
"classnames": "^2.3.1",
1515
"cors": "^2.8.5",
@@ -18,12 +18,14 @@
1818
"express-fileupload": "^1.3.1",
1919
"express-rate-limit": "^6.5.2",
2020
"express-validator": "^6.14.2",
21+
"husky": "^2.3.0",
2122
"js-file-download": "^0.4.12",
2223
"js2xmlparser": "^4.0.2",
24+
"lint-staged": "^9.5.0",
2325
"path": "^0.12.7",
2426
"prop-types": "^15.8.1",
25-
"react": "^17.0.2",
26-
"react-dom": "^17.0.2",
27+
"react": "^16.8.6",
28+
"react-dom": "^16.8.6",
2729
"react-intl": "^5.24.6",
2830
"react-redux": "^7.2.6",
2931
"react-scripts": "5.0.0",
@@ -32,8 +34,14 @@
3234
"short-uuid": "^4.2.0",
3335
"url": "^0.11.0"
3436
},
37+
"husky": {
38+
"hooks": {
39+
"pre-commit": "lint-staged"
40+
}
41+
},
3542
"scripts": {
3643
"format": "prettier --write './src/**/*.{js,jsx}'",
44+
"format:check": "prettier --check './src/**/*.{js,jsx}'",
3745
"serve": "node server.js",
3846
"start": "react-scripts start",
3947
"build": "react-scripts build",

src/nlp-visual-editor/components/rhs-panel.jsx

+7-5
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import {
2929
UnionPanel,
3030
LiteralPanel,
3131
FilterPanel,
32-
ConsolidatePanel
32+
ConsolidatePanel,
3333
} from '../nodes/components';
3434

3535
import { isNodeLabelValid } from '../../utils';
@@ -64,10 +64,12 @@ class RHSPanel extends React.Component {
6464
return <LiteralPanel {...node} />;
6565
case 'regex':
6666
return <RegexPanel {...node} />;
67-
case 'filter':
68-
return <FilterPanel {...node} canvasController={canvasController} />;
69-
case 'consolidate':
70-
return <ConsolidatePanel {...node} canvasController={canvasController} />;
67+
case 'filter':
68+
return <FilterPanel {...node} canvasController={canvasController} />;
69+
case 'consolidate':
70+
return (
71+
<ConsolidatePanel {...node} canvasController={canvasController} />
72+
);
7173
case 'dictionary':
7274
return (
7375
<DictionaryPanel {...node} canvasController={canvasController} />

src/nlp-visual-editor/nlp-visual-editor.jsx

+90-71
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,18 @@ import { IntlProvider } from 'react-intl';
1919
import { connect, Provider } from 'react-redux';
2020
import axios from 'axios';
2121
import shortUUID from 'short-uuid';
22-
import { CommonCanvas, CanvasController, CommonProperties } from '@elyra/canvas';
22+
import {
23+
CommonCanvas,
24+
CanvasController,
25+
CommonProperties,
26+
} from '@elyra/canvas';
2327
import { Button, Loading, Modal, Select } from 'carbon-components-react';
2428
import {
2529
Play32,
2630
WarningAlt24,
2731
DocumentDownload32,
2832
Upload16,
29-
SettingsAdjust32
33+
SettingsAdjust32,
3034
} from '@carbon/icons-react';
3135
import nlpPalette from '../config/nlpPalette.json';
3236
import RHSPanel from './components/rhs-panel';
@@ -53,7 +57,7 @@ import {
5357
setShowRightPanel,
5458
setShowDocumentViewer,
5559
setDirty,
56-
setModuleName
60+
setModuleName,
5761
} from '../redux/slice';
5862

5963
const TIMER_TICK = 250; // 1/4 second
@@ -100,13 +104,15 @@ class VisualEditor extends React.Component {
100104
errorMessage: undefined,
101105
languageSelectModal: false,
102106
showSettings: false,
103-
editorSettings: localStorage.getItem('nlpEditorSettings') ? JSON.parse(localStorage.getItem('nlpEditorSettings')) : {
104-
moduleName: 'elyraNLPCanvas',
105-
language: 'en'
106-
}
107+
editorSettings: localStorage.getItem('nlpEditorSettings')
108+
? JSON.parse(localStorage.getItem('nlpEditorSettings'))
109+
: {
110+
moduleName: 'elyraNLPCanvas',
111+
language: 'en',
112+
},
107113
};
108114

109-
this.props.setModuleName( this.state.editorSettings.moduleName);
115+
this.props.setModuleName(this.state.editorSettings.moduleName);
110116

111117
this.canvasController = new CanvasController();
112118
this.canvasController.openPalette();
@@ -414,8 +420,8 @@ class VisualEditor extends React.Component {
414420
this.props.setShowRightPanel({ showPanel: true });
415421
this.props.setShowDocumentViewer({ showViewer: false });
416422
this.setState({
417-
showSettings: true
418-
})
423+
showSettings: true,
424+
});
419425
}
420426

421427
getToolbar = () => {
@@ -522,12 +528,7 @@ class VisualEditor extends React.Component {
522528
tooltip: 'Select Language',
523529
jsx: (
524530
<>
525-
<Button
526-
id={'btn-language'}
527-
size="field"
528-
kind="ghost"
529-
disabled
530-
>
531+
<Button id={'btn-language'} size="field" kind="ghost" disabled>
531532
Language ({languages[this.getCurrentLanguage()]})
532533
</Button>
533534
</>
@@ -665,61 +666,67 @@ class VisualEditor extends React.Component {
665666
parameterDef: {
666667
titleDefinition: {
667668
title: 'NLP Settings',
668-
editable: false
669+
editable: false,
669670
},
670671
current_parameters: {
671672
moduleName: this.state.editorSettings.moduleName,
672-
language: this.getCurrentLanguage()
673+
language: this.getCurrentLanguage(),
673674
},
674-
parameters: [{
675-
id: 'moduleName',
676-
type: 'string',
677-
default: ''
678-
}, {
679-
id: 'language',
680-
type: 'string'
681-
}],
675+
parameters: [
676+
{
677+
id: 'moduleName',
678+
type: 'string',
679+
default: '',
680+
},
681+
{
682+
id: 'language',
683+
type: 'string',
684+
},
685+
],
682686
uihints: {
683687
id: 'Settings',
684688
editor_size: 'medium',
685689
label: {
686-
default: 'General Settings'
690+
default: 'General Settings',
687691
},
688-
parameter_info: [{
689-
parameter_ref: 'moduleName',
690-
label: {
691-
default: 'Module Name'
692+
parameter_info: [
693+
{
694+
parameter_ref: 'moduleName',
695+
label: {
696+
default: 'Module Name',
697+
},
698+
description: {
699+
default: 'Module Name',
700+
},
692701
},
693-
description: {
694-
default: 'Module Name'
695-
}
696-
}],
697-
action_info: [{
698-
id: 'language',
699-
label: {
700-
default: 'Select Language'
702+
],
703+
action_info: [
704+
{
705+
id: 'language',
706+
label: {
707+
default: 'Select Language',
708+
},
709+
control: 'button',
701710
},
702-
control: 'button'
703-
}],
704-
group_info: [{
705-
id: 'settings',
706-
label: {
707-
default: 'Settings'
711+
],
712+
group_info: [
713+
{
714+
id: 'settings',
715+
label: {
716+
default: 'Settings',
717+
},
718+
parameter_refs: ['moduleName'],
708719
},
709-
parameter_refs: [
710-
'moduleName'
711-
],
712-
}, {
713-
id: 'lang',
714-
label: {
715-
default: 'Language'
720+
{
721+
id: 'lang',
722+
label: {
723+
default: 'Language',
724+
},
725+
type: 'actionPanel',
726+
action_refs: ['language'],
716727
},
717-
type: 'actionPanel',
718-
action_refs: [
719-
'language'
720-
],
721-
}]
722-
}
728+
],
729+
},
723730
},
724731
};
725732
}
@@ -740,35 +747,41 @@ class VisualEditor extends React.Component {
740747
ref={(instance) => {
741748
this.CommonProperties = instance;
742749
}}
743-
propertiesConfig={{containerType: "Custom", rightFlyout: true }}
750+
propertiesConfig={{ containerType: 'Custom', rightFlyout: true }}
744751
propertiesInfo={this.getPropertiesInfo()} // required
745752
callbacks={{
746753
applyPropertyChanges: (propertySet) => {
747754
this.setState({
748755
editorSettings: {
749-
moduleName: propertySet.moduleName
750-
}
756+
moduleName: propertySet.moduleName,
757+
},
751758
});
752-
this.props.setModuleName( propertySet.moduleName);
753-
localStorage.setItem('nlpEditorSettings', JSON.stringify({...this.state.editorSettings, ...propertySet}));
759+
this.props.setModuleName(propertySet.moduleName);
760+
localStorage.setItem(
761+
'nlpEditorSettings',
762+
JSON.stringify({
763+
...this.state.editorSettings,
764+
...propertySet,
765+
}),
766+
);
754767
},
755768
closePropertiesDialog: () => {
756769
this.props.setShowRightPanel({ showPanel: false });
757770
this.setState({
758-
showSettings: false
771+
showSettings: false,
759772
});
760773
},
761774
actionHandler: (id, appData, data) => {
762-
switch(id) {
775+
switch (id) {
763776
case 'language':
764777
this.setState({ languageSelectModal: true });
765778
break;
766779
}
767-
}
780+
},
768781
}} // required
769782
light // optional
770783
></CommonProperties>
771-
)
784+
);
772785
}
773786
return (
774787
<Provider store={store}>
@@ -790,10 +803,16 @@ class VisualEditor extends React.Component {
790803
this.setCurrentLanguage(language);
791804
const editorSettings = {
792805
...this.state.editorSettings,
793-
...{language: language}
806+
...{ language: language },
794807
};
795-
this.setState({ languageSelectModal: false, editorSettings: editorSettings });
796-
localStorage.setItem('nlpEditorSettings', JSON.stringify(editorSettings));
808+
this.setState({
809+
languageSelectModal: false,
810+
editorSettings: editorSettings,
811+
});
812+
localStorage.setItem(
813+
'nlpEditorSettings',
814+
JSON.stringify(editorSettings),
815+
);
797816
}}
798817
onRequestClose={() => {
799818
this.setState({ languageSelectModal: false });
@@ -897,7 +916,7 @@ const mapDispatchToProps = (dispatch) => ({
897916
setShowRightPanel: (doShow) => dispatch(setShowRightPanel(doShow)),
898917
setShowDocumentViewer: (doShow) => dispatch(setShowDocumentViewer(doShow)),
899918
setDirty: (dirty) => dispatch(setDirty(dirty)),
900-
setModuleName: (name) => dispatch(setModuleName(name))
919+
setModuleName: (name) => dispatch(setModuleName(name)),
901920
});
902921

903922
export default connect(mapStateToProps, mapDispatchToProps)(VisualEditor);

0 commit comments

Comments
 (0)