Repository: DevExpress/devextreme-react
Pull request #105 (2018-05-28 10:14:59)

Fix linting and add it to CI


Patch:
diff --git a/package.json b/package.json
index 89cf030..fcda90d 100644
--- a/package.json
+++ b/package.json
@@ -56,7 +56,7 @@
     "start": "npm run build && npm run serve",
     "serve": "webpack-dev-server",
     "lint": "gulp lint",
-    "build": "npm run lint && npm run generate",
+    "build": "npm run clean && npm run lint && npm run generate",
     "generate": "gulp generate",
     "clean": "gulp clean",
     "test": "jest",
diff --git a/shippable.yml b/shippable.yml
index 3cdde3c..2d2014a 100644
--- a/shippable.yml
+++ b/shippable.yml
@@ -13,6 +13,7 @@ build:
   ci:
     - npm install
     - npm run build
+    - npm run lint
     - npm run test
   cache: true
   cache_dir_list:
diff --git a/tools/src/component-generator.ts b/tools/src/component-generator.ts
index 77d2671..0bd84bf 100644
--- a/tools/src/component-generator.ts
+++ b/tools/src/component-generator.ts
@@ -110,7 +110,7 @@ function createSubscribableOptionModel(option: IOption) {
 function createPropTypingModel(typing: IPropTyping): IRenderedPropTyping {
     const types = typing.types.map((t) => "PropTypes." + t);
     if (isNotEmptyArray(typing.acceptableValues)) {
-        types.push(`PropTypes.oneOf([${typing.acceptableValues.join(", ")}])`);
+        types.push(`PropTypes.oneOf([\n    ${typing.acceptableValues.join(",\n    ")}\n  ])`);
     }
     return {
         propName: typing.propName,
@@ -118,7 +118,6 @@ function createPropTypingModel(typing: IPropTyping): IRenderedPropTyping {
     };
 }
 
-// tslint:disable:max-line-length
 const renderComponent: (model: {
     name: string;
     widgetName: string;
@@ -127,30 +126,33 @@ const renderComponent: (model: {
     configComponentPath: string;
     dxExportPath: string;
     hasExtraOptions: boolean;
-    templates: {
+    templates: Array<{
         render: string;
         component: string;
         renderedProp: string;
-    }[]; // tslint:disable-line:array-type
-    subscribableOptions: {
+    }>;
+    subscribableOptions: Array<{
         name: string,
         type: string,
         renderedProp: string
-    }[]; // tslint:disable-line:array-type
-    nestedOptions: {
+    }>
+    nestedOptions: Array<{
         name: string;
         className: string;
         interfaceName: string;
         rendered: string;
         isCollectionItem: boolean;
-    }[]; // tslint:disable-line:array-type
+    }>;
     renderedPropTypings: string[],
     renderedExports: string
 }
 ) => string = createTempate(`
-import <#= it.widgetName #>, { IOptions <#? !it.hasExtraOptions #>as <#= it.optionsName #> <#?#>} from "devextreme/<#= it.dxExportPath #>";<#? it.renderedPropTypings #>
-import { PropTypes } from "prop-types";<#?#>
-import BaseComponent from "<#= it.baseComponentPath #>";
+import <#= it.widgetName #>, {
+    IOptions<#? !it.hasExtraOptions #> as <#= it.optionsName #><#?#>
+} from "devextreme/<#= it.dxExportPath #>";
+
+<#? it.renderedPropTypings #>import { PropTypes } from "prop-types";
+<#?#>import BaseComponent from "<#= it.baseComponentPath #>";
 <#? it.nestedOptions #>import NestedOption from "<#= it.configComponentPath #>";
 <#?#><#? it.hasExtraOptions #>
 interface <#= it.optionsName #> extends IOptions {<#~ it.templates :template #>


Test patch:
diff --git a/tools/src/component-generator.test.ts b/tools/src/component-generator.test.ts
index 1a0ae5e..e30a2bb 100644
--- a/tools/src/component-generator.test.ts
+++ b/tools/src/component-generator.test.ts
@@ -3,7 +3,10 @@ import generate from "./component-generator";
 it("generates", () => {
     //#region EXPECTED
     const EXPECTED = `
-import dxCLASS_NAME, { IOptions as ICLASS_NAMEOptions } from "devextreme/DX/WIDGET/PATH";
+import dxCLASS_NAME, {
+    IOptions as ICLASS_NAMEOptions
+} from "devextreme/DX/WIDGET/PATH";
+
 import BaseComponent from "BASE_COMPONENT_PATH";
 
 class CLASS_NAME extends BaseComponent<ICLASS_NAMEOptions> {
@@ -36,7 +39,10 @@ describe("template-props generation", () => {
     it("processes option", () => {
         //#region EXPECTED
         const EXPECTED = `
-import dxCLASS_NAME, { IOptions } from "devextreme/DX/WIDGET/PATH";
+import dxCLASS_NAME, {
+    IOptions
+} from "devextreme/DX/WIDGET/PATH";
+
 import BaseComponent from "BASE_COMPONENT_PATH";
 
 interface ICLASS_NAMEOptions extends IOptions {
@@ -79,7 +85,10 @@ export {
     it("processes several options", () => {
         //#region EXPECTED
         const EXPECTED = `
-import dxCLASS_NAME, { IOptions } from "devextreme/DX/WIDGET/PATH";
+import dxCLASS_NAME, {
+    IOptions
+} from "devextreme/DX/WIDGET/PATH";
+
 import BaseComponent from "BASE_COMPONENT_PATH";
 
 interface ICLASS_NAMEOptions extends IOptions {
@@ -128,7 +137,10 @@ export {
     it("processes single widget-template option", () => {
         //#region EXPECTED
         const EXPECTED = `
-import dxCLASS_NAME, { IOptions } from "devextreme/DX/WIDGET/PATH";
+import dxCLASS_NAME, {
+    IOptions
+} from "devextreme/DX/WIDGET/PATH";
+
 import BaseComponent from "BASE_COMPONENT_PATH";
 
 interface ICLASS_NAMEOptions extends IOptions {
@@ -174,7 +186,10 @@ describe("props generation", () => {
     it("processes subscribable option", () => {
         //#region EXPECTED
         const EXPECTED = `
-import dxCLASS_NAME, { IOptions } from "devextreme/DX/WIDGET/PATH";
+import dxCLASS_NAME, {
+    IOptions
+} from "devextreme/DX/WIDGET/PATH";
+
 import BaseComponent from "BASE_COMPONENT_PATH";
 
 interface ICLASS_NAMEOptions extends IOptions {
@@ -216,7 +231,10 @@ export {
     it("processes several subscribable options", () => {
         //#region EXPECTED
         const EXPECTED = `
-import dxCLASS_NAME, { IOptions } from "devextreme/DX/WIDGET/PATH";
+import dxCLASS_NAME, {
+    IOptions
+} from "devextreme/DX/WIDGET/PATH";
+
 import BaseComponent from "BASE_COMPONENT_PATH";
 
 interface ICLASS_NAMEOptions extends IOptions {
@@ -261,7 +279,10 @@ export {
     it("processes nested options", () => {
         //#region EXPECTED
         const EXPECTED = `
-import dxCLASS_NAME, { IOptions as ICLASS_NAMEOptions } from "devextreme/DX/WIDGET/PATH";
+import dxCLASS_NAME, {
+    IOptions as ICLASS_NAMEOptions
+} from "devextreme/DX/WIDGET/PATH";
+
 import BaseComponent from "BASE_COMPONENT_PATH";
 import NestedOption from "CONFIG_COMPONENT_PATH";
 
@@ -338,7 +359,10 @@ export {
     it("processes nested array options", () => {
         //#region EXPECTED
         const EXPECTED = `
-import dxCLASS_NAME, { IOptions as ICLASS_NAMEOptions } from "devextreme/DX/WIDGET/PATH";
+import dxCLASS_NAME, {
+    IOptions as ICLASS_NAMEOptions
+} from "devextreme/DX/WIDGET/PATH";
+
 import BaseComponent from "BASE_COMPONENT_PATH";
 import NestedOption from "CONFIG_COMPONENT_PATH";
 
@@ -393,7 +417,10 @@ export {
     it("adds check for single type", () => {
         //#region EXPECTED
         const EXPECTED = `
-import dxCLASS_NAME, { IOptions as ICLASS_NAMEOptions } from "devextreme/DX/WIDGET/PATH";
+import dxCLASS_NAME, {
+    IOptions as ICLASS_NAMEOptions
+} from "devextreme/DX/WIDGET/PATH";
+
 import { PropTypes } from "prop-types";
 import BaseComponent from "BASE_COMPONENT_PATH";
 
@@ -434,7 +461,10 @@ export {
     it("adds check for acceptable values", () => {
         //#region EXPECTED
         const EXPECTED = `
-import dxCLASS_NAME, { IOptions as ICLASS_NAMEOptions } from "devextreme/DX/WIDGET/PATH";
+import dxCLASS_NAME, {
+    IOptions as ICLASS_NAMEOptions
+} from "devextreme/DX/WIDGET/PATH";
+
 import { PropTypes } from "prop-types";
 import BaseComponent from "BASE_COMPONENT_PATH";
 
@@ -447,7 +477,10 @@ class CLASS_NAME extends BaseComponent<ICLASS_NAMEOptions> {
   protected _WidgetClass = dxCLASS_NAME;
 }
 (CLASS_NAME as any).propTypes = {
-  PROP1: PropTypes.oneOf(["VALUE_1", "VALUE_2"])
+  PROP1: PropTypes.oneOf([
+    "VALUE_1",
+    "VALUE_2"
+  ])
 };
 export {
   CLASS_NAME,
@@ -476,7 +509,10 @@ export {
     it("adds check for several types", () => {
         //#region EXPECTED
         const EXPECTED = `
-import dxCLASS_NAME, { IOptions as ICLASS_NAMEOptions } from "devextreme/DX/WIDGET/PATH";
+import dxCLASS_NAME, {
+    IOptions as ICLASS_NAMEOptions
+} from "devextreme/DX/WIDGET/PATH";
+
 import { PropTypes } from "prop-types";
 import BaseComponent from "BASE_COMPONENT_PATH";
 
@@ -520,7 +556,10 @@ export {
     it("adds typings in alphabetic order", () => {
         //#region EXPECTED
         const EXPECTED = `
-import dxCLASS_NAME, { IOptions as ICLASS_NAMEOptions } from "devextreme/DX/WIDGET/PATH";
+import dxCLASS_NAME, {
+    IOptions as ICLASS_NAMEOptions
+} from "devextreme/DX/WIDGET/PATH";
+
 import { PropTypes } from "prop-types";
 import BaseComponent from "BASE_COMPONENT_PATH";