Skip to content

Commit

Permalink
Bump linters (#12582)
Browse files Browse the repository at this point in the history
* Bump linter versions

* Apply update linters

* Restore fix for typedoc

* Apply suggestion

* Ignore staging webpack config
  • Loading branch information
fcollonval committed May 17, 2022
1 parent 51d2d63 commit b57ec96
Show file tree
Hide file tree
Showing 110 changed files with 1,051 additions and 942 deletions.
12 changes: 7 additions & 5 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,19 @@ docs/api
docs/build
examples/example.spec.ts
examples/federated/core_package/index.template.js
examples/federated/core_package/index.js
examples/federated/labextensions
galata/playwright-report
jupyterlab/chrome-test.js
jupyterlab/geckodriver
jupyterlab/staging/yarn.js
jupyterlab/staging/index.js
jupyterlab/staging/webpack.config.js
packages/extensionmanager-extension/examples/listings
packages/nbconvert-css/raw.js
packages/services/dist
packages/ui-components/src/icon/iconimports.ts
jupyterlab/staging/yarn.js
jupyterlab/staging/index.js
tsconfigdoc.json
galata/playwright-report
examples/federated/core_package/index.js
examples/federated/labextensions

#TypeDoc
typedoc-theme/
Expand Down
34 changes: 26 additions & 8 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,40 @@ module.exports = {
'jest/globals': true
},
globals: {
BigInt: 'readonly',
HTMLCollectionOf: 'readonly',
JSX: 'readonly',
NodeJS: 'readonly'
NodeJS: 'readonly',
RequestInit: 'readonly',
RequestInfo: 'readonly'
},
root: true,
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'prettier/@typescript-eslint',
'plugin:react/recommended',
'plugin:jest/recommended'
'prettier',
'plugin:react/recommended'
],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'jest'],
plugins: ['@typescript-eslint'],
overrides: [
{
files: ['packages/**/*.spec.ts', 'testutils/**/*.spec.ts'],
plugins: ['jest'],
extends: ['plugin:jest/recommended'],
rules: {
'jest/no-conditional-expect': 'warn',
'jest/valid-title': 'warn',
'jest/no-standalone-expect': [
'error',
{
additionalTestBlockFunctions: ['it']
}
]
}
}
],
rules: {
'@typescript-eslint/naming-convention': [
'error',
Expand All @@ -47,10 +67,8 @@ module.exports = {
'@typescript-eslint/no-empty-interface': 'off',
'@typescript-eslint/triple-slash-reference': 'warn',
'@typescript-eslint/no-inferrable-types': 'off',
'jest/no-conditional-expect': 'warn',
'jest/valid-title': 'warn',
camelcase: [
'warn',
'error',
{
allow: [
'__webpack_public_path__',
Expand Down
7 changes: 4 additions & 3 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,18 @@ examples/app/build
examples/app/themes
examples/app/schemas
examples/federated/core_package/index.template.js
examples/federated/core_package/index.js
examples/federated/labextensions
galata/playwright-report
jupyterlab/schemas
jupyterlab/themes
jupyterlab/geckodriver
jupyterlab/staging/yarn.js
jupyterlab/staging/index.js
jupyterlab/staging/webpack.config.js
packages/ui-components/src/icon/iconimports.ts
packages/extensionmanager/examples/listings
tsconfigdoc.json
galata/playwright-report
examples/federated/core_package/index.js
examples/federated/labextensions
typedoc-theme

# jetbrains IDE stuff
Expand Down
4 changes: 2 additions & 2 deletions buildutils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"minimatch": "~3.0.4",
"os": "~0.1.1",
"package-json": "^6.5.0",
"prettier": "~2.1.1",
"prettier": "~2.6.0",
"process": "^0.11.10",
"semver": "^7.3.2",
"sort-package-json": "~1.53.1",
Expand All @@ -64,7 +64,7 @@
"@types/glob": "^7.1.1",
"@types/inquirer": "^7.3.1",
"@types/node": "^14.6.1",
"@types/prettier": "~2.1.0",
"@types/prettier": "~2.6.0",
"rimraf": "~3.0.0"
},
"publishConfig": {
Expand Down
4 changes: 2 additions & 2 deletions dev_mode/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ const Handlebars = require('handlebars');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');
const merge = require('webpack-merge').default;
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer')
.BundleAnalyzerPlugin;
const BundleAnalyzerPlugin =
require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const baseConfig = require('@jupyterlab/builder/lib/webpack.config.base');
const { ModuleFederationPlugin } = webpack.container;

Expand Down
3 changes: 1 addition & 2 deletions galata/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,7 @@ test('Open language menu', async ({ page }) => {
if (request.method() === 'GET') {
return route.fulfill({
status: 200,
body:
'{"data": {"en": {"displayName": "English", "nativeName": "English"}}, "message": ""}'
body: '{"data": {"en": {"displayName": "English", "nativeName": "English"}}, "message": ""}'
});
} else {
return route.continue();
Expand Down
33 changes: 18 additions & 15 deletions galata/src/benchmarkReporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -382,9 +382,9 @@ class BenchmarkReporter implements Reporter {
...result.attachments
.filter(a => a.name === benchmark.DEFAULT_NAME_ATTACHMENT)
.map(raw => {
const json = (JSON.parse(
const json = JSON.parse(
raw.body?.toString() ?? '{}'
) as any) as benchmark.IRecord;
) as any as benchmark.IRecord;
return { ...json, reference: this._reference };
})
);
Expand Down Expand Up @@ -451,10 +451,8 @@ class BenchmarkReporter implements Reporter {
}

// - Create report
const [
reportContentString,
reportExtension
] = await this._buildTextReport(allData);
const [reportContentString, reportExtension] =
await this._buildTextReport(allData);
const reportFile = path.resolve(
outputDir,
`${baseName}.${reportExtension}`
Expand All @@ -470,7 +468,7 @@ class BenchmarkReporter implements Reporter {
const view = new vega.View(vega.parse(vegaSpec), {
renderer: 'canvas'
}).initialize();
const canvas = ((await view.toCanvas()) as any) as canvas.Canvas;
const canvas = (await view.toCanvas()) as any as canvas.Canvas;
const graphFile = path.resolve(outputDir, `${baseName}.png`);
const fileStream = fs.createWriteStream(graphFile);

Expand Down Expand Up @@ -554,10 +552,12 @@ class BenchmarkReporter implements Reporter {
}

const compare =
(groups.values().next().value?.values().next().value as Map<
string,
Map<string, number[]>
>).size === 2;
(
groups.values().next().value?.values().next().value as Map<
string,
Map<string, number[]>
>
).size === 2;

// - Create report
const reportContent = new Array<string>(
Expand All @@ -578,10 +578,13 @@ class BenchmarkReporter implements Reporter {

let header = '| Test file |';
let nFiles = 0;
for (const [
file
] of groups.values().next().value.values().next().value.values().next()
.value) {
for (const [file] of groups
.values()
.next()
.value.values()
.next()
.value.values()
.next().value) {
header += ` ${file} |`;
nFiles++;
}
Expand Down
8 changes: 3 additions & 5 deletions galata/src/helpers/notebook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -885,11 +885,9 @@ export class NotebookHelper {

await this.selectCells(numCells - 1);
await this.clickToolbarItem('insert');
await Utils.waitForCondition(
async (): Promise<boolean> => {
return (await this.getCellCount()) === numCells + 1;
}
);
await Utils.waitForCondition(async (): Promise<boolean> => {
return (await this.getCellCount()) === numCells + 1;
});

return await this.setCell(numCells, cellType, source);
}
Expand Down
4 changes: 2 additions & 2 deletions galata/src/helpers/sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ export class SidebarHelper {
pluginId
)) as ISettingRegistry;
const SIDEBAR_ID = '@jupyterlab/application-extension:sidebar';
const overrides = ((await settingRegistry.get(SIDEBAR_ID, 'overrides'))
.composite as any) as { [index: string]: any };
const overrides = (await settingRegistry.get(SIDEBAR_ID, 'overrides'))
.composite as any as { [index: string]: any };
for (const widgetId of Object.keys(overrides)) {
overrides[widgetId] = 'left';
}
Expand Down
2 changes: 1 addition & 1 deletion galata/test/galata/fixture.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ test.describe('page', () => {

test('should have playwright Page interface', async ({ page }) => {
expect(page.waitForSelector).toBe(
((page as any) as JupyterLabPage).page.waitForSelector
(page as any as JupyterLabPage).page.waitForSelector
);
});
});
Expand Down
2 changes: 0 additions & 2 deletions galata/test/galata/jupyterlabpage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ test('should toggle simple mode', async ({ page }) => {

// test that stock playwright test is accessible with page not being JupyterLabPage
playwrightTest('should not be loading galata helper', async ({ page }) => {
// eslint-disable-next-line jest/no-standalone-expect
expect(page['notebook']).toBeUndefined(); // no helper
// eslint-disable-next-line jest/no-standalone-expect
expect(page.url()).toEqual('about:blank');
});
3 changes: 1 addition & 2 deletions galata/test/jupyterlab/menus.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ test.describe('General Tests', () => {
if (request.method() === 'GET') {
return route.fulfill({
status: 200,
body:
'{"data": {"en": {"displayName": "English", "nativeName": "English"}}, "message": ""}'
body: '{"data": {"en": {"displayName": "English", "nativeName": "English"}}, "message": ""}'
});
} else {
return route.continue();
Expand Down
21 changes: 10 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,22 +104,21 @@
"watch:packages": "python scripts/watch_packages.py"
},
"resolutions": {
"@types/node": "^14.6.1",
"react": "^17.0.1"
},
"dependencies": {
"@typescript-eslint/eslint-plugin": "~4.8.1",
"@typescript-eslint/parser": "~4.8.1",
"eslint": "~7.14.0",
"eslint-config-prettier": "~6.15.0",
"eslint-plugin-jest": "~24.1.3",
"eslint-plugin-prettier": "~3.1.4",
"eslint-plugin-react": "~7.21.5",
"prettier": "~2.1.1",
"stylelint": "^14.3.0",
"@typescript-eslint/eslint-plugin": "~5.14.0",
"@typescript-eslint/parser": "~5.14.0",
"eslint": "~8.0.0",
"eslint-config-prettier": "~8.5.0",
"eslint-plugin-jest": "~26.2.2",
"eslint-plugin-prettier": "~4.0.0",
"eslint-plugin-react": "~7.29.4",
"prettier": "~2.6.0",
"stylelint": "^14.4.0",
"stylelint-config-prettier": "^9.0.3",
"stylelint-config-recommended": "^6.0.0",
"stylelint-config-standard": "~24.0.0",
"stylelint-config-standard": "^25.0.0",
"stylelint-prettier": "^2.0.0"
},
"devDependencies": {
Expand Down
10 changes: 2 additions & 8 deletions packages/application/src/layoutrestorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,8 @@ export class LayoutRestorer implements ILayoutRestorer {
return blank;
}

const {
main,
down,
left,
right,
relativeSizes,
top
} = data as Private.ILayout;
const { main, down, left, right, relativeSizes, top } =
data as Private.ILayout;

// If any data exists, then this is not a fresh session.
const fresh = false;
Expand Down
16 changes: 6 additions & 10 deletions packages/application/src/shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,14 +284,16 @@ export class LabShell extends Widget implements JupyterFrontEnd.IShell {
const bottomPanel = (this._bottomPanel = new BoxPanel());
bottomPanel.node.setAttribute('role', 'contentinfo');
const hboxPanel = new BoxPanel();
const vsplitPanel = (this._vsplitPanel = new Private.RestorableSplitPanel());
const vsplitPanel = (this._vsplitPanel =
new Private.RestorableSplitPanel());
const dockPanel = (this._dockPanel = new DockPanelSvg({
hiddenMode: Widget.HiddenMode.Scale,
translator: options?.translator
}));
MessageLoop.installMessageHook(dockPanel, this._dockChildHook);

const hsplitPanel = (this._hsplitPanel = new Private.RestorableSplitPanel());
const hsplitPanel = (this._hsplitPanel =
new Private.RestorableSplitPanel());
const downPanel = (this._downPanel = new TabPanelSvg({
tabsMovable: true
}));
Expand Down Expand Up @@ -910,14 +912,8 @@ export class LabShell extends Widget implements JupyterFrontEnd.IShell {
* Restore the layout state for the application shell.
*/
restoreLayout(mode: DockPanel.Mode, layout: ILabShell.ILayout): void {
const {
mainArea,
downArea,
leftArea,
rightArea,
topArea,
relativeSizes
} = layout;
const { mainArea, downArea, leftArea, rightArea, topArea, relativeSizes } =
layout;
// Rehydrate the main area.
if (mainArea) {
const { currentWidget, dock } = mainArea;
Expand Down
4 changes: 2 additions & 2 deletions packages/application/test/utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ describe('@jupyterlab/application', () => {
currentWidget = new Widget();
translator = nullTranslator;
semanticCmd = new SemanticCommand();
app = ({
app = {
commands,
shell: {
currentWidget
} as LabShell
} as any) as JupyterLab;
} as any as JupyterLab;
});

it.each([
Expand Down
2 changes: 1 addition & 1 deletion packages/apputils-extension/src/workspacesplugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ namespace Private {
// Save a file's contents as a workspace and navigate to that workspace.
void context.ready.then(async () => {
const file = context.model;
const workspace = (file.toJSON() as unknown) as Workspace.IWorkspace;
const workspace = file.toJSON() as unknown as Workspace.IWorkspace;
const path = context.path;
const id = workspace.metadata.id;

Expand Down
6 changes: 3 additions & 3 deletions packages/apputils/src/domutils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ export namespace DOMUtils {
parent: HTMLElement,
className: string
): HTMLCollectionOf<HTMLElement> {
return parent.getElementsByClassName(className) as HTMLCollectionOf<
HTMLElement
>;
return parent.getElementsByClassName(
className
) as HTMLCollectionOf<HTMLElement>;
}

/**
Expand Down
3 changes: 2 additions & 1 deletion packages/apputils/src/mainareawidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ const USE_CAPTURE = true;
*/
export class MainAreaWidget<T extends Widget = Widget>
extends Widget
implements Printing.IPrintable {
implements Printing.IPrintable
{
/**
* Construct a new main area widget.
*
Expand Down

0 comments on commit b57ec96

Please sign in to comment.