Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Linter #56

Closed
wants to merge 40 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
d4a55d0
Bump @material-ui/data-grid in /client
dependabot[bot] Mar 1, 2021
3bb1eaa
Bump react-scripts from 4.0.2 to 4.0.3 in /client
dependabot[bot] Mar 1, 2021
8c3ae7d
Bump @testing-library/user-event from 12.7.1 to 12.8.0 in /client
dependabot[bot] Mar 1, 2021
ca21dbb
Bump typescript from 4.1.5 to 4.2.2 in /client
dependabot[bot] Mar 1, 2021
dc2ddea
Merge pull request #8 from nlpsandbox/main
Mar 4, 2021
6d03614
Bump node from 15.9.0-alpine3.12 to 15.11.0-alpine3.12 in /client
dependabot[bot] Mar 4, 2021
9f4556b
Merge pull request #7 from cascadianblue/dependabot/npm_and_yarn/clie…
Mar 4, 2021
1063761
Merge pull request #6 from cascadianblue/dependabot/npm_and_yarn/clie…
Mar 4, 2021
99500a0
Merge branch 'main' into dependabot/npm_and_yarn/client/main/react-sc…
Mar 4, 2021
1d0b15d
Merge pull request #4 from cascadianblue/dependabot/npm_and_yarn/clie…
Mar 4, 2021
26ac218
Bump @testing-library/user-event from 12.7.1 to 12.8.1 in /client
dependabot[bot] Mar 4, 2021
17b6a22
Merge branch 'main' into dependabot/npm_and_yarn/client/main/testing-…
Mar 4, 2021
ffdd15a
Merge pull request #10 from cascadianblue/dependabot/npm_and_yarn/cli…
Mar 4, 2021
fb57e4c
Merge pull request #9 from cascadianblue/dependabot/docker/client/mai…
Mar 4, 2021
b0bf3cc
Merge pull request #5 from cascadianblue/dependabot/npm_and_yarn/clie…
Mar 4, 2021
5f5e9c0
Update ESLint & Add Config File
Mar 12, 2021
873ec3f
Re-format
Mar 12, 2021
e05ba57
Merge branch 'main' of https://github.com/nlpsandbox/phi-deidentifier…
Apr 6, 2021
f3271f8
Merge branch 'main' into add-linter
Apr 6, 2021
090bfe6
Clean up AnnotationView.js
Apr 6, 2021
9fc3772
Fix Up InfoDialog.js
Apr 6, 2021
961eb6f
Fix up DeidentifiedText.js
Apr 6, 2021
7499c68
De-Lint DeidentificationConfigForm.js
Apr 6, 2021
5ab932d
Fix AnnotationView Type Expectations
Apr 13, 2021
591bf61
Import PropTypes in InfoDialog
Apr 13, 2021
82d5310
Delint App.js
Apr 13, 2021
ab517a9
Import React into App.test.js
Apr 13, 2021
13cd292
Add Lint Step to CI
Apr 13, 2021
3a3fa14
Fix Call to ESLint in ci.yml
Apr 13, 2021
1f07a72
Match Linter Call to Local
Apr 13, 2021
d3348d0
Match Linter Call to Local
Apr 13, 2021
064624b
Merge branch 'add-linter' of https://github.com/cascadianblue/phi-dei…
Apr 13, 2021
8d40acb
Match Linter Call to Local
Apr 13, 2021
f726c77
Merge branch 'add-linter' of https://github.com/cascadianblue/phi-dei…
Apr 13, 2021
aec06dc
Merge branch 'add-linter' of https://github.com/cascadianblue/phi-dei…
Apr 13, 2021
e0eceb8
Merge branch 'add-linter' of https://github.com/cascadianblue/phi-dei…
Apr 20, 2021
25ddad8
Merge branch 'add-linter' of https://github.com/cascadianblue/phi-dei…
Apr 20, 2021
0a50b54
Add Useless Newline
boyleconnor Apr 20, 2021
7b77677
Revert "Add Useless Newline"
boyleconnor Apr 20, 2021
8d759f8
Merge branch 'add-linter' of https://github.com/cascadianblue/phi-dei…
boyleconnor Apr 20, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@ env:
docker_repository: nlpsandbox/phi-deidentifier-app

