Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

WebUI eslint configuration #1847

Merged
merged 32 commits into from
Dec 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
3a45961
Merge pull request #31 from microsoft/master
chicm-ms Aug 6, 2019
633db43
Merge pull request #32 from microsoft/master
chicm-ms Sep 9, 2019
3e926f1
Merge pull request #33 from microsoft/master
chicm-ms Oct 8, 2019
f173789
Merge pull request #34 from microsoft/master
chicm-ms Oct 9, 2019
508850a
Merge pull request #35 from microsoft/master
chicm-ms Oct 9, 2019
5a0e9c9
Merge pull request #36 from microsoft/master
chicm-ms Oct 10, 2019
e7df061
Merge pull request #37 from microsoft/master
chicm-ms Oct 23, 2019
2175cef
Merge pull request #38 from microsoft/master
chicm-ms Oct 29, 2019
2ccbfbb
Merge pull request #39 from microsoft/master
chicm-ms Oct 30, 2019
b29cb0b
Merge pull request #40 from microsoft/master
chicm-ms Oct 30, 2019
4a3ba83
Merge pull request #41 from microsoft/master
chicm-ms Nov 4, 2019
c8a1148
Merge pull request #42 from microsoft/master
chicm-ms Nov 4, 2019
73c6101
Merge pull request #43 from microsoft/master
chicm-ms Nov 5, 2019
6a518a9
Merge pull request #44 from microsoft/master
chicm-ms Nov 11, 2019
a0d587f
Merge pull request #45 from microsoft/master
chicm-ms Nov 12, 2019
e905bfe
Merge pull request #46 from microsoft/master
chicm-ms Nov 14, 2019
4b266f3
Merge pull request #47 from microsoft/master
chicm-ms Nov 15, 2019
237ff4b
Merge pull request #48 from microsoft/master
chicm-ms Nov 21, 2019
682be01
Merge pull request #49 from microsoft/master
chicm-ms Nov 25, 2019
133af82
Merge pull request #50 from microsoft/master
chicm-ms Nov 25, 2019
71a8a25
Merge pull request #51 from microsoft/master
chicm-ms Nov 26, 2019
d2a73bc
Merge pull request #52 from microsoft/master
chicm-ms Nov 26, 2019
198cf5e
Merge pull request #53 from microsoft/master
chicm-ms Dec 5, 2019
cdbfaf9
Merge pull request #54 from microsoft/master
chicm-ms Dec 6, 2019
7e9b29e
Merge pull request #55 from microsoft/master
chicm-ms Dec 10, 2019
d00c46d
Merge pull request #56 from microsoft/master
chicm-ms Dec 10, 2019
de7d1fa
Merge pull request #57 from microsoft/master
chicm-ms Dec 11, 2019
1835ab0
Merge pull request #58 from microsoft/master
chicm-ms Dec 12, 2019
550aa3a
enable webui eslint
chicm-ms Dec 12, 2019
d280cfb
enable react eslint plugin
chicm-ms Dec 12, 2019
9857618
updates
chicm-ms Dec 12, 2019
adc4f2b
updates
chicm-ms Dec 12, 2019
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
5 changes: 4 additions & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ jobs:
set -e
cd src/nni_manager
yarn eslint
# uncomment following 2 lines to enable webui eslint
# cd ../webui
# yarn eslint
displayName: 'Run eslint'
- script: |
python3 -m pip install torch==0.4.1 --user
Expand All @@ -43,7 +46,7 @@ jobs:
displayName: 'Run pylint'
- script: |
python3 -m pip install flake8 --user
EXCLUDES=./src/nni_manager/,./tools/nni_annotation/testcase/,./examples/trials/mnist-nas/*/mnist*.py,./examples/trials/nas_cifar10/src/cifar10/general_child.py
EXCLUDES=./src/nni_manager/,./src/webui,./tools/nni_annotation/testcase/,./examples/trials/mnist-nas/*/mnist*.py,./examples/trials/nas_cifar10/src/cifar10/general_child.py
python3 -m flake8 . --count --exclude=$EXCLUDES --select=E9,F63,F72,F82 --show-source --statistics
displayName: 'Run flake8 tests to find Python syntax errors and undefined names'
- script: |
Expand Down
38 changes: 38 additions & 0 deletions src/webui/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"env": {
"browser": true,
"es6": true
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module"
},
"plugins": [
"@typescript-eslint"
],
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
],
"rules": {
"@typescript-eslint/no-explicit-any": 0,
"@typescript-eslint/no-namespace": 0,
"@typescript-eslint/consistent-type-assertions": 0,
"@typescript-eslint/no-inferrable-types": 0,
"no-inner-declarations": 0,
"@typescript-eslint/no-var-requires": 0
},
"ignorePatterns": [
"node_modules/",
"build/",
"**/*.js"
],
"settings": {
"react": {
"version": "detect"
}
}
}
1 change: 0 additions & 1 deletion src/webui/config/paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ module.exports = {
appNodeModules: resolveApp('node_modules'),
appTsConfig: resolveApp('tsconfig.json'),
appTsProdConfig: resolveApp('tsconfig.prod.json'),
appTsLint: resolveApp('tslint.json'),
publicUrl: getPublicUrl(resolveApp('package.json')),
servedPath: getServedPath(resolveApp('package.json')),
};
2 changes: 1 addition & 1 deletion src/webui/config/webpack.config.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ module.exports = {
async: false,
watch: paths.appSrc,
tsconfig: paths.appTsConfig,
tslint: paths.appTsLint,
eslint: false
}),
],
// Some libraries import Node modules but don't use them in the browser.
Expand Down
2 changes: 1 addition & 1 deletion src/webui/config/webpack.config.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ module.exports = {
new ForkTsCheckerWebpackPlugin({
async: false,
tsconfig: paths.appTsProdConfig,
tslint: paths.appTsLint,
eslint: false
}),
],
// Some libraries import Node modules but don't use them in the browser.
Expand Down
10 changes: 7 additions & 3 deletions src/webui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@
"ts-import-plugin": "^1.4.3",
"ts-loader": "^6.0.4",
"tsconfig-paths-webpack-plugin": "^3.2.0",
"tslint": "^5.7.0",
"tslint-react": "^4.0.0",
"url-loader": "^2.1.0",
"webpack": "^4.39.1",
"webpack-dev-server": "^3.7.2",
Expand All @@ -53,7 +51,8 @@
},
"scripts": {
"build": "node scripts/build.js",
"start": "node --trace-warnings scripts/start.js"
"start": "node --trace-warnings scripts/start.js",
"eslint": "npx eslint ./ --ext .tsx,.ts"
},
"devDependencies": {
"@types/node": "^10.14.14",
Expand All @@ -62,6 +61,11 @@
"@types/react-json-tree": "^0.6.11",
"@types/react-responsive": "^3.0.3",
"@types/react-router": "^3.0.20",
"@typescript-eslint/eslint-plugin": "^2.11.0",
"@typescript-eslint/parser": "^2.11.0",
"eslint": "^6.7.2",
"eslint-plugin-react": "^7.17.0",
"npx": "^10.2.0",
"typescript": "^3.5.3"
},
"resolutions": {
Expand Down
1 change: 0 additions & 1 deletion src/webui/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ class App extends React.Component<{}, AppState> {
}
const reactPropsChildren = React.Children.map(this.props.children, child =>
React.cloneElement(
// tslint:disable-next-line:no-any
child as React.ReactElement<any>, {
interval,
columnList, changeColumn: this.changeColumn,
Expand Down
1 change: 0 additions & 1 deletion src/webui/src/components/overview/TrialProfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class TrialInfo extends React.Component<TrialInfoProps, {}> {
'id', 'logDir', 'startTime', 'endTime',
'experimentName', 'searchSpace', 'trainingServicePlatform'
];
// tslint:disable-next-line:no-any
const filter = (key: string, val: any) => {
if (key === 'trialConcurrency') {
return this.props.concurrency;
Expand Down
57 changes: 28 additions & 29 deletions src/webui/src/registerServiceWorker.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// tslint:disable:no-console
// In production, we register a service worker to serve assets from local cache.

// This lets the app load faster on subsequent visits in production, and gives
Expand All @@ -19,34 +18,6 @@ const isLocalhost = Boolean(
)
);

export default function register() {
if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
// The URL constructor is available in all browsers that support SW.
const publicUrl = new URL(
process.env.PUBLIC_URL!,
window.location.toString()
);
if (publicUrl.origin !== window.location.origin) {
// Our service worker won't work if PUBLIC_URL is on a different origin
// from what our page is served on. This might happen if a CDN is used to
// serve assets; see https://github.com/facebookincubator/create-react-app/issues/2374
return;
}

window.addEventListener('load', () => {
const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;

if (!isLocalhost) {
// Is not local host. Just register service worker
registerValidSW(swUrl);
} else {
// This is running on localhost. Lets check if a service worker still exists or not.
checkValidServiceWorker(swUrl);
}
});
}
}

function registerValidSW(swUrl: string) {
navigator.serviceWorker
.register(swUrl)
Expand Down Expand Up @@ -105,6 +76,34 @@ function checkValidServiceWorker(swUrl: string) {
});
}

export default function register() {
if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
// The URL constructor is available in all browsers that support SW.
const publicUrl = new URL(
process.env.PUBLIC_URL!,
window.location.toString()
);
if (publicUrl.origin !== window.location.origin) {
// Our service worker won't work if PUBLIC_URL is on a different origin
// from what our page is served on. This might happen if a CDN is used to
// serve assets; see https://github.com/facebookincubator/create-react-app/issues/2374
return;
}

window.addEventListener('load', () => {
const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;

if (!isLocalhost) {
// Is not local host. Just register service worker
registerValidSW(swUrl);
} else {
// This is running on localhost. Lets check if a service worker still exists or not.
checkValidServiceWorker(swUrl);
}
});
}
}

export function unregister() {
if ('serviceWorker' in navigator) {
navigator.serviceWorker.ready.then(registration => {
Expand Down
4 changes: 2 additions & 2 deletions src/webui/src/static/function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const convertDuration = (num: number) => {
const hour = Math.floor(num / 3600);
const minute = Math.floor(num / 60 % 60);
const second = Math.floor(num % 60);
let result = [ ];
const result = [ ];
if (hour > 0) {
result.push(`${hour}h`);
}
Expand Down Expand Up @@ -163,7 +163,7 @@ const downFile = (content: string, fileName: string) => {
downTag.download = fileName;
downTag.href = URL.createObjectURL(file);
});
let eventMouse = document.createEvent('MouseEvents');
const eventMouse = document.createEvent('MouseEvents');
eventMouse.initEvent('click', false, false);
downTag.dispatchEvent(eventMouse);
}
Expand Down
2 changes: 0 additions & 2 deletions src/webui/src/static/interface.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// tslint:disable:no-any

// draw accuracy graph data interface
interface TableObj {
key: number;
Expand Down
2 changes: 1 addition & 1 deletion src/webui/src/static/model/trial.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class Trial implements TableObj {
}

get description(): Parameters {
let ret: Parameters = {
const ret: Parameters = {
parameters: { },
intermediate: [ ],
multiProgress: 1
Expand Down
24 changes: 12 additions & 12 deletions src/webui/src/static/model/trialmanager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@ import { MANAGER_IP, METRIC_GROUP_UPDATE_THRESHOLD, METRIC_GROUP_UPDATE_SIZE } f
import { MetricDataRecord, TableRecord, TrialJobInfo } from '../interface';
import { Trial } from './trial';

function groupMetricsByTrial(metrics: MetricDataRecord[]): Map<string, MetricDataRecord[]> {
const ret = new Map<string, MetricDataRecord[]>();
for (const metric of metrics) {
if (ret.has(metric.trialJobId)) {
ret.get(metric.trialJobId)!.push(metric);
} else {
ret.set(metric.trialJobId, [ metric ]);
}
}
return ret;
}

class TrialManager {
private trials: Map<string, Trial> = new Map<string, Trial>();
private infoInitialized: boolean = false;
Expand Down Expand Up @@ -141,16 +153,4 @@ class TrialManager {
}
}

function groupMetricsByTrial(metrics: MetricDataRecord[]): Map<string, MetricDataRecord[]> {
const ret = new Map<string, MetricDataRecord[]>();
for (const metric of metrics) {
if (ret.has(metric.trialJobId)) {
ret.get(metric.trialJobId)!.push(metric);
} else {
ret.set(metric.trialJobId, [ metric ]);
}
}
return ret;
}

export { TrialManager };
111 changes: 0 additions & 111 deletions src/webui/tslint.json

This file was deleted.

Loading