Skip to content

Commit

Permalink
Fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
jtpio committed Nov 19, 2020
1 parent 558ef8c commit 3bf3812
Show file tree
Hide file tree
Showing 7 changed files with 117 additions and 85 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ jobs:
run: |
cd labextension/
jlpm
jlpm run eslint:check
jlpm run lint:check
21 changes: 14 additions & 7 deletions labextension/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,25 @@ module.exports = {
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended'
'plugin:prettier/recommended',
],
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
sourceType: 'module'
sourceType: 'module',
},
plugins: ['@typescript-eslint'],
rules: {
'@typescript-eslint/interface-name-prefix': [
'@typescript-eslint/naming-convention': [
'error',
{ prefixWithI: 'always' }
{
selector: 'interface',
format: ['PascalCase'],
custom: {
regex: '^I[A-Z]',
match: true,
},
},
],
'@typescript-eslint/no-unused-vars': ['warn', { args: 'none' }],
'@typescript-eslint/no-explicit-any': 'off',
Expand All @@ -23,10 +30,10 @@ module.exports = {
'@typescript-eslint/quotes': [
'error',
'single',
{ avoidEscape: true, allowTemplateLiterals: false }
{ avoidEscape: true, allowTemplateLiterals: false },
],
curly: ['error', 'all'],
eqeqeq: 'error',
'prefer-arrow-callback': 'error'
}
'prefer-arrow-callback': 'error',
},
};
15 changes: 9 additions & 6 deletions labextension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@
"eslint": "eslint . --ext .ts,.tsx --fix",
"eslint:check": "eslint . --ext .ts,.tsx",
"install:extension": "jupyter labextension develop --overwrite .",
"lint:check": "jlpm run eslint:check && jlpm run prettier:check",
"prepare": "jlpm run clean && jlpm run build:prod",
"prettier": "prettier --write '**/*{.ts,.tsx,.js,.jsx,.css,.json,.md}'",
"prettier:check": "prettier --list-different \"**/*{.ts,.tsx,.js,.jsx,.css,.json,.md}\"",
"watch": "run-p watch:src watch:labextension",
"watch:src": "tsc -w",
"watch:labextension": "jupyter labextension watch ."
Expand All @@ -53,13 +56,13 @@
},
"devDependencies": {
"@jupyterlab/builder": "^3.0.0-rc.10",
"@typescript-eslint/eslint-plugin": "^2.27.0",
"@typescript-eslint/parser": "^2.27.0",
"eslint": "^7.5.0",
"eslint-config-prettier": "^6.10.1",
"eslint-plugin-prettier": "^3.1.2",
"@typescript-eslint/eslint-plugin": "^4.2.0",
"@typescript-eslint/parser": "^4.2.0",
"eslint": "^7.10.0",
"eslint-config-prettier": "^6.15.0",
"eslint-plugin-prettier": "^3.1.4",
"npm-run-all": "^4.1.5",
"prettier": "^1.19.0",
"prettier": "^2.1.2",
"rimraf": "^3.0.2",
"typescript": "~4.0.3"
},
Expand Down
29 changes: 11 additions & 18 deletions labextension/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
import {
JupyterFrontEnd,
JupyterFrontEndPlugin
JupyterFrontEndPlugin,
} from '@jupyterlab/application';

import {
IStatusBar,
} from '@jupyterlab/statusbar';
import { IStatusBar } from '@jupyterlab/statusbar';

import {
ITranslator
} from '@jupyterlab/translation';
import { ITranslator } from '@jupyterlab/translation';

import { MemoryUsage } from './memoryUsage';

Expand All @@ -27,17 +23,14 @@ const extension: JupyterFrontEndPlugin<void> = {
) => {
const item = new MemoryUsage(translator);

statusBar.registerStatusItem(
'nbresuse:memory-usage-status',
{
item,
align: 'left',
rank: 2,
isActive: () => item.model!.metricsAvailable,
activeStateChanged: item.model!.stateChanged
}
);
}
statusBar.registerStatusItem('nbresuse:memory-usage-status', {
item,
align: 'left',
rank: 2,
isActive: () => item.model.metricsAvailable,
activeStateChanged: item.model.stateChanged,
});
},
};