jobs:
build:
env:
working-directory: ./client
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install modules
working-directory: ${{env.working-directory}}
run: npm ci
- name: Run ESLint
working-directory: ${{env.working-directory}}
run: npx eslint
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding the script npm run lint to package.json to make it easy to developer to lint the project. The CI/CD workflow should then rely on the command npm run lint (requires to install dev npm dependencies with npm install --only=dev).

docker:
# needs: [test]
runs-on: ubuntu-latest
Expand Down
21 changes: 21 additions & 0 deletions client/.eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
env:
browser: true
es2021: true
extends:
- 'plugin:react/recommended'
- google
parser: '@typescript-eslint/parser'
parserOptions:
ecmaFeatures:
jsx: true
ecmaVersion: 12
sourceType: module
plugins:
- react
- '@typescript-eslint'
rules:
no-invalid-this: off
require-jsdoc: off
indent:
- error
- 2
131 changes: 114 additions & 17 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"@testing-library/jest-dom": "^5.11.10",
"@testing-library/react": "^11.2.5",
"@testing-library/user-event": "^13.1.1",
"prop-types": "^15.7.2",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-router-dom": "^5.2.0",
Expand Down Expand Up @@ -39,5 +40,12 @@
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^4.17.0",
"@typescript-eslint/parser": "^4.17.0",
"eslint": "^7.21.0",
"eslint-config-google": "^0.14.0",
"eslint-plugin-react": "^7.22.0"
}
}
3 changes: 2 additions & 1 deletion client/src/App.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { render, screen } from '@testing-library/react';
import {render, screen} from '@testing-library/react';
import {React} from 'react';
import App from './App';

test('renders learn react link', () => {
Expand Down
61 changes: 39 additions & 22 deletions client/src/components/AnnotationView.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,56 @@
import { Paper, Zoom } from '@material-ui/core';
import { DataGrid } from '@material-ui/data-grid';
import {Paper} from '@material-ui/core';
import {DataGrid} from '@material-ui/data-grid';
import React from 'react';
import { deidentificationStates } from './DeidentifiedText';

export function AnnotationView(props) {
import {deidentificationStates} from './DeidentifiedText';
import PropTypes from 'prop-types';

function AnnotationView(props) {
const types = [
{type: "text_date", name: "Date", key: "textDateAnnotations"},
{type: "text_physical_address", name: "Physical Address", key: "textPhysicalAddressAnnotations"},
{type: "text_person_name", name: "Person Name", key: "textPersonNameAnnotations"}
]
{type: 'text_date', name: 'Date', key: 'textDateAnnotations'},
{type: 'text_physical_address', name: 'Physical Address', key:
'textPhysicalAddressAnnotations'},
{type: 'text_person_name', name: 'Person Name', key:
'textPersonNameAnnotations'},
];

let allAnnotations;
if (props.annotations === deidentificationStates.EMPTY || props.annotations === deidentificationStates.LOADING || props.annotations === deidentificationStates.ERROR) {
allAnnotations = []
if (props.annotations === deidentificationStates.EMPTY ||
props.annotations === deidentificationStates.LOADING ||
props.annotations === deidentificationStates.ERROR) {
allAnnotations = [];
} else {
allAnnotations = types.map(
(type) => props.annotations[type.key].map((annotation, index) => {
return {type: type.name, id: String(type.type)+'_'+String(index), ...annotation};
})
return {
type: type.name,
id: String(type.type)+'_'+String(index),
...annotation,
};
}),
).flat();
}

const columns = [
{field: 'id', headerName: "ID", hide: true},
{field: 'type', headerName: "Type", width: 125},
{field: 'text', headerName: "Text", width: 130},
{field: 'start', headerName: "Start", width: 90},
{field: 'length', headerName: "Length", width: 100},
{field: 'confidence', headerName: "Confidence", width: 130}
]
{field: 'id', headerName: 'ID', hide: true},
{field: 'type', headerName: 'Type', width: 125},
{field: 'text', headerName: 'Text', width: 130},
{field: 'start', headerName: 'Start', width: 90},
{field: 'length', headerName: 'Length', width: 100},
{field: 'confidence', headerName: 'Confidence', width: 130},
];

return (
<Paper elevation={3} style={{ height: "400px" }}>
<Paper elevation={3} style={{height: '400px'}}>
<DataGrid rows={allAnnotations} columns={columns}/>
</Paper>
);
}
}

AnnotationView.propTypes = {
annotations: PropTypes.oneOfType([
PropTypes.object,
PropTypes.number,
]),
};

export default AnnotationView;
Loading