Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
29 changes: 29 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,35 @@ jobs:
- name: Test
run: npm test

lint:
name: Lint & Format
runs-on: ubuntu-latest

steps:

- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@46b06cea07f9e64621fdf066ba77ac6915163d43 # v2.22.3
with:
egress-policy: audit

- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: '24.x'
cache: 'npm'

- name: Install
run: npm ci --ignore-scripts

- name: Lint
run: npm run lint

- name: Check formatting
run: npm run format.check

doctor:
name: Doctor (Node ${{ matrix.node-version }})
runs-on: ubuntu-latest
Expand Down
12 changes: 12 additions & 0 deletions .oxfmtrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"$schema": "./node_modules/oxfmt/configuration_schema.json",
"useTabs": true,
"printWidth": 80,
"sortPackageJson": false,
"ignorePatterns": [
"lib/common/test/resources/**",
"lib/common/vendor/**",
"lib/common/bin/**",
"test/files/**"
]
}
50 changes: 50 additions & 0 deletions .oxlintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"$schema": "./node_modules/oxlint/configuration_schema.json",
"ignorePatterns": [
"lib/common/test/resources/**",
"lib/common/vendor/**",
"lib/common/bin/**",
"test/files/**",
"vendor/**",
"resources/**",
"packages/**",
"docs/**",
"docs-cli/**"
],
"rules": {
"no-unused-vars": [
"warn",
{
"args": "none",
"caughtErrors": "none",
"varsIgnorePattern": "^_",
"ignoreRestSiblings": true
}
],
"eqeqeq": ["error", "always", { "null": "ignore" }],
"no-debugger": "error",
"no-eval": "error",
"no-var": "error",
"prefer-const": [
"error",
{ "destructuring": "all", "ignoreReadBeforeAssign": true }
],
"no-new-wrappers": "error",
"no-redeclare": "error",
"no-unused-expressions": [
"error",
{ "allowShortCircuit": true, "allowTernary": true }
],
"no-empty": "warn",
"no-fallthrough": "error"
},
"overrides": [
{
"files": ["**/*.d.ts"],
"rules": {
"no-var": "off",
"no-redeclare": "off"
}
}
]
}
11 changes: 0 additions & 11 deletions .prettierrc.json

This file was deleted.

