Skip to content

Commit

Permalink
Merge pull request #269 from delegateas/263_eslint
Browse files Browse the repository at this point in the history
Implement eslint
  • Loading branch information
misoeli authored May 20, 2022
2 parents f59dc61 + 4cb51ce commit b52617a
Show file tree
Hide file tree
Showing 31 changed files with 10,766 additions and 2,305 deletions.
2 changes: 2 additions & 0 deletions src/XrmDefinitelyTyped/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
**/Dist/**/*.ts
**/node_modules/**
12 changes: 12 additions & 0 deletions src/XrmDefinitelyTyped/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint"
],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
]
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/// <reference path="..\Dist\dg.xrmquery.web.d.ts" />
// eslint-disable-next-line @typescript-eslint/triple-slash-reference
/// <reference path="..\Dist\dg.xrmquery.web.d.ts" />
declare namespace Filter {
function $in<T extends string | number | XQW.Guid>(val: T, listVal: T[]): WebFilter;
function notIn<T extends string | number | XQW.Guid>(val: T, listVal: T[]): WebFilter;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/// <reference path="..\dg.xrmquery.web.ts" />
// eslint-disable-next-line @typescript-eslint/no-namespace, @typescript-eslint/no-unused-vars
namespace Filter {
const GUID_ENDING = "_value";
const GUID_START = "_";
Expand Down Expand Up @@ -39,21 +39,24 @@ namespace Filter {
*/
function queryFunc<T>(funcName: string, val1: T): WebFilter;
function queryFunc<T, V>(funcName: string, val1: T, val2: V): WebFilter;
// eslint-disable-next-line no-inner-declarations
function queryFunc<T, V>(funcName: string, val1: T, val2?: V): WebFilter {
if (val2 !== undefined) {
return <WebFilter><any>(`Microsoft.Dynamics.CRM.${funcName}(PropertyName='${parsePropertyName(getVal(val1))}',PropertyValues=${getVal(val2)})`);
return <WebFilter><any>(`Microsoft.Dynamics.CRM.${funcName}(PropertyName='${parsePropertyName(getVal(val1))}',PropertyValues=${getVal(val2)})`); // eslint-disable-line @typescript-eslint/no-explicit-any
} else {
return <WebFilter><any>(`Microsoft.Dynamics.CRM.${funcName}(PropertyName='${parsePropertyName(getVal(val1))}')`);
return <WebFilter><any>(`Microsoft.Dynamics.CRM.${funcName}(PropertyName='${parsePropertyName(getVal(val1))}')`); // eslint-disable-line @typescript-eslint/no-explicit-any
}
}

// eslint-disable-next-line no-inner-declarations
function parsePropertyName(name: string) {
const idxStart = name.indexOf(GUID_START);
const idxEnd = name.indexOf(GUID_ENDING);
if (idxStart === -1 || idxEnd === -1) return name;
return `${name.substr(idxStart + 1, idxEnd - 1)}`;
}