export default extension;
20 changes: 10 additions & 10 deletions labextension/src/memoryUsage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { ServerConnection } from '@jupyterlab/services';
import {
nullTranslator,
ITranslator,
TranslationBundle
TranslationBundle,
} from '@jupyterlab/translation';

import { Poll } from '@lumino/polling';
Expand All @@ -37,9 +37,9 @@ export class MemoryUsage extends VDomRenderer<MemoryUsage.Model> {
/**
* Render the memory usage status item.
*/
render() {
render(): JSX.Element {
if (!this.model) {
return null;
return <div></div>;
}
let text: string;
if (this.model.memoryLimit === null) {
Expand Down Expand Up @@ -94,11 +94,11 @@ export namespace MemoryUsage {
factory: () => Private.factory(),
frequency: {
interval: options.refreshRate,
backoff: true
backoff: true,
},
name: '@jupyterlab/statusbar:MemoryUsage#metrics'
name: '@jupyterlab/statusbar:MemoryUsage#metrics',
});
this._poll.ticked.connect(poll => {
this._poll.ticked.connect((poll) => {
const { payload, phase } = poll.state;
if (phase === 'resolved') {
this._updateMetricsValues(payload);
Expand Down Expand Up @@ -210,12 +210,12 @@ export namespace MemoryUsage {
}
}

private _currentMemory: number = 0;
private _currentMemory = 0;
private _memoryLimit: number | null = null;
private _metricsAvailable: boolean = false;
private _metricsAvailable = false;
private _poll: Poll<Private.IMetricRequestResult | null>;
private _units: MemoryUnit = 'B';
private _warn: boolean = false;
private _warn = false;
}

/**
Expand Down Expand Up @@ -259,7 +259,7 @@ namespace Private {
MB: 1048576,
GB: 1073741824,
TB: 1099511627776,
PB: 1125899906842624
PB: 1125899906842624,
};

/**
Expand Down
4 changes: 2 additions & 2 deletions labextension/src/text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import { style } from 'typestyle/lib';

export const baseText: NestedCSSProperties = {
fontSize: vars.fontSize,
fontFamily: vars.fontFamily
fontFamily: vars.fontFamily,
};

export const nbresuse = style(baseText, {
backgroundColor: '#FFD2D2',
color: '#D8000C'
color: '#D8000C',
});
111 changes: 70 additions & 41 deletions labextension/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -580,11 +580,6 @@
"@types/eslint" "*"
"@types/estree" "*"

"@types/eslint-visitor-keys@^1.0.0":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@types/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz#1ee30d79544ca84d68d4b3cdb0af4f205663dd2d"
integrity sha512-OCutwjDZ4aFS6PB1UZ988C4YgwlBHJd6wCeQqaLdmadZ/7e+w79+hbMUFC1QXDNCmdyoRfAFdm0RypzwR+Qpag==

"@types/eslint@*":
version "7.2.5"
resolved "https://registry.yarnpkg.com/@types/eslint/-/eslint-7.2.5.tgz#92172ecf490c2fce4b076739693d75f30376d610"
Expand Down Expand Up @@ -634,49 +629,76 @@
"@types/prop-types" "*"
csstype "^3.0.2"

"@typescript-eslint/eslint-plugin@^2.27.0":
version "2.34.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.34.0.tgz#6f8ce8a46c7dea4a6f1d171d2bb8fbae6dac2be9"
integrity sha512-4zY3Z88rEE99+CNvTbXSyovv2z9PNOVffTWD2W8QF5s2prBQtwN2zadqERcrHpcR7O/+KMI3fcTAmUUhK/iQcQ==
"@typescript-eslint/eslint-plugin@^4.2.0":
version "4.8.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.8.1.tgz#b362abe0ee478a6c6d06c14552a6497f0b480769"
integrity sha512-d7LeQ7dbUrIv5YVFNzGgaW3IQKMmnmKFneRWagRlGYOSfLJVaRbj/FrBNOBC1a3tVO+TgNq1GbHvRtg1kwL0FQ==
dependencies:
"@typescript-eslint/experimental-utils" "2.34.0"
"@typescript-eslint/experimental-utils" "4.8.1"
"@typescript-eslint/scope-manager" "4.8.1"
debug "^4.1.1"
functional-red-black-tree "^1.0.1"
regexpp "^3.0.0"
semver "^7.3.2"
tsutils "^3.17.1"

"@typescript-eslint/experimental-utils@2.34.0":
version "2.34.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-2.34.0.tgz#d3524b644cdb40eebceca67f8cf3e4cc9c8f980f"
integrity sha512-eS6FTkq+wuMJ+sgtuNTtcqavWXqsflWcfBnlYhg/nS4aZ1leewkXGbvBhaapn1q6qf4M71bsR1tez5JTRMuqwA==
"@typescript-eslint/experimental-utils@4.8.1":
version "4.8.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-4.8.1.tgz#27275c20fa4336df99ebcf6195f7d7aa7aa9f22d"
integrity sha512-WigyLn144R3+lGATXW4nNcDJ9JlTkG8YdBWHkDlN0lC3gUGtDi7Pe3h5GPvFKMcRz8KbZpm9FJV9NTW8CpRHpg==
dependencies:
"@types/json-schema" "^7.0.3"
"@typescript-eslint/typescript-estree" "2.34.0"
"@typescript-eslint/scope-manager" "4.8.1"
"@typescript-eslint/types" "4.8.1"
"@typescript-eslint/typescript-estree" "4.8.1"
eslint-scope "^5.0.0"
eslint-utils "^2.0.0"

"@typescript-eslint/parser@^2.27.0":
version "2.34.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-2.34.0.tgz#50252630ca319685420e9a39ca05fe185a256bc8"
integrity sha512-03ilO0ucSD0EPTw2X4PntSIRFtDPWjrVq7C3/Z3VQHRC7+13YB55rcJI3Jt+YgeHbjUdJPcPa7b23rXCBokuyA==
"@typescript-eslint/parser@^4.2.0":
version "4.8.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-4.8.1.tgz#4fe2fbdbb67485bafc4320b3ae91e34efe1219d1"
integrity sha512-QND8XSVetATHK9y2Ltc/XBl5Ro7Y62YuZKnPEwnNPB8E379fDsvzJ1dMJ46fg/VOmk0hXhatc+GXs5MaXuL5Uw==
dependencies:
"@types/eslint-visitor-keys" "^1.0.0"
"@typescript-eslint/experimental-utils" "2.34.0"
"@typescript-eslint/typescript-estree" "2.34.0"
eslint-visitor-keys "^1.1.0"
"@typescript-eslint/scope-manager" "4.8.1"
"@typescript-eslint/types" "4.8.1"
"@typescript-eslint/typescript-estree" "4.8.1"
debug "^4.1.1"

"@typescript-eslint/[email protected]":
version "2.34.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-2.34.0.tgz#14aeb6353b39ef0732cc7f1b8285294937cf37d5"
integrity sha512-OMAr+nJWKdlVM9LOqCqh3pQQPwxHAN7Du8DR6dmwCrAmxtiXQnhHJ6tBNtf+cggqfo51SG/FCwnKhXCIM7hnVg==
"@typescript-eslint/[email protected]":
version "4.8.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-4.8.1.tgz#e343c475f8f1d15801b546cb17d7f309b768fdce"
integrity sha512-r0iUOc41KFFbZdPAdCS4K1mXivnSZqXS5D9oW+iykQsRlTbQRfuFRSW20xKDdYiaCoH+SkSLeIF484g3kWzwOQ==
dependencies:
"@typescript-eslint/types" "4.8.1"
"@typescript-eslint/visitor-keys" "4.8.1"

"@typescript-eslint/[email protected]":
version "4.8.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.8.1.tgz#23829c73c5fc6f4fcd5346a7780b274f72fee222"
integrity sha512-ave2a18x2Y25q5K05K/U3JQIe2Av4+TNi/2YuzyaXLAsDx6UZkz1boZ7nR/N6Wwae2PpudTZmHFXqu7faXfHmA==

"@typescript-eslint/[email protected]":
version "4.8.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.8.1.tgz#7307e3f2c9e95df7daa8dc0a34b8c43b7ec0dd32"
integrity sha512-bJ6Fn/6tW2g7WIkCWh3QRlaSU7CdUUK52shx36/J7T5oTQzANvi6raoTsbwGM11+7eBbeem8hCCKbyvAc0X3sQ==
dependencies:
"@typescript-eslint/types" "4.8.1"
"@typescript-eslint/visitor-keys" "4.8.1"
debug "^4.1.1"
eslint-visitor-keys "^1.1.0"
glob "^7.1.6"
globby "^11.0.1"
is-glob "^4.0.1"
lodash "^4.17.15"
semver "^7.3.2"
tsutils "^3.17.1"

"@typescript-eslint/[email protected]":
version "4.8.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.8.1.tgz#794f68ee292d1b2e3aa9690ebedfcb3a8c90e3c3"
integrity sha512-3nrwXFdEYALQh/zW8rFwP4QltqsanCDz4CwWMPiIZmwlk9GlvBeueEIbq05SEq4ganqM0g9nh02xXgv5XI3PeQ==
dependencies:
"@typescript-eslint/types" "4.8.1"
eslint-visitor-keys "^2.0.0"

"@webassemblyjs/[email protected]":
version "1.9.0"
resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.9.0.tgz#bd850604b4042459a5a41cd7d338cbed695ed964"
Expand Down Expand Up @@ -1527,14 +1549,14 @@ escape-string-regexp@^1.0.5:
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4"
integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=

eslint-config-prettier@^6.10.1:
eslint-config-prettier@^6.15.0:
version "6.15.0"
resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-6.15.0.tgz#7f93f6cb7d45a92f1537a70ecc06366e1ac6fed9"
integrity sha512-a1+kOYLR8wMGustcgAjdydMsQ2A/2ipRPwRKUmfYaSxc9ZPcrku080Ctl6zrZzZNs/U82MjSv+qKREkoq3bJaw==
dependencies:
get-stdin "^6.0.0"

eslint-plugin-prettier@^3.1.2:
eslint-plugin-prettier@^3.1.4:
version "3.1.4"
resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-3.1.4.tgz#168ab43154e2ea57db992a2cd097c828171f75c2"
integrity sha512-jZDa8z76klRqo+TdGDTFJSavwbnWK2ZpqGKNZ+VvweMW516pDUMmQ2koXvxEE4JhzNvTv+radye/bWGBmA6jmg==
Expand Down Expand Up @@ -1566,7 +1588,7 @@ eslint-visitor-keys@^2.0.0:
resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-2.0.0.tgz#21fdc8fbcd9c795cc0321f0563702095751511a8"
integrity sha512-QudtT6av5WXels9WjIM7qz1XD1cWGvX4gGXvp/zBn9nXG02D0utdU3Em2m/QjTnrsk6bBjmCygl3rmj118msQQ==

eslint@^7.5.0:
eslint@^7.10.0:
version "7.13.0"
resolved "https://registry.yarnpkg.com/eslint/-/eslint-7.13.0.tgz#7f180126c0dcdef327bfb54b211d7802decc08da"
integrity sha512-uCORMuOO8tUzJmsdRtrvcGq5qposf7Rw0LwkTJkoDbOycVQtQjmnhZSuLQnozLE4TmAzlMVV45eCHmQ1OpDKUQ==
Expand Down Expand Up @@ -1691,7 +1713,7 @@ fast-diff@^1.1.2:
resolved "https://registry.yarnpkg.com/fast-diff/-/fast-diff-1.2.0.tgz#73ee11982d86caaf7959828d519cfe927fac5f03"
integrity sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w==

fast-glob@^3.0.3:
fast-glob@^3.0.3, fast-glob@^3.1.1:
version "3.2.4"
resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.4.tgz#d20aefbf99579383e7f3cc66529158c9b98554d3"
integrity sha512-kr/Oo6PX51265qeuCYsyGypiO5uJFgBS0jksyG7FUeCyQzNwYnzrNIMR1NXfkZXsMYXYLRAHgISHBz8gQcxKHQ==
Expand Down Expand Up @@ -1867,7 +1889,7 @@ glob-to-regexp@^0.4.1:
resolved "https://registry.yarnpkg.com/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz#c75297087c851b9a578bd217dd59a92f59fe546e"
integrity sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw==

glob@^7.1.3, glob@^7.1.4, glob@^7.1.6, glob@~7.1.6:
glob@^7.1.3, glob@^7.1.4, glob@~7.1.6:
version "7.1.6"
resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.6.tgz#141f33b81a7c2492e125594307480c46679278a6"
integrity sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==
Expand Down Expand Up @@ -1900,6 +1922,18 @@ [email protected]:
merge2 "^1.2.3"
slash "^3.0.0"

globby@^11.0.1:
version "11.0.1"
resolved "https://registry.yarnpkg.com/globby/-/globby-11.0.1.tgz#9a2bf107a068f3ffeabc49ad702c79ede8cfd357"
integrity sha512-iH9RmgwCmUJHi2z5o2l3eTtGBtXek1OYlHrbcxOYugyHLmAsZrPj43OtHThd62Buh/Vv6VyCBD2bdyWcGNQqoQ==
dependencies:
array-union "^2.1.0"
dir-glob "^3.0.1"
fast-glob "^3.1.1"
ignore "^5.1.4"
merge2 "^1.3.0"
slash "^3.0.0"

got@^9.6.0:
version "9.6.0"
resolved "https://registry.yarnpkg.com/got/-/got-9.6.0.tgz#edf45e7d67f99545705de1f7bbeeeb121765ed85"
Expand Down Expand Up @@ -1998,7 +2032,7 @@ ignore@^4.0.6:
resolved "https://registry.yarnpkg.com/ignore/-/ignore-4.0.6.tgz#750e3db5862087b4737ebac8207ffd1ef27b25fc"
integrity sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==

ignore@^5.1.1:
ignore@^5.1.1, ignore@^5.1.4:
version "5.1.8"
resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.1.8.tgz#f150a8b50a34289b33e22f5889abd4d8016f0e57"
integrity sha512-BMpfD7PpiETpBl/A6S498BaIJ6Y/ABT93ETbby2fP00v4EbvPBXWEoaR1UBPKs3iR53pJY7EtZk5KACI57i1Uw==
Expand Down Expand Up @@ -2854,12 +2888,7 @@ prettier-linter-helpers@^1.0.0:
dependencies:
fast-diff "^1.1.2"

prettier@^1.19.0:
version "1.19.1"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.19.1.tgz#f7d7f5ff8a9cd872a7be4ca142095956a60797cb"
integrity sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==

prettier@^2.1.1:
prettier@^2.1.1, prettier@^2.1.2:
version "2.1.2"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.1.2.tgz#3050700dae2e4c8b67c4c3f666cdb8af405e1ce5"
integrity sha512-16c7K+x4qVlJg9rEbXl7HEGmQyZlG4R9AgP+oHKRMsMsuk8s+ATStlf1NpDqyBI1HpVyfjLOeMhH2LvuNvV5Vg==
Expand Down

0 comments on commit 3bf3812

Please sign in to comment.