Skip to content

Commit 77612a9

Browse files
committed
fix(web): remove eslint errors
1 parent 8760f2a commit 77612a9

File tree

5 files changed

+37
-26
lines changed

5 files changed

+37
-26
lines changed

tools/nx-python/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
"name": "@sftkit/nx-python",
33
"version": "0.0.1",
44
"dependencies": {
5-
"@nx/devkit": "^19.2.2",
5+
"@nx/devkit": "^20.3.0",
66
"tslib": "^2.3.0",
7-
"nx": "^19.2.2",
7+
"nx": "^20.3.0",
88
"semver": "^7.6.2",
99
"@ltd/j-toml": "^1.38.0"
1010
},

tools/nx-python/src/executors/release-publish/executor.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,15 @@ export default async function runExecutor(options: ReleaseExecutorSchema, contex
1111
*/
1212
const isDryRun = process.env.NX_DRY_RUN === "true" || options.dryRun || false;
1313

14-
const projectConfig = context.projectsConfigurations!.projects[context.projectName!]!;
14+
if (!context.projectName) {
15+
throw new Error("project name is empty");
16+
}
17+
18+
const projectConfig = context.projectsConfigurations?.projects[context.projectName];
19+
20+
if (!projectConfig) {
21+
throw new Error("could not find a project config");
22+
}
1523

1624
const packageRoot = joinPathFragments(context.root, options.packageRoot ?? projectConfig.root);
1725

@@ -35,7 +43,8 @@ export default async function runExecutor(options: ReleaseExecutorSchema, contex
3543
return {
3644
success: true,
3745
};
38-
} catch (err: any) {
46+
} catch (err) {
47+
output.logSingleLine(`Error running pdm publish: ${err}`);
3948
return {
4049
success: false,
4150
};

tools/nx-python/src/generators/release-version/generator.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* eslint-disable @typescript-eslint/no-explicit-any */
2+
/* eslint-disable @typescript-eslint/no-non-null-assertion */
13
import {
24
formatFiles,
35
joinPathFragments,
@@ -203,8 +205,8 @@ To fix this you will either need to add a pyproject.toml file at that location,
203205
const previousVersionRef = latestMatchingGitTag
204206
? latestMatchingGitTag.tag
205207
: options.fallbackCurrentVersionResolver === "disk"
206-
? await getFirstGitCommit()
207-
: undefined;
208+
? await getFirstGitCommit()
209+
: undefined;
208210

209211
if (!previousVersionRef) {
210212
// This should never happen since the checks above should catch if the current version couldn't be resolved
@@ -481,8 +483,8 @@ function resolveLocalPackageDependencies(
481483
const dependencyCollection: "dependencies" | "dev-dependencies" | null = dependencies[depProject.name]
482484
? "dependencies"
483485
: devDependencies[depProject.name]
484-
? "dev-dependencies"
485-
: null;
486+
? "dev-dependencies"
487+
: null;
486488
if (!dependencyCollection) {
487489
throw new Error(
488490
`The project "${projectNode.name}" does not have a local dependency on "${depProject.name}" in its Cargo.toml`

tools/nx-python/src/graph.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,12 @@ export const createNodes: CreateNodesV2 = [
1313
const root = dirname(projectFile);
1414
const pyproject = loadPyprojectToml(projectFile);
1515

16+
if (!pyproject.project?.name) {
17+
throw new Error("No name configured in pyproject.toml");
18+
}
19+
1620
const pythonPackage = {
17-
name: pyproject.project!.name!,
21+
name: pyproject.project.name,
1822
pyprojectToml: pyproject,
1923
projectRoot: dirname(projectFile),
2024
};

tools/nx-python/src/utils/pyproject-toml.ts

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
/* eslint-disable @typescript-eslint/no-explicit-any */
12
import { logger, Tree } from "@nx/devkit";
2-
import TOML from '@ltd/j-toml';
3+
import TOML from "@ltd/j-toml";
34
import * as fs from "fs";
45

56
export interface BuildSystem {
@@ -36,12 +37,12 @@ export interface Project {
3637
classifiers?: string[];
3738
urls?: Record<string, string>;
3839
requires_python?: string;
39-
dependencies?: string[],
40-
optional_dependencies?: string[],
40+
dependencies?: string[];
41+
optional_dependencies?: string[];
4142
scripts?: Record<string, string>;
4243
gui_scripts?: Record<string, string>;
4344
entry_points?: Record<string, Record<string, string>>;
44-
dynamic?: string[]
45+
dynamic?: string[];
4546
}
4647

4748
export interface PyprojectToml {
@@ -67,20 +68,20 @@ export function loadPyprojectToml(pyprojectTomlPath: string): PyprojectToml {
6768
}
6869

6970
export function parsePyprojectToml(pyprojectString: string) {
70-
return TOML.parse(pyprojectString, {
71+
return TOML.parse(pyprojectString, {
7172
x: { comment: true },
7273
}) as unknown as PyprojectToml;
7374
}
7475

7576
export function stringifyPyprojectToml(pyprojectToml: PyprojectToml) {
7677
const tomlString = TOML.stringify(pyprojectToml, {
77-
newlineAround: 'section',
78+
newlineAround: "section",
7879
indent: 4,
7980
});
8081
// the following is a very, very dirty hack for dealing with j-toml not being able to configure the type of quotation
8182

8283
if (Array.isArray(tomlString)) {
83-
return tomlString.join('\n').replace(/'/g, '"');
84+
return tomlString.join("\n").replace(/'/g, '"');
8485
}
8586

8687
return tomlString.toString().replace(/'/g, '"');
@@ -94,19 +95,14 @@ export function modifyPyprojectToml(
9495
) {
9596
toml[section] ??= TOML.Section({});
9697
toml[section][key] =
97-
typeof value === 'object' && !Array.isArray(value)
98+
typeof value === "object" && !Array.isArray(value)
9899
? TOML.inline(value as any)
99-
: typeof value === 'function'
100-
? value()
101-
: value;
100+
: typeof value === "function"
101+
? value()
102+
: value;
102103
}
103104

104-
export function modifyCargoNestedTable(
105-
toml: PyprojectToml,
106-
section: string,
107-
key: string,
108-
value: object
109-
) {
105+
export function modifyCargoNestedTable(toml: PyprojectToml, section: string, key: string, value: object) {
110106
toml[section] ??= {};
111107
toml[section][key] = TOML.Section(value as any);
112108
}

0 commit comments

Comments
 (0)