// eslint-disable-next-line no-inner-declarations, @typescript-eslint/no-explicit-any
function getVal(v: any): string {
if (v === null) return "null";
if (typeof v === "string") return `'${encodeSpecialCharacters(v)}'`;
Expand All @@ -65,6 +68,7 @@ namespace Filter {
/**
* @internal
*/
// eslint-disable-next-line no-inner-declarations
function encodeSpecialCharacters(queryString: string) {
return encodeURI(queryString)
.replace(/'/g, "''")
Expand Down
3 changes: 2 additions & 1 deletion src/XrmDefinitelyTyped/Resources/Extensions/xrm_ext_-6.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/// <reference path="..\xrm.d.ts" />
// eslint-disable-next-line @typescript-eslint/triple-slash-reference
/// <reference path="..\xrm.d.ts" />
declare namespace Xrm {
interface context {
/**
Expand Down
6 changes: 4 additions & 2 deletions src/XrmDefinitelyTyped/Resources/Extensions/xrm_ext_-8.d.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
/// <reference path="..\xrm.d.ts" />
// eslint-disable-next-line @typescript-eslint/triple-slash-reference
/// <reference path="..\xrm.d.ts" />
declare namespace Xrm {
//eslint-disable-next-line @typescript-eslint/no-unused-vars
interface PageTab<T extends SectionCollectionBase> {
/**
* Add an event handler on tab state change.
*
* @param reference Event handler for tab state change.
*/
add_tabStateChange(reference: Function): void;
add_tabStateChange(reference: Function): void; //eslint-disable-line @typescript-eslint/ban-types
}
}
10 changes: 7 additions & 3 deletions src/XrmDefinitelyTyped/Resources/Extensions/xrm_ext_-9-.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
/// <reference path="..\xrm.d.ts" />
// eslint-disable-next-line @typescript-eslint/triple-slash-reference
/// <reference path="..\xrm.d.ts" />
declare namespace Xrm {
var Page: Xrm.PageBase<Xrm.AttributeCollectionBase, Xrm.TabCollectionBase, Xrm.ControlCollectionBase>;
let Page: Xrm.PageBase<Xrm.AttributeCollectionBase, Xrm.TabCollectionBase, Xrm.ControlCollectionBase>;
/**
* Interface for the base of an Xrm.Page
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface PageBase<T extends AttributeCollectionBase, U extends TabCollectionBase, V extends ControlCollectionBase> {
/**
* The context of the page.
Expand All @@ -25,7 +27,7 @@ declare namespace Xrm {
/**
* Returns a dictionary object of key value pairs that represent the query string arguments that were passed to the page.
*/
getQueryStringParameters(): any;
getQueryStringParameters(): any; // eslint-disable-line @typescript-eslint/no-explicit-any

/**
* Returns the GUID of the SystemUser.Id value for the current user.
Expand All @@ -46,6 +48,7 @@ declare namespace Xrm {
/**
* Interface for the entity on a form.
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface PageEntity<T extends AttributeCollectionBase> {
/**
* This is the equivalent of using the "Save and Close" command.
Expand Down Expand Up @@ -80,6 +83,7 @@ declare namespace Xrm {
* @param parameters A dictionary object that passes extra query string parameters to the form. Invalid query string parameters will cause an error.
* @param windowOptions You can choose to open a form in a new window by passing a dictionary object with a boolean openInNewWindow property set to true.
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
openEntityForm(name: string, id?: string, parameters?: any, windowOptions?: WindowOptions): void;

/**
Expand Down
5 changes: 4 additions & 1 deletion src/XrmDefinitelyTyped/Resources/Extensions/xrm_ext_-9.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/// <reference path="..\xrm.d.ts" />
// eslint-disable-next-line @typescript-eslint/triple-slash-reference
/// <reference path="..\xrm.d.ts" />
declare namespace Xrm {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface DataModule<T extends AttributeCollectionBase> {
/**
* Asynchronously refreshes and optionally saves all the data of the form without reloading the page.
Expand All @@ -16,6 +18,7 @@ declare namespace Xrm {
save(saveOptions?: SaveOptions): Then<undefined>;
}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface SubGridControl<T extends string> extends BaseControl {
/**
* Use this method to get the logical name of the relationship used for the data displayed in the grid.
Expand Down
8 changes: 7 additions & 1 deletion src/XrmDefinitelyTyped/Resources/Extensions/xrm_ext_6-.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/// <reference path="..\xrm.d.ts" />
// eslint-disable-next-line @typescript-eslint/triple-slash-reference
/// <reference path="..\xrm.d.ts" />
declare namespace Xrm {
interface BaseControl {
/**
Expand Down Expand Up @@ -29,11 +30,13 @@ declare namespace Xrm {
/**
* Use this method to apply changes to lookups based on values current just as the user is about to view results for the lookup.
*/
// eslint-disable-next-line @typescript-eslint/ban-types
addPreSearch(handler: Function): void;

/**
* Use this method to remove event handler functions that have previously been set for the PreSearch event.
*/
// eslint-disable-next-line @typescript-eslint/ban-types
removePreSearch(handler: Function): void;
}

Expand All @@ -44,20 +47,23 @@ declare namespace Xrm {
setShowTime(doShow: boolean): void;
}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface PageEntity<T extends AttributeCollectionBase> {
/**
* Gets a string for the value of the primary attribute of the entity.
*/
getPrimaryAttributeValue(): string;
}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface BaseAttribute<T> {
/**
* Determine whether a lookup attribute represents a partylist lookup.
*/
getIsPartyList(): boolean;
}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface UiModule<T extends TabCollectionBase, U extends ControlCollectionBase> {
/**
* Use this method to remove form level notifications.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/// <reference path="..\xrm.d.ts" />
// eslint-disable-next-line @typescript-eslint/triple-slash-reference
/// <reference path="..\xrm.d.ts" />
declare namespace Xrm {
interface Utility {
/**
Expand All @@ -7,6 +8,7 @@ declare namespace Xrm {
* @param message The text of the message to display in the dialog.
* @param onCloseCallback A function to execute when the OK button is clicked.
*/
// eslint-disable-next-line @typescript-eslint/ban-types
alertDialog(message: string, onCloseCallback?: Function): void;

/**
Expand All @@ -16,6 +18,7 @@ declare namespace Xrm {
* @param yesCloseCallback A function to execute when the OK button is clicked.
* @param noCloseCallback A function to execute when the Cancel button is clicked.
*/
// eslint-disable-next-line @typescript-eslint/ban-types
confirmDialog(message: string, yesCloseCallback?: Function, noCloseCallback?: Function): void;

/**
Expand Down
4 changes: 3 additions & 1 deletion src/XrmDefinitelyTyped/Resources/Extensions/xrm_ext_7-.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
/// <reference path="..\xrm.d.ts" />
// eslint-disable-next-line @typescript-eslint/triple-slash-reference
/// <reference path="..\xrm.d.ts" />
declare namespace Xrm {
/**
* Interface for the ui of a form.
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface UiModule<T extends TabCollectionBase, U extends ControlCollectionBase> {
/**
* Access UI controls for the business process flow on the form.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/// <reference path="..\xrm.d.ts" />
// eslint-disable-next-line @typescript-eslint/triple-slash-reference
/// <reference path="..\xrm.d.ts" />
declare namespace Xrm {
interface context {
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
/// <reference path="..\xrm.d.ts" />
// eslint-disable-next-line @typescript-eslint/triple-slash-reference
/// <reference path="..\xrm.d.ts" />
declare namespace Xrm {
interface SubGridControl<T extends string> extends BaseControl {
/**
* Add event handlers to this event to run every time the subgrid refreshes.
* This includes when users sort the values by clicking the column headings.
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
addOnLoad(functionRef: (context?: ExecutionContext<this, any>) => any): void;

/**
Expand All @@ -25,6 +27,7 @@ declare namespace Xrm {
/**
* Use this method to remove event handlers from the GridControl.OnLoad event.
*/
// eslint-disable-next-line @typescript-eslint/ban-types
removeOnLoad(reference: Function): void;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/// <reference path="..\xrm.d.ts" />
// eslint-disable-next-line @typescript-eslint/triple-slash-reference
/// <reference path="..\xrm.d.ts" />
declare namespace Xrm {

interface Utility {
Expand All @@ -10,6 +11,7 @@ declare namespace Xrm {
* @param createFromEntity Designates a record that will provide default values based on mapped attribute values.
* @param parameters A dictionary object that passes extra query string parameters to the form. Invalid query string parameters will cause an error.
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
openQuickCreate(callback: (lookup: Lookup) => any, entityLogicalName: string, createFromEntity?: Lookup, parameters?: any): void;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/// <reference path="..\xrm.d.ts" />
// eslint-disable-next-line @typescript-eslint/triple-slash-reference
/// <reference path="..\xrm.d.ts" />
declare namespace Xrm {
interface context {
/**
Expand Down
16 changes: 15 additions & 1 deletion src/XrmDefinitelyTyped/Resources/Extensions/xrm_ext_8-.d.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
/// <reference path="..\xrm.d.ts" />
// eslint-disable-next-line @typescript-eslint/triple-slash-reference
/// <reference path="..\xrm.d.ts" />
declare namespace Xrm {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface PageTab<T extends SectionCollectionBase> {
/**
* Add an event handler on tab state change.
*
* @param reference Event handler for tab state change.
*/
// eslint-disable-next-line @typescript-eslint/ban-types
addTabStateChange(reference: Function): void;
}

Expand Down Expand Up @@ -69,6 +72,7 @@ declare namespace Xrm {
/**
* Interface for the data of a form.
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface DataModule<T extends AttributeCollectionBase> {
/**
* Access various functionality for a business process flow.
Expand All @@ -88,8 +92,10 @@ declare namespace Xrm {
getDirection(): ProcessStageChangeDirection;
}

// eslint-disable-next-line @typescript-eslint/no-empty-interface
interface StageSelectedContext extends ExecutionContext<Stage, StageSelectedEventArguments> { }

// eslint-disable-next-line @typescript-eslint/no-empty-interface
interface StageChangeContext extends ExecutionContext<Stage, StageChangeEventArguments> { }

/**
Expand Down Expand Up @@ -123,6 +129,7 @@ declare namespace Xrm {
* OR
* - The record hasn’t been saved yet.
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
setActiveStage(stageId: string, callback?: (stringVal: ProcessStageSetAnswer) => any): void;

/**
Expand All @@ -139,6 +146,7 @@ declare namespace Xrm {
* The enabled processes are filtered according to the user’s privileges. The list of enabled processes is the same ones a user can see in the UI
* if they want to change the process manually.
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
getEnabledProcesses(callback: (enabledProcesses: ProcessContainer) => any): void;

/**
Expand All @@ -152,13 +160,15 @@ declare namespace Xrm {
*
* @param handler The function will be added to the bottom of the event handler pipeline.
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
addOnStageChange(handler: (context?: StageChangeContext) => any): void;

/**
* Use this to remove a function as an event handler for the OnStageChange event.
*
* @param handler If an anonymous function is set using the addOnStageChange method it cannot be removed using this method.
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
removeOnStageChange(handler: (context?: StageChangeContext) => any): void;

/**
Expand All @@ -167,13 +177,15 @@ declare namespace Xrm {
*
* @param handler The function will be added to the bottom of the event handler pipeline.
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
addOnStageSelected(handler: (context?: StageSelectedContext) => any): void;

/**
* Use this to remove a function as an event handler for the OnStageSelected event.
*
* @param handler If an anonymous function is set using the addOnStageSelected method it cannot be removed using this method.
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
removeOnStageSelected(handler: (context?: StageSelectedContext) => any): void;

/**
Expand All @@ -188,6 +200,7 @@ declare namespace Xrm {
* "invalid": The operation failed because the selected stage isn’t the same as the active stage.
* "dirtyForm": This value will be returned if the data in the page is not saved.
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
moveNext(callback?: (stringVal: ProcessStageMoveAnswer) => any): void;

/**
Expand All @@ -202,6 +215,7 @@ declare namespace Xrm {
* "invalid": The operation failed because the selected stage isn’t the same as the active stage.
* "dirtyForm": This value will be returned if the data in the page is not saved.
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
movePrevious(callback?: (stringVal: ProcessStageMoveAnswer) => any): void;
}

Expand Down
4 changes: 3 additions & 1 deletion src/XrmDefinitelyTyped/Resources/Extensions/xrm_ext_8-9.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/// <reference path="..\xrm.d.ts" />
// eslint-disable-next-line @typescript-eslint/triple-slash-reference
/// <reference path="..\xrm.d.ts" />
declare namespace Xrm {
/**
* Interface for the business process flow on a form.
Expand All @@ -11,6 +12,7 @@ declare namespace Xrm {
* @param callback A function to call when the operation is complete. This callback function is passed one of the following string
* values to indicate whether the operation succeeded. Is "success" or "invalid".
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
setActiveProcess(processId: string, callback: (successOrInvalid: "success" | "invalid") => any): void;
}
}
Loading

0 comments on commit b52617a

Please sign in to comment.