5 changes: 3 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,10 @@ Before you submit a Pull Request, consider the following guidelines.
```bash
npm test
```
* Ensure that your code is formatted.
* Ensure that your code is formatted and lints cleanly.
```bash
npm run prettier
npm run format
npm run lint
```
* Commit your changes following the [commit message guidelines](https://github.com/NativeScript/NativeScript/blob/master/CONTRIBUTING.md#-commit-message-guidelines) (the commit message is used to generate release notes).
```bash
Expand Down
2 changes: 1 addition & 1 deletion lib/base-package-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export abstract class BasePackageManager implements INodePackageManager {
config?: IDictionary<string | boolean>,
path?: string,
): Promise<string>;
public abstract view(packageName: string, config: Object): Promise<any>;
public abstract view(packageName: string, config: object): Promise<any>;
public abstract search(
filter: string[],
config: IDictionary<string | boolean>,
Expand Down
20 changes: 10 additions & 10 deletions lib/bun-package-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class BunPackageManager extends BasePackageManager {
$hostInfo: IHostInfo,
private $logger: ILogger,
private $httpClient: Server.IHttpClient,
$pacoteService: IPacoteService
$pacoteService: IPacoteService,
) {
super($childProcess, $fs, $hostInfo, $pacoteService, "bun");
}
Expand All @@ -34,7 +34,7 @@ export class BunPackageManager extends BasePackageManager {
public async install(
packageName: string,
pathToSave: string,
config: INodePackageManagerInstallOptions
config: INodePackageManagerInstallOptions,
): Promise<INpmInstallResultInfo> {
if (config.disableNpmInstall) {
return;
Expand All @@ -60,7 +60,7 @@ export class BunPackageManager extends BasePackageManager {
const result = await this.processPackageManagerInstall(
packageName,
params,
{ cwd, isInstallingAllDependencies }
{ cwd, isInstallingAllDependencies },
);
return result;
} catch (err) {
Expand All @@ -74,7 +74,7 @@ export class BunPackageManager extends BasePackageManager {
public async uninstall(
packageName: string,
config?: any,
cwd?: string
cwd?: string,
): Promise<string> {
const flags = this.getFlagsString(config, false);
return this.$childProcess.exec(`bun remove ${packageName} ${flags}`, {
Expand All @@ -84,14 +84,14 @@ export class BunPackageManager extends BasePackageManager {

// Bun does not have a `view` command; use npm.
@exported("bun")
public async view(packageName: string, config: Object): Promise<any> {
public async view(packageName: string, config: object): Promise<any> {
const wrappedConfig = _.extend({}, config, { json: true }); // always require view response as JSON

const flags = this.getFlagsString(wrappedConfig, false);
let viewResult: any;
try {
viewResult = await this.$childProcess.exec(
`npm view ${packageName} ${flags}`
`npm view ${packageName} ${flags}`,
);
} catch (e) {
this.$errors.fail(e.message);
Expand Down Expand Up @@ -119,7 +119,7 @@ export class BunPackageManager extends BasePackageManager {
// https://github.com/npms-io/npms-api/issues/112. Better to switch to
// https://registry.npmjs.org/<query>
const httpRequestResult = await this.$httpClient.httpRequest(
`https://api.npms.io/v2/search?q=keywords:${keyword}`
`https://api.npms.io/v2/search?q=keywords:${keyword}`,
);
const result: INpmsResult = JSON.parse(httpRequestResult.body);
return result;
Expand All @@ -132,15 +132,15 @@ export class BunPackageManager extends BasePackageManager {
const registry = await this.$childProcess.exec(`npm config get registry`);
const url = registry.trim() + packageName;
this.$logger.trace(
`Trying to get data from npm registry for package ${packageName}, url is: ${url}`
`Trying to get data from npm registry for package ${packageName}, url is: ${url}`,
);
const responseData = (await this.$httpClient.httpRequest(url)).body;
this.$logger.trace(
`Successfully received data from npm registry for package ${packageName}. Response data is: ${responseData}`
`Successfully received data from npm registry for package ${packageName}. Response data is: ${responseData}`,
);
const jsonData = JSON.parse(responseData);
this.$logger.trace(
`Successfully parsed data from npm registry for package ${packageName}.`
`Successfully parsed data from npm registry for package ${packageName}.`,
);
return jsonData;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/commands/clean.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ async function getNSProjectPathsInDirectory(
$logger: ILogger,
dir = process.cwd(),
): Promise<string[]> {
let nsDirs: string[] = [];
const nsDirs: string[] = [];

const getFiles = async (dir: string) => {
if (dir.includes("node_modules")) {
Expand Down Expand Up @@ -250,7 +250,7 @@ async function cleanMultipleProjects(
);
spinner.warn(`This action cannot be undone!`);

let confirmed = await $prompter.confirm(
const confirmed = await $prompter.confirm(
"Are you sure you want to clean the selected projects?",
);
if (!confirmed) {
Expand Down
6 changes: 3 additions & 3 deletions lib/commands/native-add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ function generateJavaKotlin(
): void {
const $projectData = ctx.injector.get(ProjectData);
const $logger = ctx.injector.get<ILogger>("logger");
const fileExt = extension == "java" ? extension : "kt";
const fileExt = extension === "java" ? extension : "kt";
const packageName = getPackageName(className);
const classSimpleName = getClassSimpleName(className);
const packagePath = path.join(
Expand All @@ -142,12 +142,12 @@ function generateJavaKotlin(
return;
}

if (extension == "kotlin" && !checkAndUpdateGradleProperties(ctx)) {
if (extension === "kotlin" && !checkAndUpdateGradleProperties(ctx)) {
return;
}

const fileContent =
extension == "java"
extension === "java"
? generateJavaClassContent(packageName, classSimpleName)
: generateKotlinClassContent(packageName, classSimpleName);

Expand Down
2 changes: 1 addition & 1 deletion lib/common/codeGeneration/code-generation.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { IDictionary } from "../declarations";

declare module CodeGeneration {
declare namespace CodeGeneration {
interface IModel {
id: string;
properties: IDictionary<IModelProperty>;
Expand Down
6 changes: 4 additions & 2 deletions lib/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,10 @@ export class EmulatorDiscoveryNames {

export const DEVICE_LOG_EVENT_NAME = "deviceLogData";
export const IOS_LOG_PREDICATE = 'senderImagePath contains "NativeScript"';
export const IOS_APP_CRASH_LOG_REG_EXP = /Fatal JavaScript exception \- application has been terminated/;
export const FAIL_LIVESYNC_LOG_REGEX = /Failed to refresh the application with RefreshRequest./;
export const IOS_APP_CRASH_LOG_REG_EXP =
/Fatal JavaScript exception - application has been terminated/;
export const FAIL_LIVESYNC_LOG_REGEX =
/Failed to refresh the application with RefreshRequest./;

export const TARGET_FRAMEWORK_IDENTIFIERS = {
Cordova: "Cordova",
Expand Down
9 changes: 1 addition & 8 deletions lib/common/declarations.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import type { FileSystem } from "../contracts/file-system";
import type { HostInfo } from "../contracts/host-info";
import type { HttpClient } from "../contracts/http-client";

// tslint:disable-next-line:interface-name
interface Object {
[key: string]: any;
}
Expand All @@ -21,7 +20,6 @@ interface IStringDictionary extends IDictionary<string> {}
/**
* Describes iTunes Connect application types
*/
// tslint:disable-next-line:interface-name
interface IiTunesConnectApplicationType {
/**
* Applications developed for iOS
Expand All @@ -44,7 +42,6 @@ interface IiTunesConnectApplicationType {
/**
* Descibes iTunes Connect applications
*/
// tslint:disable-next-line:interface-name
interface IiTunesConnectApplication {
/**
* Unique Apple ID for each application. Automatically generated and assigned by Apple.
Expand Down Expand Up @@ -159,7 +156,7 @@ interface IContentDeliveryBody {
};
}

declare module Server {
declare namespace Server {
interface IResponse {
response: any;
body?: any;
Expand Down Expand Up @@ -688,13 +685,11 @@ interface ISysInfo {
/** @deprecated Kept so existing annotations compile; use the {@link HostInfo} contract. */
interface IHostInfo extends HostInfo {}

// tslint:disable-next-line:interface-name
interface GenericFunction<T> extends Function {
(...args: any[]): T;
}

declare global {
// tslint:disable-next-line:interface-name
interface Function {
$inject: {
args: string[];
Expand All @@ -706,7 +701,6 @@ declare global {
* Extends Nodejs' Error interface.
* The native interface already has name and message properties
*/
// tslint:disable-next-line:interface-name
interface Error {
/**
* Error's stack trace
Expand Down Expand Up @@ -1177,7 +1171,6 @@ interface IDeferPromise<T> extends IPromiseActions<T> {
/**
* Describes service used for interaction with Notification Center
*/
// tslint:disable-next-line:interface-name
interface IiOSNotificationService {
/**
* Posts a notification and waits for a response.
Expand Down
Loading
Loading