Skip to content

Commit

Permalink
Enforce path imports for mui icons, Migrate to newer eslint (v8) (#572)
Browse files Browse the repository at this point in the history
* Enforce path imports for mui icons, migrate to newer eslint

* update snapshots

* Fix: eslint errors and warnings

* set a no-op filter if extraction filter is supported (Python 3.12+)

---------

Co-authored-by: Andrii Ieroshenko <[email protected]>
  • Loading branch information
astitv-sh and andrii-i authored Feb 13, 2025
1 parent 14c4451 commit 469b8e6
Show file tree
Hide file tree
Showing 12 changed files with 600 additions and 358 deletions.
23 changes: 21 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = {
project: 'tsconfig.json',
sourceType: 'module'
},
plugins: ['@typescript-eslint'],
plugins: ['@stylistic', '@typescript-eslint'],
rules: {
'@typescript-eslint/naming-convention': [
'error',
Expand All @@ -27,13 +27,32 @@ module.exports = {
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-namespace': 'off',
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/quotes': [
'@stylistic/quotes': [
'error',
'single',
{ avoidEscape: true, allowTemplateLiterals: false }
],
curly: ['error', 'all'],
eqeqeq: 'error',
'no-restricted-imports': [
'error',
{
paths: [
{
name: '@mui/icons-material',

message:
"Please import icons using path imports, e.g. `import AddIcon from '@mui/icons-material/Add'`"
}
],
patterns: [
{
group: ['@mui/*/*/*'],
message: '3rd level imports in mui are considered private'
}
]
}
],
'prefer-arrow-callback': 'error'
}
};
4 changes: 4 additions & 0 deletions jupyter_scheduler/job_files_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ def download_tar(self, archive_format: str = "tar"):

with fsspec.open(archive_filepath) as f:
with tarfile.open(fileobj=f, mode=read_mode) as tar:
# if extraction filter is supported (Python 3.12+), set a no-op filter
if hasattr(tar, "extraction_filter"):
tar.extraction_filter = lambda member, path: member

tar.extractall(self.output_dir)

def download(self):
Expand Down
13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@
"watch:labextension": "jupyter labextension watch ."
},
"dependencies": {
"@emotion/react": "^11.10.4",
"@emotion/styled": "^11.10.4",
"@emotion/react": "^11.10.5",
"@emotion/styled": "^11.10.5",
"@jupyterlab/application": "^4",
"@jupyterlab/apputils": "^4",
"@jupyterlab/coreutils": "^6",
Expand All @@ -69,7 +69,7 @@
"@lumino/polling": "^2",
"@lumino/signaling": "^2",
"@lumino/widgets": "^2",
"@mui/icons-material": "^5.10.9",
"@mui/icons-material": "^5.11.0",
"@mui/material": "^5.10.6",
"@mui/system": "^5.10.6",
"@types/react-dom": "^18.0.5",
Expand All @@ -83,10 +83,11 @@
"@babel/preset-env": "^7.0.0",
"@jupyterlab/builder": "^4",
"@jupyterlab/testutils": "^4",
"@stylistic/eslint-plugin": "^3.0.1",
"@types/jest": "^29",
"@typescript-eslint/eslint-plugin": "^4.8.1",
"@typescript-eslint/parser": "^4.8.1",
"eslint": "^7.14.0",
"@typescript-eslint/eslint-plugin": "^8.0.0",
"@typescript-eslint/parser": "^8.0.0",
"eslint": "^8.56.0",
"eslint-config-prettier": "^6.15.0",
"eslint-plugin-prettier": "^3.1.4",
"jest": "^29",
Expand Down
2 changes: 1 addition & 1 deletion src/components/schedule-inputs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ export function ScheduleInputs<
const scheduleHelperText = useMemo(() => {
try {
return cronstrue.toString(props.model.schedule);
} catch (e) {
} catch {
return '';
}
}, [props.model.schedule]);
Expand Down
2 changes: 1 addition & 1 deletion src/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ async function requestAPI<T>(
if (expectData && data.length > 0) {
try {
data = JSON.parse(data);
} catch (error) {
} catch {
console.error('Not a JSON response body.', response);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/mainviews/detail-view/job-definition.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export function JobDefinition(props: IJobDefinitionProps): JSX.Element {
if (model.schedule !== undefined) {
cronString = cronstrue.toString(model.schedule);
}
} catch (e) {
} catch {
// Do nothing; let the errors or nothing display instead
}

Expand Down
2 changes: 1 addition & 1 deletion src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export function emptyUpdateJobDefinitionModel(): IUpdateJobDefinitionModel {
};
}

// eslint-disable-next-line @typescript-eslint/no-empty-interface
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
export interface IListJobsModel extends PartialJSONObject {
/* reserved */
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 469b8e6

Please sign in to comment.