From e3cfc58101c05c0fdec71568da9ec484863445ac Mon Sep 17 00:00:00 2001 From: Aman Agarwal Date: Mon, 12 Aug 2024 14:45:48 +0530 Subject: [PATCH 01/21] chore: created utils package and moved objectKeys function to it --- app/client/package.json | 1 + .../chromatic/Button.chromatic.stories.tsx | 8 +-- .../Button/stories/Button.stories.tsx | 2 +- .../IconButton/stories/IconButton.stories.tsx | 2 +- .../stories/InlineButtons.stories.tsx | 2 +- .../stories/ToolbarButtons.stories.tsx | 2 +- .../design-system/widgets/src/utils/index.ts | 1 - app/client/packages/utils/.eslintrc.json | 3 + app/client/packages/utils/index.d.ts | 1 + app/client/packages/utils/jest.config.js | 12 ++++ app/client/packages/utils/package.json | 18 ++++++ app/client/packages/utils/src/index.ts | 1 + app/client/packages/utils/src/object/index.ts | 1 + .../packages/utils/src/object/keys.test.ts | 7 +++ .../src/object/keys.ts} | 7 ++- app/client/packages/utils/tsconfig.json | 3 + .../WDSButtonWidget/config/defaultsConfig.ts | 3 +- .../config/propertyPaneConfig/styleConfig.ts | 3 +- .../config/defaultsConfig.ts | 3 +- .../config/propertyPaneConfig/styleConfig.ts | 3 +- .../propertyPaneConfig/contentConfig.ts | 3 +- .../config/defaultsConfig.ts | 3 +- .../config/propertyPaneConfig/styleConfig.ts | 8 +-- .../propertyPaneConfig/PanelConfig/General.ts | 3 +- .../config/propertyPaneConfig/styleConfig.ts | 3 +- app/client/yarn.lock | 61 +++++++++++++++++-- 26 files changed, 131 insertions(+), 33 deletions(-) create mode 100644 app/client/packages/utils/.eslintrc.json create mode 100644 app/client/packages/utils/index.d.ts create mode 100644 app/client/packages/utils/jest.config.js create mode 100644 app/client/packages/utils/package.json create mode 100644 app/client/packages/utils/src/index.ts create mode 100644 app/client/packages/utils/src/object/index.ts create mode 100644 app/client/packages/utils/src/object/keys.test.ts rename app/client/packages/{design-system/widgets/src/utils/objectKeys.ts => utils/src/object/keys.ts} (76%) create mode 100644 app/client/packages/utils/tsconfig.json diff --git a/app/client/package.json b/app/client/package.json index 13fe62a77e6..e05741f2a03 100644 --- a/app/client/package.json +++ b/app/client/package.json @@ -106,6 +106,7 @@ "@welldone-software/why-did-you-render": "^4.2.5", "algoliasearch": "^4.2.0", "appsmith-icons": "workspace:^", + "appsmith-utils": "workspace:^", "assert-never": "^1.2.1", "astring": "^1.7.5", "async-mutex": "^0.5.0", diff --git a/app/client/packages/design-system/widgets/src/components/Button/chromatic/Button.chromatic.stories.tsx b/app/client/packages/design-system/widgets/src/components/Button/chromatic/Button.chromatic.stories.tsx index be2b9ab10ec..130d8c5d84f 100644 --- a/app/client/packages/design-system/widgets/src/components/Button/chromatic/Button.chromatic.stories.tsx +++ b/app/client/packages/design-system/widgets/src/components/Button/chromatic/Button.chromatic.stories.tsx @@ -1,12 +1,8 @@ import React from "react"; import type { Meta, StoryObj } from "@storybook/react"; import { StoryGrid, DataAttrWrapper } from "@design-system/storybook"; -import { - Button, - BUTTON_VARIANTS, - COLORS, - objectKeys, -} from "@design-system/widgets"; +import { Button, BUTTON_VARIANTS, COLORS } from "@design-system/widgets"; +import { objectKeys } from "appsmith-utils/src/object"; const variants = objectKeys(BUTTON_VARIANTS); const colors = Object.values(COLORS); diff --git a/app/client/packages/design-system/widgets/src/components/Button/stories/Button.stories.tsx b/app/client/packages/design-system/widgets/src/components/Button/stories/Button.stories.tsx index 2a016d47fa8..18ab810674e 100644 --- a/app/client/packages/design-system/widgets/src/components/Button/stories/Button.stories.tsx +++ b/app/client/packages/design-system/widgets/src/components/Button/stories/Button.stories.tsx @@ -6,8 +6,8 @@ import { BUTTON_VARIANTS, COLORS, SIZES, - objectKeys, } from "@design-system/widgets"; +import { objectKeys } from "appsmith-utils/src/object"; /** * A button is a clickable element that is used to trigger an action. diff --git a/app/client/packages/design-system/widgets/src/components/IconButton/stories/IconButton.stories.tsx b/app/client/packages/design-system/widgets/src/components/IconButton/stories/IconButton.stories.tsx index 3064a1e9926..9aaab66b55e 100644 --- a/app/client/packages/design-system/widgets/src/components/IconButton/stories/IconButton.stories.tsx +++ b/app/client/packages/design-system/widgets/src/components/IconButton/stories/IconButton.stories.tsx @@ -6,8 +6,8 @@ import { SIZES, BUTTON_VARIANTS, COLORS, - objectKeys, } from "@design-system/widgets"; +import { objectKeys } from "appsmith-utils/src/object"; /** * Icon Button is a button component that only contains an icon. diff --git a/app/client/packages/design-system/widgets/src/components/InlineButtons/stories/InlineButtons.stories.tsx b/app/client/packages/design-system/widgets/src/components/InlineButtons/stories/InlineButtons.stories.tsx index 550eec8186c..bfe54673169 100644 --- a/app/client/packages/design-system/widgets/src/components/InlineButtons/stories/InlineButtons.stories.tsx +++ b/app/client/packages/design-system/widgets/src/components/InlineButtons/stories/InlineButtons.stories.tsx @@ -2,12 +2,12 @@ import React from "react"; import { InlineButtons, Flex, - objectKeys, BUTTON_VARIANTS, COLORS, SIZES, } from "@design-system/widgets"; import type { Meta, StoryObj } from "@storybook/react"; +import { objectKeys } from "appsmith-utils/src/object"; import { itemList, longItemList, diff --git a/app/client/packages/design-system/widgets/src/components/ToolbarButtons/stories/ToolbarButtons.stories.tsx b/app/client/packages/design-system/widgets/src/components/ToolbarButtons/stories/ToolbarButtons.stories.tsx index 8ac6403e04b..bfd2fb12cf5 100644 --- a/app/client/packages/design-system/widgets/src/components/ToolbarButtons/stories/ToolbarButtons.stories.tsx +++ b/app/client/packages/design-system/widgets/src/components/ToolbarButtons/stories/ToolbarButtons.stories.tsx @@ -4,10 +4,10 @@ import { BUTTON_VARIANTS, COLORS, Flex, - objectKeys, ToolbarButtons, SIZES, } from "@design-system/widgets"; +import { objectKeys } from "appsmith-utils/src/object"; import { itemList, itemListWithIcons, diff --git a/app/client/packages/design-system/widgets/src/utils/index.ts b/app/client/packages/design-system/widgets/src/utils/index.ts index eab50f1fb4f..92af43695ef 100644 --- a/app/client/packages/design-system/widgets/src/utils/index.ts +++ b/app/client/packages/design-system/widgets/src/utils/index.ts @@ -1,2 +1 @@ export { filterDataProps } from "./filterDataProps"; -export { objectKeys } from "./objectKeys"; diff --git a/app/client/packages/utils/.eslintrc.json b/app/client/packages/utils/.eslintrc.json new file mode 100644 index 00000000000..b6652ce70c7 --- /dev/null +++ b/app/client/packages/utils/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": ["../../.eslintrc.base.json"] +} diff --git a/app/client/packages/utils/index.d.ts b/app/client/packages/utils/index.d.ts new file mode 100644 index 00000000000..1711ca500ba --- /dev/null +++ b/app/client/packages/utils/index.d.ts @@ -0,0 +1 @@ +declare module "appsmith-utils"; diff --git a/app/client/packages/utils/jest.config.js b/app/client/packages/utils/jest.config.js new file mode 100644 index 00000000000..2812cd5e029 --- /dev/null +++ b/app/client/packages/utils/jest.config.js @@ -0,0 +1,12 @@ +module.exports = { + roots: ["/src"], + transform: { + "^.+\\.(png|js|ts|tsx)$": ["ts-jest", { + isolatedModules: true, + }], + }, + testTimeout: 9000, + testRegex: "(/__tests__/.*|(\\.|/)(test|spec))\\.(tsx|ts|js)?$", + moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"], + moduleDirectories: ["node_modules", "src"], +}; diff --git a/app/client/packages/utils/package.json b/app/client/packages/utils/package.json new file mode 100644 index 00000000000..b8062fcda95 --- /dev/null +++ b/app/client/packages/utils/package.json @@ -0,0 +1,18 @@ +{ + "name": "appsmith-utils", + "version": "1.0.0", + "description": "This package has all the shared util functions which can be used in different packages e.g. client, rts etc", + "main": "dist/index.js", + "scripts": { + "build": "tsc", + "test": "yarn g:jest" + }, + "author": "", + "license": "ISC", + "devDependencies": { + "@types/jest": "^29.5.12", + "jest": "^29.7.0", + "ts-jest": "^29.2.4", + "typescript": "^5.5.4" + } +} diff --git a/app/client/packages/utils/src/index.ts b/app/client/packages/utils/src/index.ts new file mode 100644 index 00000000000..58b59cdff32 --- /dev/null +++ b/app/client/packages/utils/src/index.ts @@ -0,0 +1 @@ +export * as object from "./object"; diff --git a/app/client/packages/utils/src/object/index.ts b/app/client/packages/utils/src/object/index.ts new file mode 100644 index 00000000000..f026fca10d6 --- /dev/null +++ b/app/client/packages/utils/src/object/index.ts @@ -0,0 +1 @@ +export { default as objectKeys } from "./keys"; diff --git a/app/client/packages/utils/src/object/keys.test.ts b/app/client/packages/utils/src/object/keys.test.ts new file mode 100644 index 00000000000..974b369eab8 --- /dev/null +++ b/app/client/packages/utils/src/object/keys.test.ts @@ -0,0 +1,7 @@ +import objectKeys from "./keys"; + +test("objectKeys should return all the keys in the object map pass to it.", () => { + const objectMap = { a: 1, b: 2, c: 3 }; + const keys = objectKeys(objectMap); + expect(keys).toStrictEqual(["a", "b", "c"]); +}); diff --git a/app/client/packages/design-system/widgets/src/utils/objectKeys.ts b/app/client/packages/utils/src/object/keys.ts similarity index 76% rename from app/client/packages/design-system/widgets/src/utils/objectKeys.ts rename to app/client/packages/utils/src/object/keys.ts index a638b663b07..3a9051dbb2f 100644 --- a/app/client/packages/design-system/widgets/src/utils/objectKeys.ts +++ b/app/client/packages/utils/src/object/keys.ts @@ -4,11 +4,14 @@ * when looping through the keys. This function returns an array of keys with the correct type information. * * with classic Object.keys: Object.keys({ a: 1, b: 2 }) -> string[] - * with objeetKeys: objectKeys({ a: 1, b: 2 }) -> ("a" | "b")[] + * with objectKeys: objectKeys({ a: 1, b: 2 }) -> ("a" | "b")[] * * @param object * @returns array of keys with correct type information */ -export function objectKeys(object: T) { + +export default function objectKeys( + object: T, +): Array { return Object.keys(object) as Array; } diff --git a/app/client/packages/utils/tsconfig.json b/app/client/packages/utils/tsconfig.json new file mode 100644 index 00000000000..4082f16a5d9 --- /dev/null +++ b/app/client/packages/utils/tsconfig.json @@ -0,0 +1,3 @@ +{ + "extends": "../../tsconfig.json" +} diff --git a/app/client/src/widgets/wds/WDSButtonWidget/config/defaultsConfig.ts b/app/client/src/widgets/wds/WDSButtonWidget/config/defaultsConfig.ts index faeb30f06e2..9f30e0dc0e7 100644 --- a/app/client/src/widgets/wds/WDSButtonWidget/config/defaultsConfig.ts +++ b/app/client/src/widgets/wds/WDSButtonWidget/config/defaultsConfig.ts @@ -1,6 +1,7 @@ import { RecaptchaTypes } from "components/constants"; -import { COLORS, BUTTON_VARIANTS, objectKeys } from "@design-system/widgets"; +import { COLORS, BUTTON_VARIANTS } from "@design-system/widgets"; import { ResponsiveBehavior } from "layoutSystems/common/utils/constants"; +import { objectKeys } from "appsmith-utils/src/object"; import { BUTTON_WIDGET_DEFAULT_LABEL, createMessage, diff --git a/app/client/src/widgets/wds/WDSButtonWidget/config/propertyPaneConfig/styleConfig.ts b/app/client/src/widgets/wds/WDSButtonWidget/config/propertyPaneConfig/styleConfig.ts index ca5e2c8aa16..0e5e54e602e 100644 --- a/app/client/src/widgets/wds/WDSButtonWidget/config/propertyPaneConfig/styleConfig.ts +++ b/app/client/src/widgets/wds/WDSButtonWidget/config/propertyPaneConfig/styleConfig.ts @@ -1,6 +1,7 @@ import { capitalize } from "lodash"; import { ValidationTypes } from "constants/WidgetValidation"; -import { COLORS, BUTTON_VARIANTS, objectKeys } from "@design-system/widgets"; +import { COLORS, BUTTON_VARIANTS } from "@design-system/widgets"; +import { objectKeys } from "appsmith-utils/src/object"; export const propertyPaneStyleConfig = [ { diff --git a/app/client/src/widgets/wds/WDSIconButtonWidget/config/defaultsConfig.ts b/app/client/src/widgets/wds/WDSIconButtonWidget/config/defaultsConfig.ts index 698ad414a8a..994e52644df 100644 --- a/app/client/src/widgets/wds/WDSIconButtonWidget/config/defaultsConfig.ts +++ b/app/client/src/widgets/wds/WDSIconButtonWidget/config/defaultsConfig.ts @@ -1,4 +1,5 @@ -import { BUTTON_VARIANTS, COLORS, objectKeys } from "@design-system/widgets"; +import { BUTTON_VARIANTS, COLORS } from "@design-system/widgets"; +import { objectKeys } from "appsmith-utils/src/object"; import { ResponsiveBehavior } from "layoutSystems/common/utils/constants"; export const defaultsConfig = { diff --git a/app/client/src/widgets/wds/WDSIconButtonWidget/config/propertyPaneConfig/styleConfig.ts b/app/client/src/widgets/wds/WDSIconButtonWidget/config/propertyPaneConfig/styleConfig.ts index 70ef075917d..26da3524b57 100644 --- a/app/client/src/widgets/wds/WDSIconButtonWidget/config/propertyPaneConfig/styleConfig.ts +++ b/app/client/src/widgets/wds/WDSIconButtonWidget/config/propertyPaneConfig/styleConfig.ts @@ -1,5 +1,6 @@ import { capitalize } from "lodash"; -import { BUTTON_VARIANTS, COLORS, objectKeys } from "@design-system/widgets"; +import { BUTTON_VARIANTS, COLORS } from "@design-system/widgets"; +import { objectKeys } from "appsmith-utils/src/object"; import { ValidationTypes } from "constants/WidgetValidation"; export const propertyPaneStyleConfig = [ diff --git a/app/client/src/widgets/wds/WDSInlineButtonsWidget/config/propertyPaneConfig/contentConfig.ts b/app/client/src/widgets/wds/WDSInlineButtonsWidget/config/propertyPaneConfig/contentConfig.ts index e88f0181085..72579082ae2 100644 --- a/app/client/src/widgets/wds/WDSInlineButtonsWidget/config/propertyPaneConfig/contentConfig.ts +++ b/app/client/src/widgets/wds/WDSInlineButtonsWidget/config/propertyPaneConfig/contentConfig.ts @@ -1,10 +1,11 @@ -import { BUTTON_VARIANTS, COLORS, objectKeys } from "@design-system/widgets"; +import { BUTTON_VARIANTS, COLORS } from "@design-system/widgets"; import { BUTTON_WIDGET_DEFAULT_LABEL, createMessage, } from "ee/constants/messages"; import { ValidationTypes } from "constants/WidgetValidation"; import { capitalize } from "lodash"; +import { objectKeys } from "appsmith-utils/src/object"; export const propertyPaneContentConfig = [ { diff --git a/app/client/src/widgets/wds/WDSMenuButtonWidget/config/defaultsConfig.ts b/app/client/src/widgets/wds/WDSMenuButtonWidget/config/defaultsConfig.ts index da8c271d6f9..f3c9903431f 100644 --- a/app/client/src/widgets/wds/WDSMenuButtonWidget/config/defaultsConfig.ts +++ b/app/client/src/widgets/wds/WDSMenuButtonWidget/config/defaultsConfig.ts @@ -1,5 +1,6 @@ -import { BUTTON_VARIANTS, COLORS, objectKeys } from "@design-system/widgets"; +import { BUTTON_VARIANTS, COLORS } from "@design-system/widgets"; import type { WidgetDefaultProps } from "WidgetProvider/constants"; +import { objectKeys } from "appsmith-utils/src/object"; export const defaultsConfig = { label: "Open The Menu…", diff --git a/app/client/src/widgets/wds/WDSMenuButtonWidget/config/propertyPaneConfig/styleConfig.ts b/app/client/src/widgets/wds/WDSMenuButtonWidget/config/propertyPaneConfig/styleConfig.ts index b9de5480464..f11a5568cab 100644 --- a/app/client/src/widgets/wds/WDSMenuButtonWidget/config/propertyPaneConfig/styleConfig.ts +++ b/app/client/src/widgets/wds/WDSMenuButtonWidget/config/propertyPaneConfig/styleConfig.ts @@ -1,11 +1,7 @@ import { capitalize } from "lodash"; import { ValidationTypes } from "constants/WidgetValidation"; -import { - BUTTON_VARIANTS, - COLORS, - ICONS, - objectKeys, -} from "@design-system/widgets"; +import { BUTTON_VARIANTS, COLORS, ICONS } from "@design-system/widgets"; +import { objectKeys } from "appsmith-utils/src/object"; import type { MenuButtonWidgetProps } from "../../widget/types"; diff --git a/app/client/src/widgets/wds/WDSTableWidget/config/propertyPaneConfig/PanelConfig/General.ts b/app/client/src/widgets/wds/WDSTableWidget/config/propertyPaneConfig/PanelConfig/General.ts index 62cee626470..1cde4b2ef03 100644 --- a/app/client/src/widgets/wds/WDSTableWidget/config/propertyPaneConfig/PanelConfig/General.ts +++ b/app/client/src/widgets/wds/WDSTableWidget/config/propertyPaneConfig/PanelConfig/General.ts @@ -2,7 +2,8 @@ import { ValidationTypes } from "constants/WidgetValidation"; import type { TableWidgetProps } from "widgets/wds/WDSTableWidget/constants"; import { ColumnTypes } from "widgets/wds/WDSTableWidget/constants"; import { hideByColumnType } from "../../../widget/propertyUtils"; -import { BUTTON_VARIANTS, objectKeys } from "@design-system/widgets"; +import { BUTTON_VARIANTS } from "@design-system/widgets"; +import { objectKeys } from "appsmith-utils/src/object"; export default { sectionName: "General", diff --git a/app/client/src/widgets/wds/WDSToolbarButtonsWidget/config/propertyPaneConfig/styleConfig.ts b/app/client/src/widgets/wds/WDSToolbarButtonsWidget/config/propertyPaneConfig/styleConfig.ts index ee59b2189ac..ff176be958e 100644 --- a/app/client/src/widgets/wds/WDSToolbarButtonsWidget/config/propertyPaneConfig/styleConfig.ts +++ b/app/client/src/widgets/wds/WDSToolbarButtonsWidget/config/propertyPaneConfig/styleConfig.ts @@ -1,6 +1,7 @@ -import { BUTTON_VARIANTS, COLORS, objectKeys } from "@design-system/widgets"; +import { BUTTON_VARIANTS, COLORS } from "@design-system/widgets"; import { ValidationTypes } from "constants/WidgetValidation"; import { capitalize } from "lodash"; +import { objectKeys } from "appsmith-utils/src/object"; export const propertyPaneStyleConfig = [ { diff --git a/app/client/yarn.lock b/app/client/yarn.lock index 65b8e2c6167..08e38215b78 100644 --- a/app/client/yarn.lock +++ b/app/client/yarn.lock @@ -10916,13 +10916,13 @@ __metadata: languageName: node linkType: hard -"@types/jest@npm:*, @types/jest@npm:^29.2.3": - version: 29.4.0 - resolution: "@types/jest@npm:29.4.0" +"@types/jest@npm:*, @types/jest@npm:^29.2.3, @types/jest@npm:^29.5.12": + version: 29.5.12 + resolution: "@types/jest@npm:29.5.12" dependencies: expect: ^29.0.0 pretty-format: ^29.0.0 - checksum: 23760282362a252e6690314584d83a47512d4cd61663e957ed3398ecf98195fe931c45606ee2f9def12f8ed7d8aa102d492ec42d26facdaf8b78094a31e6568e + checksum: 19b1efdeed9d9a60a81edc8226cdeae5af7479e493eaed273e01243891c9651f7b8b4c08fc633a7d0d1d379b091c4179bbaa0807af62542325fd72f2dd17ce1c languageName: node linkType: hard @@ -13150,6 +13150,17 @@ __metadata: languageName: unknown linkType: soft +"appsmith-utils@workspace:^, appsmith-utils@workspace:packages/utils": + version: 0.0.0-use.local + resolution: "appsmith-utils@workspace:packages/utils" + dependencies: + "@types/jest": ^29.5.12 + jest: ^29.7.0 + ts-jest: ^29.2.4 + typescript: ^5.5.4 + languageName: unknown + linkType: soft + "appsmith@workspace:.": version: 0.0.0-use.local resolution: "appsmith@workspace:." @@ -13272,6 +13283,7 @@ __metadata: "@welldone-software/why-did-you-render": ^4.2.5 algoliasearch: ^4.2.0 appsmith-icons: "workspace:^" + appsmith-utils: "workspace:^" assert-never: ^1.2.1 astring: ^1.7.5 async-mutex: ^0.5.0 @@ -23772,7 +23784,7 @@ __metadata: languageName: node linkType: hard -"jest@npm:^29.3.1, jest@npm:^29.5.0, jest@npm:^29.6.4": +"jest@npm:^29.3.1, jest@npm:^29.5.0, jest@npm:^29.6.4, jest@npm:^29.7.0": version: 29.7.0 resolution: "jest@npm:29.7.0" dependencies: @@ -34061,7 +34073,7 @@ __metadata: languageName: node linkType: hard -"ts-jest@npm:29.1.0, ts-jest@npm:^29.1.0": +"ts-jest@npm:29.1.0": version: 29.1.0 resolution: "ts-jest@npm:29.1.0" dependencies: @@ -34094,6 +34106,43 @@ __metadata: languageName: node linkType: hard +"ts-jest@npm:^29.1.0, ts-jest@npm:^29.2.4": + version: 29.2.4 + resolution: "ts-jest@npm:29.2.4" + dependencies: + bs-logger: 0.x + ejs: ^3.1.10 + fast-json-stable-stringify: 2.x + jest-util: ^29.0.0 + json5: ^2.2.3 + lodash.memoize: 4.x + make-error: 1.x + semver: ^7.5.3 + yargs-parser: ^21.0.1 + peerDependencies: + "@babel/core": ">=7.0.0-beta.0 <8" + "@jest/transform": ^29.0.0 + "@jest/types": ^29.0.0 + babel-jest: ^29.0.0 + jest: ^29.0.0 + typescript: ">=4.3 <6" + peerDependenciesMeta: + "@babel/core": + optional: true + "@jest/transform": + optional: true + "@jest/types": + optional: true + babel-jest: + optional: true + esbuild: + optional: true + bin: + ts-jest: cli.js + checksum: 142246f12bb11d5edbfb5a65e298097667e2c4d390e316e356416ce00d3cd157220dbfb9de2a56b38f30776bc92ba59eff9fd78e9345ba4c6712783f27f5475a + languageName: node + linkType: hard + "ts-loader@npm:^9.4.1": version: 9.4.1 resolution: "ts-loader@npm:9.4.1" From 5606509b1aa6e0de550230f8fa8da9dffe4a6973 Mon Sep 17 00:00:00 2001 From: Aman Agarwal Date: Tue, 13 Aug 2024 16:32:47 +0530 Subject: [PATCH 02/21] fix: utils packages imports --- app/client/package.json | 2 +- .../design-system/widgets/package.json | 1 + .../chromatic/Button.chromatic.stories.tsx | 2 +- .../Button/stories/Button.stories.tsx | 2 +- .../IconButton/stories/IconButton.stories.tsx | 2 +- .../stories/InlineButtons.stories.tsx | 2 +- .../stories/ToolbarButtons.stories.tsx | 2 +- app/client/packages/utils/.eslintignore | 2 ++ app/client/packages/utils/.prettierignore | 1 + app/client/packages/utils/index.d.ts | 1 - app/client/packages/utils/jest.config.js | 6 ++--- app/client/packages/utils/package.json | 12 +++++---- app/client/packages/utils/src/index.d.ts | 1 + app/client/packages/utils/tsconfig.json | 20 ++++++++++++++- .../WDSButtonWidget/config/defaultsConfig.ts | 2 +- .../config/propertyPaneConfig/styleConfig.ts | 2 +- .../config/defaultsConfig.ts | 2 +- .../config/propertyPaneConfig/styleConfig.ts | 2 +- .../propertyPaneConfig/contentConfig.ts | 2 +- .../config/defaultsConfig.ts | 2 +- .../config/propertyPaneConfig/styleConfig.ts | 2 +- .../propertyPaneConfig/PanelConfig/General.ts | 2 +- .../config/propertyPaneConfig/styleConfig.ts | 2 +- app/client/yarn.lock | 25 ++++++++++--------- 24 files changed, 62 insertions(+), 37 deletions(-) create mode 100644 app/client/packages/utils/.eslintignore create mode 100644 app/client/packages/utils/.prettierignore delete mode 100644 app/client/packages/utils/index.d.ts create mode 100644 app/client/packages/utils/src/index.d.ts diff --git a/app/client/package.json b/app/client/package.json index e05741f2a03..8d491e116b7 100644 --- a/app/client/package.json +++ b/app/client/package.json @@ -50,6 +50,7 @@ "dependencies": { "@appsmith/ads": "workspace:^", "@appsmith/ads-old": "workspace:^", + "@appsmith/utils": "workspace:^", "@aws-sdk/client-s3": "^3.622.0", "@aws-sdk/lib-storage": "^3.622.0", "@babel/standalone": "^7.23.6", @@ -106,7 +107,6 @@ "@welldone-software/why-did-you-render": "^4.2.5", "algoliasearch": "^4.2.0", "appsmith-icons": "workspace:^", - "appsmith-utils": "workspace:^", "assert-never": "^1.2.1", "astring": "^1.7.5", "async-mutex": "^0.5.0", diff --git a/app/client/packages/design-system/widgets/package.json b/app/client/packages/design-system/widgets/package.json index 6fe7d1c212a..ceee2b6c28a 100644 --- a/app/client/packages/design-system/widgets/package.json +++ b/app/client/packages/design-system/widgets/package.json @@ -11,6 +11,7 @@ "build:icons": "npx tsx ./src/scripts/build-icons.ts" }, "dependencies": { + "@appsmith/utils": "workspace:^", "@design-system/headless": "workspace:^", "@design-system/theming": "workspace:^", "@emotion/css": "^11.11.2", diff --git a/app/client/packages/design-system/widgets/src/components/Button/chromatic/Button.chromatic.stories.tsx b/app/client/packages/design-system/widgets/src/components/Button/chromatic/Button.chromatic.stories.tsx index 130d8c5d84f..a3fcb0667dc 100644 --- a/app/client/packages/design-system/widgets/src/components/Button/chromatic/Button.chromatic.stories.tsx +++ b/app/client/packages/design-system/widgets/src/components/Button/chromatic/Button.chromatic.stories.tsx @@ -2,7 +2,7 @@ import React from "react"; import type { Meta, StoryObj } from "@storybook/react"; import { StoryGrid, DataAttrWrapper } from "@design-system/storybook"; import { Button, BUTTON_VARIANTS, COLORS } from "@design-system/widgets"; -import { objectKeys } from "appsmith-utils/src/object"; +import { objectKeys } from "@appsmith/utils/src/object"; const variants = objectKeys(BUTTON_VARIANTS); const colors = Object.values(COLORS); diff --git a/app/client/packages/design-system/widgets/src/components/Button/stories/Button.stories.tsx b/app/client/packages/design-system/widgets/src/components/Button/stories/Button.stories.tsx index 18ab810674e..02636c17991 100644 --- a/app/client/packages/design-system/widgets/src/components/Button/stories/Button.stories.tsx +++ b/app/client/packages/design-system/widgets/src/components/Button/stories/Button.stories.tsx @@ -7,7 +7,7 @@ import { COLORS, SIZES, } from "@design-system/widgets"; -import { objectKeys } from "appsmith-utils/src/object"; +import { objectKeys } from "@appsmith/utils/src/object"; /** * A button is a clickable element that is used to trigger an action. diff --git a/app/client/packages/design-system/widgets/src/components/IconButton/stories/IconButton.stories.tsx b/app/client/packages/design-system/widgets/src/components/IconButton/stories/IconButton.stories.tsx index 9aaab66b55e..fc078aa4121 100644 --- a/app/client/packages/design-system/widgets/src/components/IconButton/stories/IconButton.stories.tsx +++ b/app/client/packages/design-system/widgets/src/components/IconButton/stories/IconButton.stories.tsx @@ -7,7 +7,7 @@ import { BUTTON_VARIANTS, COLORS, } from "@design-system/widgets"; -import { objectKeys } from "appsmith-utils/src/object"; +import { objectKeys } from "@appsmith/utils/src/object"; /** * Icon Button is a button component that only contains an icon. diff --git a/app/client/packages/design-system/widgets/src/components/InlineButtons/stories/InlineButtons.stories.tsx b/app/client/packages/design-system/widgets/src/components/InlineButtons/stories/InlineButtons.stories.tsx index bfe54673169..e8808613f38 100644 --- a/app/client/packages/design-system/widgets/src/components/InlineButtons/stories/InlineButtons.stories.tsx +++ b/app/client/packages/design-system/widgets/src/components/InlineButtons/stories/InlineButtons.stories.tsx @@ -7,7 +7,7 @@ import { SIZES, } from "@design-system/widgets"; import type { Meta, StoryObj } from "@storybook/react"; -import { objectKeys } from "appsmith-utils/src/object"; +import { objectKeys } from "@appsmith/utils/src/object"; import { itemList, longItemList, diff --git a/app/client/packages/design-system/widgets/src/components/ToolbarButtons/stories/ToolbarButtons.stories.tsx b/app/client/packages/design-system/widgets/src/components/ToolbarButtons/stories/ToolbarButtons.stories.tsx index bfd2fb12cf5..e9727d112ac 100644 --- a/app/client/packages/design-system/widgets/src/components/ToolbarButtons/stories/ToolbarButtons.stories.tsx +++ b/app/client/packages/design-system/widgets/src/components/ToolbarButtons/stories/ToolbarButtons.stories.tsx @@ -7,7 +7,7 @@ import { ToolbarButtons, SIZES, } from "@design-system/widgets"; -import { objectKeys } from "appsmith-utils/src/object"; +import { objectKeys } from "@appsmith/utils/src/object"; import { itemList, itemListWithIcons, diff --git a/app/client/packages/utils/.eslintignore b/app/client/packages/utils/.eslintignore new file mode 100644 index 00000000000..60c723a5cb3 --- /dev/null +++ b/app/client/packages/utils/.eslintignore @@ -0,0 +1,2 @@ +**/*.d.ts +./src/**/*.d.ts \ No newline at end of file diff --git a/app/client/packages/utils/.prettierignore b/app/client/packages/utils/.prettierignore new file mode 100644 index 00000000000..b7e99510bea --- /dev/null +++ b/app/client/packages/utils/.prettierignore @@ -0,0 +1 @@ +jest.config.js \ No newline at end of file diff --git a/app/client/packages/utils/index.d.ts b/app/client/packages/utils/index.d.ts deleted file mode 100644 index 1711ca500ba..00000000000 --- a/app/client/packages/utils/index.d.ts +++ /dev/null @@ -1 +0,0 @@ -declare module "appsmith-utils"; diff --git a/app/client/packages/utils/jest.config.js b/app/client/packages/utils/jest.config.js index 2812cd5e029..660dcae6be5 100644 --- a/app/client/packages/utils/jest.config.js +++ b/app/client/packages/utils/jest.config.js @@ -1,12 +1,12 @@ module.exports = { roots: ["/src"], transform: { - "^.+\\.(png|js|ts|tsx)$": ["ts-jest", { + "^.+\\.(ts)$": ["ts-jest", { isolatedModules: true, }], }, testTimeout: 9000, - testRegex: "(/__tests__/.*|(\\.|/)(test|spec))\\.(tsx|ts|js)?$", - moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"], + testRegex: "(/__tests__/.*|(\\.|/)(test|spec))\\.(ts)?$", + moduleFileExtensions: ["ts"], moduleDirectories: ["node_modules", "src"], }; diff --git a/app/client/packages/utils/package.json b/app/client/packages/utils/package.json index b8062fcda95..9f0057c0d2a 100644 --- a/app/client/packages/utils/package.json +++ b/app/client/packages/utils/package.json @@ -1,13 +1,15 @@ { - "name": "appsmith-utils", + "name": "@appsmith/utils", "version": "1.0.0", "description": "This package has all the shared util functions which can be used in different packages e.g. client, rts etc", - "main": "dist/index.js", + "main": "src/index.ts", + "types": "src/index.d.ts", "scripts": { - "build": "tsc", - "test": "yarn g:jest" + "lint": "yarn g:lint", + "prettier": "yarn g:prettier", + "test:unit": "yarn g:jest" }, - "author": "", + "author": "Aman Agarwal , Pawan Kumar ", "license": "ISC", "devDependencies": { "@types/jest": "^29.5.12", diff --git a/app/client/packages/utils/src/index.d.ts b/app/client/packages/utils/src/index.d.ts new file mode 100644 index 00000000000..2fe226f0295 --- /dev/null +++ b/app/client/packages/utils/src/index.d.ts @@ -0,0 +1 @@ +declare module "@appsmith/utils"; diff --git a/app/client/packages/utils/tsconfig.json b/app/client/packages/utils/tsconfig.json index 4082f16a5d9..eac4922150e 100644 --- a/app/client/packages/utils/tsconfig.json +++ b/app/client/packages/utils/tsconfig.json @@ -1,3 +1,21 @@ { - "extends": "../../tsconfig.json" + "compilerOptions": { + "outDir": "./dist", + "rootDir": "./src", + "target": "es6", + "baseUrl": "./", + "allowJs": true, + "skipLibCheck": true, + "strict": true, + "esModuleInterop": true, + "module": "ESNext", + "isolatedModules": true, + "paths": { + "@appsmith/utils/*": ["src/*"], + "@*": ["src/*"] + }, + "typeRoots": ["./src"] + }, + "include": ["src/**/*", "**/*.ts"], + "exclude": ["node_modules", "dist"] } diff --git a/app/client/src/widgets/wds/WDSButtonWidget/config/defaultsConfig.ts b/app/client/src/widgets/wds/WDSButtonWidget/config/defaultsConfig.ts index 9f30e0dc0e7..ee8c66131c9 100644 --- a/app/client/src/widgets/wds/WDSButtonWidget/config/defaultsConfig.ts +++ b/app/client/src/widgets/wds/WDSButtonWidget/config/defaultsConfig.ts @@ -1,7 +1,7 @@ import { RecaptchaTypes } from "components/constants"; import { COLORS, BUTTON_VARIANTS } from "@design-system/widgets"; import { ResponsiveBehavior } from "layoutSystems/common/utils/constants"; -import { objectKeys } from "appsmith-utils/src/object"; +import { objectKeys } from "@appsmith/utils/src/object"; import { BUTTON_WIDGET_DEFAULT_LABEL, createMessage, diff --git a/app/client/src/widgets/wds/WDSButtonWidget/config/propertyPaneConfig/styleConfig.ts b/app/client/src/widgets/wds/WDSButtonWidget/config/propertyPaneConfig/styleConfig.ts index 0e5e54e602e..c2c7f810f8e 100644 --- a/app/client/src/widgets/wds/WDSButtonWidget/config/propertyPaneConfig/styleConfig.ts +++ b/app/client/src/widgets/wds/WDSButtonWidget/config/propertyPaneConfig/styleConfig.ts @@ -1,7 +1,7 @@ import { capitalize } from "lodash"; import { ValidationTypes } from "constants/WidgetValidation"; import { COLORS, BUTTON_VARIANTS } from "@design-system/widgets"; -import { objectKeys } from "appsmith-utils/src/object"; +import { objectKeys } from "@appsmith/utils/src/object"; export const propertyPaneStyleConfig = [ { diff --git a/app/client/src/widgets/wds/WDSIconButtonWidget/config/defaultsConfig.ts b/app/client/src/widgets/wds/WDSIconButtonWidget/config/defaultsConfig.ts index 994e52644df..52bd88f0467 100644 --- a/app/client/src/widgets/wds/WDSIconButtonWidget/config/defaultsConfig.ts +++ b/app/client/src/widgets/wds/WDSIconButtonWidget/config/defaultsConfig.ts @@ -1,5 +1,5 @@ import { BUTTON_VARIANTS, COLORS } from "@design-system/widgets"; -import { objectKeys } from "appsmith-utils/src/object"; +import { objectKeys } from "@appsmith/utils/src/object"; import { ResponsiveBehavior } from "layoutSystems/common/utils/constants"; export const defaultsConfig = { diff --git a/app/client/src/widgets/wds/WDSIconButtonWidget/config/propertyPaneConfig/styleConfig.ts b/app/client/src/widgets/wds/WDSIconButtonWidget/config/propertyPaneConfig/styleConfig.ts index 26da3524b57..e4bc74b9de4 100644 --- a/app/client/src/widgets/wds/WDSIconButtonWidget/config/propertyPaneConfig/styleConfig.ts +++ b/app/client/src/widgets/wds/WDSIconButtonWidget/config/propertyPaneConfig/styleConfig.ts @@ -1,6 +1,6 @@ import { capitalize } from "lodash"; import { BUTTON_VARIANTS, COLORS } from "@design-system/widgets"; -import { objectKeys } from "appsmith-utils/src/object"; +import { objectKeys } from "@appsmith/utils/src/object"; import { ValidationTypes } from "constants/WidgetValidation"; export const propertyPaneStyleConfig = [ diff --git a/app/client/src/widgets/wds/WDSInlineButtonsWidget/config/propertyPaneConfig/contentConfig.ts b/app/client/src/widgets/wds/WDSInlineButtonsWidget/config/propertyPaneConfig/contentConfig.ts index 72579082ae2..2a518e4fc59 100644 --- a/app/client/src/widgets/wds/WDSInlineButtonsWidget/config/propertyPaneConfig/contentConfig.ts +++ b/app/client/src/widgets/wds/WDSInlineButtonsWidget/config/propertyPaneConfig/contentConfig.ts @@ -5,7 +5,7 @@ import { } from "ee/constants/messages"; import { ValidationTypes } from "constants/WidgetValidation"; import { capitalize } from "lodash"; -import { objectKeys } from "appsmith-utils/src/object"; +import { objectKeys } from "@appsmith/utils/src/object"; export const propertyPaneContentConfig = [ { diff --git a/app/client/src/widgets/wds/WDSMenuButtonWidget/config/defaultsConfig.ts b/app/client/src/widgets/wds/WDSMenuButtonWidget/config/defaultsConfig.ts index f3c9903431f..577f4f1037b 100644 --- a/app/client/src/widgets/wds/WDSMenuButtonWidget/config/defaultsConfig.ts +++ b/app/client/src/widgets/wds/WDSMenuButtonWidget/config/defaultsConfig.ts @@ -1,6 +1,6 @@ import { BUTTON_VARIANTS, COLORS } from "@design-system/widgets"; import type { WidgetDefaultProps } from "WidgetProvider/constants"; -import { objectKeys } from "appsmith-utils/src/object"; +import { objectKeys } from "@appsmith/utils/src/object"; export const defaultsConfig = { label: "Open The Menu…", diff --git a/app/client/src/widgets/wds/WDSMenuButtonWidget/config/propertyPaneConfig/styleConfig.ts b/app/client/src/widgets/wds/WDSMenuButtonWidget/config/propertyPaneConfig/styleConfig.ts index f11a5568cab..c93c59e8b2e 100644 --- a/app/client/src/widgets/wds/WDSMenuButtonWidget/config/propertyPaneConfig/styleConfig.ts +++ b/app/client/src/widgets/wds/WDSMenuButtonWidget/config/propertyPaneConfig/styleConfig.ts @@ -1,7 +1,7 @@ import { capitalize } from "lodash"; import { ValidationTypes } from "constants/WidgetValidation"; import { BUTTON_VARIANTS, COLORS, ICONS } from "@design-system/widgets"; -import { objectKeys } from "appsmith-utils/src/object"; +import { objectKeys } from "@appsmith/utils/src/object"; import type { MenuButtonWidgetProps } from "../../widget/types"; diff --git a/app/client/src/widgets/wds/WDSTableWidget/config/propertyPaneConfig/PanelConfig/General.ts b/app/client/src/widgets/wds/WDSTableWidget/config/propertyPaneConfig/PanelConfig/General.ts index 1cde4b2ef03..fa904888054 100644 --- a/app/client/src/widgets/wds/WDSTableWidget/config/propertyPaneConfig/PanelConfig/General.ts +++ b/app/client/src/widgets/wds/WDSTableWidget/config/propertyPaneConfig/PanelConfig/General.ts @@ -3,7 +3,7 @@ import type { TableWidgetProps } from "widgets/wds/WDSTableWidget/constants"; import { ColumnTypes } from "widgets/wds/WDSTableWidget/constants"; import { hideByColumnType } from "../../../widget/propertyUtils"; import { BUTTON_VARIANTS } from "@design-system/widgets"; -import { objectKeys } from "appsmith-utils/src/object"; +import { objectKeys } from "@appsmith/utils/src/object"; export default { sectionName: "General", diff --git a/app/client/src/widgets/wds/WDSToolbarButtonsWidget/config/propertyPaneConfig/styleConfig.ts b/app/client/src/widgets/wds/WDSToolbarButtonsWidget/config/propertyPaneConfig/styleConfig.ts index ff176be958e..47491c3cf73 100644 --- a/app/client/src/widgets/wds/WDSToolbarButtonsWidget/config/propertyPaneConfig/styleConfig.ts +++ b/app/client/src/widgets/wds/WDSToolbarButtonsWidget/config/propertyPaneConfig/styleConfig.ts @@ -1,7 +1,7 @@ import { BUTTON_VARIANTS, COLORS } from "@design-system/widgets"; import { ValidationTypes } from "constants/WidgetValidation"; import { capitalize } from "lodash"; -import { objectKeys } from "appsmith-utils/src/object"; +import { objectKeys } from "@appsmith/utils/src/object"; export const propertyPaneStyleConfig = [ { diff --git a/app/client/yarn.lock b/app/client/yarn.lock index 08e38215b78..98b553606ab 100644 --- a/app/client/yarn.lock +++ b/app/client/yarn.lock @@ -228,6 +228,17 @@ __metadata: languageName: unknown linkType: soft +"@appsmith/utils@workspace:^, @appsmith/utils@workspace:packages/utils": + version: 0.0.0-use.local + resolution: "@appsmith/utils@workspace:packages/utils" + dependencies: + "@types/jest": ^29.5.12 + jest: ^29.7.0 + ts-jest: ^29.2.4 + typescript: ^5.5.4 + languageName: unknown + linkType: soft + "@aws-crypto/crc32@npm:5.2.0": version: 5.2.0 resolution: "@aws-crypto/crc32@npm:5.2.0" @@ -3188,6 +3199,7 @@ __metadata: version: 0.0.0-use.local resolution: "@design-system/widgets@workspace:packages/design-system/widgets" dependencies: + "@appsmith/utils": "workspace:^" "@design-system/headless": "workspace:^" "@design-system/theming": "workspace:^" "@emotion/css": ^11.11.2 @@ -13150,23 +13162,13 @@ __metadata: languageName: unknown linkType: soft -"appsmith-utils@workspace:^, appsmith-utils@workspace:packages/utils": - version: 0.0.0-use.local - resolution: "appsmith-utils@workspace:packages/utils" - dependencies: - "@types/jest": ^29.5.12 - jest: ^29.7.0 - ts-jest: ^29.2.4 - typescript: ^5.5.4 - languageName: unknown - linkType: soft - "appsmith@workspace:.": version: 0.0.0-use.local resolution: "appsmith@workspace:." dependencies: "@appsmith/ads": "workspace:^" "@appsmith/ads-old": "workspace:^" + "@appsmith/utils": "workspace:^" "@aws-sdk/client-s3": ^3.622.0 "@aws-sdk/lib-storage": ^3.622.0 "@babel/helper-create-regexp-features-plugin": ^7.18.6 @@ -13283,7 +13285,6 @@ __metadata: "@welldone-software/why-did-you-render": ^4.2.5 algoliasearch: ^4.2.0 appsmith-icons: "workspace:^" - appsmith-utils: "workspace:^" assert-never: ^1.2.1 astring: ^1.7.5 async-mutex: ^0.5.0 From dbb3c9a0fb77fedde895cb64f6c36acf2a37b85f Mon Sep 17 00:00:00 2001 From: Aman Agarwal Date: Tue, 13 Aug 2024 16:35:43 +0530 Subject: [PATCH 03/21] fix: jest config --- app/client/packages/utils/jest.config.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/app/client/packages/utils/jest.config.js b/app/client/packages/utils/jest.config.js index 660dcae6be5..41e98d5d6d3 100644 --- a/app/client/packages/utils/jest.config.js +++ b/app/client/packages/utils/jest.config.js @@ -5,8 +5,4 @@ module.exports = { isolatedModules: true, }], }, - testTimeout: 9000, - testRegex: "(/__tests__/.*|(\\.|/)(test|spec))\\.(ts)?$", - moduleFileExtensions: ["ts"], - moduleDirectories: ["node_modules", "src"], }; From dabf5e4f98ace417d1300565bf135dfabaabe5f0 Mon Sep 17 00:00:00 2001 From: Aman Agarwal Date: Tue, 13 Aug 2024 16:44:25 +0530 Subject: [PATCH 04/21] fix: changed to named exports --- app/client/packages/utils/src/object/index.ts | 2 +- app/client/packages/utils/src/object/keys.test.ts | 2 +- app/client/packages/utils/src/object/keys.ts | 4 +--- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/app/client/packages/utils/src/object/index.ts b/app/client/packages/utils/src/object/index.ts index f026fca10d6..b983a09bae5 100644 --- a/app/client/packages/utils/src/object/index.ts +++ b/app/client/packages/utils/src/object/index.ts @@ -1 +1 @@ -export { default as objectKeys } from "./keys"; +export { objectKeys } from "./keys"; diff --git a/app/client/packages/utils/src/object/keys.test.ts b/app/client/packages/utils/src/object/keys.test.ts index 974b369eab8..33f7cb52864 100644 --- a/app/client/packages/utils/src/object/keys.test.ts +++ b/app/client/packages/utils/src/object/keys.test.ts @@ -1,4 +1,4 @@ -import objectKeys from "./keys"; +import { objectKeys } from "./keys"; test("objectKeys should return all the keys in the object map pass to it.", () => { const objectMap = { a: 1, b: 2, c: 3 }; diff --git a/app/client/packages/utils/src/object/keys.ts b/app/client/packages/utils/src/object/keys.ts index 3a9051dbb2f..62a401fc285 100644 --- a/app/client/packages/utils/src/object/keys.ts +++ b/app/client/packages/utils/src/object/keys.ts @@ -10,8 +10,6 @@ * @returns array of keys with correct type information */ -export default function objectKeys( - object: T, -): Array { +export function objectKeys(object: T): Array { return Object.keys(object) as Array; } From bc86aab151feaea7e9e75e22021f5d8e988d64b5 Mon Sep 17 00:00:00 2001 From: Valera Melnikov Date: Tue, 13 Aug 2024 14:25:11 +0300 Subject: [PATCH 05/21] fix: package structure --- .../chromatic/Button.chromatic.stories.tsx | 2 +- app/client/packages/utils/.eslintignore | 2 -- app/client/packages/utils/.prettierignore | 1 - app/client/packages/utils/package.json | 8 +------ app/client/packages/utils/src/index.d.ts | 1 - app/client/packages/utils/src/index.ts | 2 +- app/client/packages/utils/tsconfig.json | 21 ++----------------- app/client/yarn.lock | 11 +++------- 8 files changed, 8 insertions(+), 40 deletions(-) delete mode 100644 app/client/packages/utils/.eslintignore delete mode 100644 app/client/packages/utils/.prettierignore delete mode 100644 app/client/packages/utils/src/index.d.ts diff --git a/app/client/packages/design-system/widgets/src/components/Button/chromatic/Button.chromatic.stories.tsx b/app/client/packages/design-system/widgets/src/components/Button/chromatic/Button.chromatic.stories.tsx index a3fcb0667dc..3242f0f4b68 100644 --- a/app/client/packages/design-system/widgets/src/components/Button/chromatic/Button.chromatic.stories.tsx +++ b/app/client/packages/design-system/widgets/src/components/Button/chromatic/Button.chromatic.stories.tsx @@ -2,7 +2,7 @@ import React from "react"; import type { Meta, StoryObj } from "@storybook/react"; import { StoryGrid, DataAttrWrapper } from "@design-system/storybook"; import { Button, BUTTON_VARIANTS, COLORS } from "@design-system/widgets"; -import { objectKeys } from "@appsmith/utils/src/object"; +import { objectKeys } from "@appsmith/utils"; const variants = objectKeys(BUTTON_VARIANTS); const colors = Object.values(COLORS); diff --git a/app/client/packages/utils/.eslintignore b/app/client/packages/utils/.eslintignore deleted file mode 100644 index 60c723a5cb3..00000000000 --- a/app/client/packages/utils/.eslintignore +++ /dev/null @@ -1,2 +0,0 @@ -**/*.d.ts -./src/**/*.d.ts \ No newline at end of file diff --git a/app/client/packages/utils/.prettierignore b/app/client/packages/utils/.prettierignore deleted file mode 100644 index b7e99510bea..00000000000 --- a/app/client/packages/utils/.prettierignore +++ /dev/null @@ -1 +0,0 @@ -jest.config.js \ No newline at end of file diff --git a/app/client/packages/utils/package.json b/app/client/packages/utils/package.json index 9f0057c0d2a..60e362695f0 100644 --- a/app/client/packages/utils/package.json +++ b/app/client/packages/utils/package.json @@ -10,11 +10,5 @@ "test:unit": "yarn g:jest" }, "author": "Aman Agarwal , Pawan Kumar ", - "license": "ISC", - "devDependencies": { - "@types/jest": "^29.5.12", - "jest": "^29.7.0", - "ts-jest": "^29.2.4", - "typescript": "^5.5.4" - } + "license": "ISC" } diff --git a/app/client/packages/utils/src/index.d.ts b/app/client/packages/utils/src/index.d.ts deleted file mode 100644 index 2fe226f0295..00000000000 --- a/app/client/packages/utils/src/index.d.ts +++ /dev/null @@ -1 +0,0 @@ -declare module "@appsmith/utils"; diff --git a/app/client/packages/utils/src/index.ts b/app/client/packages/utils/src/index.ts index 58b59cdff32..7ea2e7134f2 100644 --- a/app/client/packages/utils/src/index.ts +++ b/app/client/packages/utils/src/index.ts @@ -1 +1 @@ -export * as object from "./object"; +export * from "./object"; diff --git a/app/client/packages/utils/tsconfig.json b/app/client/packages/utils/tsconfig.json index eac4922150e..752e48c03ef 100644 --- a/app/client/packages/utils/tsconfig.json +++ b/app/client/packages/utils/tsconfig.json @@ -1,21 +1,4 @@ { - "compilerOptions": { - "outDir": "./dist", - "rootDir": "./src", - "target": "es6", - "baseUrl": "./", - "allowJs": true, - "skipLibCheck": true, - "strict": true, - "esModuleInterop": true, - "module": "ESNext", - "isolatedModules": true, - "paths": { - "@appsmith/utils/*": ["src/*"], - "@*": ["src/*"] - }, - "typeRoots": ["./src"] - }, - "include": ["src/**/*", "**/*.ts"], - "exclude": ["node_modules", "dist"] + "extends": "../../tsconfig.json", + "include": ["./src/**/*"] } diff --git a/app/client/yarn.lock b/app/client/yarn.lock index 98b553606ab..5d661e668ac 100644 --- a/app/client/yarn.lock +++ b/app/client/yarn.lock @@ -231,11 +231,6 @@ __metadata: "@appsmith/utils@workspace:^, @appsmith/utils@workspace:packages/utils": version: 0.0.0-use.local resolution: "@appsmith/utils@workspace:packages/utils" - dependencies: - "@types/jest": ^29.5.12 - jest: ^29.7.0 - ts-jest: ^29.2.4 - typescript: ^5.5.4 languageName: unknown linkType: soft @@ -10928,7 +10923,7 @@ __metadata: languageName: node linkType: hard -"@types/jest@npm:*, @types/jest@npm:^29.2.3, @types/jest@npm:^29.5.12": +"@types/jest@npm:*, @types/jest@npm:^29.2.3": version: 29.5.12 resolution: "@types/jest@npm:29.5.12" dependencies: @@ -23785,7 +23780,7 @@ __metadata: languageName: node linkType: hard -"jest@npm:^29.3.1, jest@npm:^29.5.0, jest@npm:^29.6.4, jest@npm:^29.7.0": +"jest@npm:^29.3.1, jest@npm:^29.5.0, jest@npm:^29.6.4": version: 29.7.0 resolution: "jest@npm:29.7.0" dependencies: @@ -34107,7 +34102,7 @@ __metadata: languageName: node linkType: hard -"ts-jest@npm:^29.1.0, ts-jest@npm:^29.2.4": +"ts-jest@npm:^29.1.0": version: 29.2.4 resolution: "ts-jest@npm:29.2.4" dependencies: From 2ccacd89f4312028d7ae794618b45a65be9bf272 Mon Sep 17 00:00:00 2001 From: Aman Agarwal Date: Wed, 14 Aug 2024 14:30:43 +0530 Subject: [PATCH 06/21] fix: added the eslint custom package to warn the use of Object.keys over objectKeys --- app/client/.eslintrc.base.json | 6 ++-- app/client/package.json | 1 + .../Button/stories/Button.stories.tsx | 2 +- .../IconButton/stories/IconButton.stories.tsx | 2 +- .../stories/InlineButtons.stories.tsx | 2 +- .../stories/ToolbarButtons.stories.tsx | 2 +- app/client/packages/eslint-plugin/index.js | 8 +++++ .../object-keys-replacement/rule.js | 34 +++++++++++++++++++ .../packages/eslint-plugin/package.json | 6 ++++ .../WDSButtonWidget/config/defaultsConfig.ts | 2 +- .../config/propertyPaneConfig/styleConfig.ts | 2 +- .../config/defaultsConfig.ts | 2 +- .../config/propertyPaneConfig/styleConfig.ts | 2 +- .../propertyPaneConfig/contentConfig.ts | 2 +- .../config/defaultsConfig.ts | 2 +- .../config/propertyPaneConfig/styleConfig.ts | 2 +- .../propertyPaneConfig/PanelConfig/General.ts | 2 +- .../config/propertyPaneConfig/styleConfig.ts | 2 +- app/client/yarn.lock | 7 ++++ 19 files changed, 73 insertions(+), 15 deletions(-) create mode 100644 app/client/packages/eslint-plugin/index.js create mode 100644 app/client/packages/eslint-plugin/object-keys-replacement/rule.js create mode 100644 app/client/packages/eslint-plugin/package.json diff --git a/app/client/.eslintrc.base.json b/app/client/.eslintrc.base.json index 485c107c646..e5a152f7fc3 100644 --- a/app/client/.eslintrc.base.json +++ b/app/client/.eslintrc.base.json @@ -16,7 +16,8 @@ "sort-destructure-keys", "cypress", "testing-library", - "jest" + "jest", + "@appsmith-plugins" ], "extends": [ "plugin:react/recommended", // Uses the recommended rules from @eslint-plugin-react @@ -84,7 +85,8 @@ } ] } - ] + ], + "@appsmith-plugins/object-keys": "warn" }, "settings": { "import/resolver": { diff --git a/app/client/package.json b/app/client/package.json index 8d491e116b7..329113ce90e 100644 --- a/app/client/package.json +++ b/app/client/package.json @@ -253,6 +253,7 @@ "not op_mini all" ], "devDependencies": { + "@appsmith-plugins/eslint-plugin": "workspace:^", "@babel/helper-create-regexp-features-plugin": "^7.18.6", "@babel/helper-string-parser": "^7.19.4", "@craco/craco": "^7.0.0", diff --git a/app/client/packages/design-system/widgets/src/components/Button/stories/Button.stories.tsx b/app/client/packages/design-system/widgets/src/components/Button/stories/Button.stories.tsx index 02636c17991..a6b05b4833c 100644 --- a/app/client/packages/design-system/widgets/src/components/Button/stories/Button.stories.tsx +++ b/app/client/packages/design-system/widgets/src/components/Button/stories/Button.stories.tsx @@ -7,7 +7,7 @@ import { COLORS, SIZES, } from "@design-system/widgets"; -import { objectKeys } from "@appsmith/utils/src/object"; +import { objectKeys } from "@appsmith/utils"; /** * A button is a clickable element that is used to trigger an action. diff --git a/app/client/packages/design-system/widgets/src/components/IconButton/stories/IconButton.stories.tsx b/app/client/packages/design-system/widgets/src/components/IconButton/stories/IconButton.stories.tsx index fc078aa4121..f73f45aade8 100644 --- a/app/client/packages/design-system/widgets/src/components/IconButton/stories/IconButton.stories.tsx +++ b/app/client/packages/design-system/widgets/src/components/IconButton/stories/IconButton.stories.tsx @@ -7,7 +7,7 @@ import { BUTTON_VARIANTS, COLORS, } from "@design-system/widgets"; -import { objectKeys } from "@appsmith/utils/src/object"; +import { objectKeys } from "@appsmith/utils"; /** * Icon Button is a button component that only contains an icon. diff --git a/app/client/packages/design-system/widgets/src/components/InlineButtons/stories/InlineButtons.stories.tsx b/app/client/packages/design-system/widgets/src/components/InlineButtons/stories/InlineButtons.stories.tsx index e8808613f38..295d92a31fc 100644 --- a/app/client/packages/design-system/widgets/src/components/InlineButtons/stories/InlineButtons.stories.tsx +++ b/app/client/packages/design-system/widgets/src/components/InlineButtons/stories/InlineButtons.stories.tsx @@ -7,7 +7,7 @@ import { SIZES, } from "@design-system/widgets"; import type { Meta, StoryObj } from "@storybook/react"; -import { objectKeys } from "@appsmith/utils/src/object"; +import { objectKeys } from "@appsmith/utils"; import { itemList, longItemList, diff --git a/app/client/packages/design-system/widgets/src/components/ToolbarButtons/stories/ToolbarButtons.stories.tsx b/app/client/packages/design-system/widgets/src/components/ToolbarButtons/stories/ToolbarButtons.stories.tsx index e9727d112ac..439d32b907a 100644 --- a/app/client/packages/design-system/widgets/src/components/ToolbarButtons/stories/ToolbarButtons.stories.tsx +++ b/app/client/packages/design-system/widgets/src/components/ToolbarButtons/stories/ToolbarButtons.stories.tsx @@ -7,7 +7,7 @@ import { ToolbarButtons, SIZES, } from "@design-system/widgets"; -import { objectKeys } from "@appsmith/utils/src/object"; +import { objectKeys } from "@appsmith/utils"; import { itemList, itemListWithIcons, diff --git a/app/client/packages/eslint-plugin/index.js b/app/client/packages/eslint-plugin/index.js new file mode 100644 index 00000000000..27c3372bc4c --- /dev/null +++ b/app/client/packages/eslint-plugin/index.js @@ -0,0 +1,8 @@ +/* eslint-disable-next-line @typescript-eslint/no-var-requires */ +const { rule } = require("./object-keys-replacement/rule"); + +module.exports = { + rules: { + "object-keys": rule, + }, +}; diff --git a/app/client/packages/eslint-plugin/object-keys-replacement/rule.js b/app/client/packages/eslint-plugin/object-keys-replacement/rule.js new file mode 100644 index 00000000000..b6f76819a39 --- /dev/null +++ b/app/client/packages/eslint-plugin/object-keys-replacement/rule.js @@ -0,0 +1,34 @@ +module.exports = { + rule: { + meta: { + type: "suggestion", + docs: { + description: "Warns when Object.keys is used instead of objectKeys", + recommended: true, + }, + schema: [], // No options + messages: { + useObjectKeys: "Use objectKeys instead of Object.keys.", + }, + }, + create(context) { + return { + CallExpression(node) { + // Check if the callee is Object.keys + if ( + node.callee.type === "MemberExpression" && + node.callee.object.type === "Identifier" && + node.callee.object.name === "Object" && + node.callee.property.type === "Identifier" && + node.callee.property.name === "keys" + ) { + context.report({ + node, + messageId: "useObjectKeys", + }); + } + }, + }; + }, + }, +}; diff --git a/app/client/packages/eslint-plugin/package.json b/app/client/packages/eslint-plugin/package.json new file mode 100644 index 00000000000..54125d03cee --- /dev/null +++ b/app/client/packages/eslint-plugin/package.json @@ -0,0 +1,6 @@ +{ + "name": "@appsmith-plugins/eslint-plugin", + "version": "1.0.0", + "private": true, + "main": "index.js" +} diff --git a/app/client/src/widgets/wds/WDSButtonWidget/config/defaultsConfig.ts b/app/client/src/widgets/wds/WDSButtonWidget/config/defaultsConfig.ts index ee8c66131c9..1d22e0cee09 100644 --- a/app/client/src/widgets/wds/WDSButtonWidget/config/defaultsConfig.ts +++ b/app/client/src/widgets/wds/WDSButtonWidget/config/defaultsConfig.ts @@ -1,7 +1,7 @@ import { RecaptchaTypes } from "components/constants"; import { COLORS, BUTTON_VARIANTS } from "@design-system/widgets"; import { ResponsiveBehavior } from "layoutSystems/common/utils/constants"; -import { objectKeys } from "@appsmith/utils/src/object"; +import { objectKeys } from "@appsmith/utils"; import { BUTTON_WIDGET_DEFAULT_LABEL, createMessage, diff --git a/app/client/src/widgets/wds/WDSButtonWidget/config/propertyPaneConfig/styleConfig.ts b/app/client/src/widgets/wds/WDSButtonWidget/config/propertyPaneConfig/styleConfig.ts index c2c7f810f8e..309ed24cfab 100644 --- a/app/client/src/widgets/wds/WDSButtonWidget/config/propertyPaneConfig/styleConfig.ts +++ b/app/client/src/widgets/wds/WDSButtonWidget/config/propertyPaneConfig/styleConfig.ts @@ -1,7 +1,7 @@ import { capitalize } from "lodash"; import { ValidationTypes } from "constants/WidgetValidation"; import { COLORS, BUTTON_VARIANTS } from "@design-system/widgets"; -import { objectKeys } from "@appsmith/utils/src/object"; +import { objectKeys } from "@appsmith/utils"; export const propertyPaneStyleConfig = [ { diff --git a/app/client/src/widgets/wds/WDSIconButtonWidget/config/defaultsConfig.ts b/app/client/src/widgets/wds/WDSIconButtonWidget/config/defaultsConfig.ts index 52bd88f0467..3859696f77c 100644 --- a/app/client/src/widgets/wds/WDSIconButtonWidget/config/defaultsConfig.ts +++ b/app/client/src/widgets/wds/WDSIconButtonWidget/config/defaultsConfig.ts @@ -1,5 +1,5 @@ import { BUTTON_VARIANTS, COLORS } from "@design-system/widgets"; -import { objectKeys } from "@appsmith/utils/src/object"; +import { objectKeys } from "@appsmith/utils"; import { ResponsiveBehavior } from "layoutSystems/common/utils/constants"; export const defaultsConfig = { diff --git a/app/client/src/widgets/wds/WDSIconButtonWidget/config/propertyPaneConfig/styleConfig.ts b/app/client/src/widgets/wds/WDSIconButtonWidget/config/propertyPaneConfig/styleConfig.ts index e4bc74b9de4..5f222107cc6 100644 --- a/app/client/src/widgets/wds/WDSIconButtonWidget/config/propertyPaneConfig/styleConfig.ts +++ b/app/client/src/widgets/wds/WDSIconButtonWidget/config/propertyPaneConfig/styleConfig.ts @@ -1,6 +1,6 @@ import { capitalize } from "lodash"; import { BUTTON_VARIANTS, COLORS } from "@design-system/widgets"; -import { objectKeys } from "@appsmith/utils/src/object"; +import { objectKeys } from "@appsmith/utils"; import { ValidationTypes } from "constants/WidgetValidation"; export const propertyPaneStyleConfig = [ diff --git a/app/client/src/widgets/wds/WDSInlineButtonsWidget/config/propertyPaneConfig/contentConfig.ts b/app/client/src/widgets/wds/WDSInlineButtonsWidget/config/propertyPaneConfig/contentConfig.ts index 2a518e4fc59..ac58ba52d95 100644 --- a/app/client/src/widgets/wds/WDSInlineButtonsWidget/config/propertyPaneConfig/contentConfig.ts +++ b/app/client/src/widgets/wds/WDSInlineButtonsWidget/config/propertyPaneConfig/contentConfig.ts @@ -5,7 +5,7 @@ import { } from "ee/constants/messages"; import { ValidationTypes } from "constants/WidgetValidation"; import { capitalize } from "lodash"; -import { objectKeys } from "@appsmith/utils/src/object"; +import { objectKeys } from "@appsmith/utils"; export const propertyPaneContentConfig = [ { diff --git a/app/client/src/widgets/wds/WDSMenuButtonWidget/config/defaultsConfig.ts b/app/client/src/widgets/wds/WDSMenuButtonWidget/config/defaultsConfig.ts index 577f4f1037b..244cbfc4e59 100644 --- a/app/client/src/widgets/wds/WDSMenuButtonWidget/config/defaultsConfig.ts +++ b/app/client/src/widgets/wds/WDSMenuButtonWidget/config/defaultsConfig.ts @@ -1,6 +1,6 @@ import { BUTTON_VARIANTS, COLORS } from "@design-system/widgets"; import type { WidgetDefaultProps } from "WidgetProvider/constants"; -import { objectKeys } from "@appsmith/utils/src/object"; +import { objectKeys } from "@appsmith/utils"; export const defaultsConfig = { label: "Open The Menu…", diff --git a/app/client/src/widgets/wds/WDSMenuButtonWidget/config/propertyPaneConfig/styleConfig.ts b/app/client/src/widgets/wds/WDSMenuButtonWidget/config/propertyPaneConfig/styleConfig.ts index c93c59e8b2e..d92407fd2dc 100644 --- a/app/client/src/widgets/wds/WDSMenuButtonWidget/config/propertyPaneConfig/styleConfig.ts +++ b/app/client/src/widgets/wds/WDSMenuButtonWidget/config/propertyPaneConfig/styleConfig.ts @@ -1,7 +1,7 @@ import { capitalize } from "lodash"; import { ValidationTypes } from "constants/WidgetValidation"; import { BUTTON_VARIANTS, COLORS, ICONS } from "@design-system/widgets"; -import { objectKeys } from "@appsmith/utils/src/object"; +import { objectKeys } from "@appsmith/utils"; import type { MenuButtonWidgetProps } from "../../widget/types"; diff --git a/app/client/src/widgets/wds/WDSTableWidget/config/propertyPaneConfig/PanelConfig/General.ts b/app/client/src/widgets/wds/WDSTableWidget/config/propertyPaneConfig/PanelConfig/General.ts index fa904888054..f15d65d7221 100644 --- a/app/client/src/widgets/wds/WDSTableWidget/config/propertyPaneConfig/PanelConfig/General.ts +++ b/app/client/src/widgets/wds/WDSTableWidget/config/propertyPaneConfig/PanelConfig/General.ts @@ -3,7 +3,7 @@ import type { TableWidgetProps } from "widgets/wds/WDSTableWidget/constants"; import { ColumnTypes } from "widgets/wds/WDSTableWidget/constants"; import { hideByColumnType } from "../../../widget/propertyUtils"; import { BUTTON_VARIANTS } from "@design-system/widgets"; -import { objectKeys } from "@appsmith/utils/src/object"; +import { objectKeys } from "@appsmith/utils"; export default { sectionName: "General", diff --git a/app/client/src/widgets/wds/WDSToolbarButtonsWidget/config/propertyPaneConfig/styleConfig.ts b/app/client/src/widgets/wds/WDSToolbarButtonsWidget/config/propertyPaneConfig/styleConfig.ts index 47491c3cf73..45053da515d 100644 --- a/app/client/src/widgets/wds/WDSToolbarButtonsWidget/config/propertyPaneConfig/styleConfig.ts +++ b/app/client/src/widgets/wds/WDSToolbarButtonsWidget/config/propertyPaneConfig/styleConfig.ts @@ -1,7 +1,7 @@ import { BUTTON_VARIANTS, COLORS } from "@design-system/widgets"; import { ValidationTypes } from "constants/WidgetValidation"; import { capitalize } from "lodash"; -import { objectKeys } from "@appsmith/utils/src/object"; +import { objectKeys } from "@appsmith/utils"; export const propertyPaneStyleConfig = [ { diff --git a/app/client/yarn.lock b/app/client/yarn.lock index 5d661e668ac..0863dca2dbb 100644 --- a/app/client/yarn.lock +++ b/app/client/yarn.lock @@ -174,6 +174,12 @@ __metadata: languageName: node linkType: hard +"@appsmith-plugins/eslint-plugin@workspace:^, @appsmith-plugins/eslint-plugin@workspace:packages/eslint-plugin": + version: 0.0.0-use.local + resolution: "@appsmith-plugins/eslint-plugin@workspace:packages/eslint-plugin" + languageName: unknown + linkType: soft + "@appsmith/ads-old@workspace:^, @appsmith/ads-old@workspace:packages/design-system/ads-old": version: 0.0.0-use.local resolution: "@appsmith/ads-old@workspace:packages/design-system/ads-old" @@ -13161,6 +13167,7 @@ __metadata: version: 0.0.0-use.local resolution: "appsmith@workspace:." dependencies: + "@appsmith-plugins/eslint-plugin": "workspace:^" "@appsmith/ads": "workspace:^" "@appsmith/ads-old": "workspace:^" "@appsmith/utils": "workspace:^" From b3f5a415d1bcab33f3543276c2cd6d645f449bc6 Mon Sep 17 00:00:00 2001 From: Aman Agarwal Date: Wed, 14 Aug 2024 14:51:46 +0530 Subject: [PATCH 07/21] fix: updated the message --- .../packages/eslint-plugin/object-keys-replacement/rule.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/client/packages/eslint-plugin/object-keys-replacement/rule.js b/app/client/packages/eslint-plugin/object-keys-replacement/rule.js index b6f76819a39..c9fb92a09ea 100644 --- a/app/client/packages/eslint-plugin/object-keys-replacement/rule.js +++ b/app/client/packages/eslint-plugin/object-keys-replacement/rule.js @@ -8,7 +8,8 @@ module.exports = { }, schema: [], // No options messages: { - useObjectKeys: "Use objectKeys instead of Object.keys.", + useObjectKeys: + "Use objectKeys from '@appsmith/utils' package instead of Object.keys", }, }, create(context) { From d0644b36458a468e1c7ef459f626b89a28e772f3 Mon Sep 17 00:00:00 2001 From: Aman Agarwal Date: Wed, 14 Aug 2024 14:52:52 +0530 Subject: [PATCH 08/21] fix: updated the require --- app/client/packages/eslint-plugin/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/client/packages/eslint-plugin/index.js b/app/client/packages/eslint-plugin/index.js index 27c3372bc4c..5ba5fdcefb2 100644 --- a/app/client/packages/eslint-plugin/index.js +++ b/app/client/packages/eslint-plugin/index.js @@ -1,8 +1,8 @@ /* eslint-disable-next-line @typescript-eslint/no-var-requires */ -const { rule } = require("./object-keys-replacement/rule"); +const { rule: objectKeysRule } = require("./object-keys-replacement/rule"); module.exports = { rules: { - "object-keys": rule, + "object-keys": objectKeysRule, }, }; From 225b6f2cbd913e8f97cc8dce25fcb5b2aa29a0f2 Mon Sep 17 00:00:00 2001 From: Aman Agarwal Date: Wed, 14 Aug 2024 17:31:38 +0530 Subject: [PATCH 09/21] chore: added test case for rule, readme for adding new rule --- app/client/packages/eslint-plugin/Readme.md | 106 ++++++++++++++++++ app/client/packages/eslint-plugin/index.js | 2 +- .../rule.js | 0 .../eslint-plugin/object-keys/rule.test.js | 20 ++++ .../packages/eslint-plugin/package.json | 7 +- 5 files changed, 132 insertions(+), 3 deletions(-) create mode 100644 app/client/packages/eslint-plugin/Readme.md rename app/client/packages/eslint-plugin/{object-keys-replacement => object-keys}/rule.js (100%) create mode 100644 app/client/packages/eslint-plugin/object-keys/rule.test.js diff --git a/app/client/packages/eslint-plugin/Readme.md b/app/client/packages/eslint-plugin/Readme.md new file mode 100644 index 00000000000..66b0ac67738 --- /dev/null +++ b/app/client/packages/eslint-plugin/Readme.md @@ -0,0 +1,106 @@ +# Adding a Custom Rule to Your Appsmith ESLint Plugin + +Welcome to the guide for adding a custom rule to your Appsmith ESLint plugin. Follow these steps to create and integrate a new rule into your Appsmith ESLint plugin. + +You can create one by following the [official ESLint custom rule](https://eslint.org/docs/latest/extend/custom-rule-tutorial). + +## Step 1: Create the Custom Rule File + +1. Navigate to your Appsmith ESLint plugin directory i.e. `app/client/packages/eslint-plugin`. +2. Create a new directory for your custom rule in the root of `app/client/packages/eslint-plugin` directory. For example, `custom-rule/rule.js`. + + ```bash + mkdir custom-rule + touch custom-rule/rule.js + ``` + +3. Open `custom-rule/rule.js` and define your rule. Here's a basic template to get you started: + + ```js + module.exports = { + meta: { + type: "problem", // or "suggestion" or "layout" + docs: { + description: "A description of what the rule does", + category: "Best Practices", + recommended: false + }, + fixable: null, // or "code" if the rule can fix issues automatically + schema: [] // JSON Schema for rule options + }, + create(context) { + return { + // Define the rule's behavior here + // e.g., "Identifier": (node) => { /* logic */ } + }; + } + }; + ``` + +## Step 2: Update the Plugin Index File + +1. Open the `index.js` file inside `eslint-plugin` directory. + +2. Import your custom rule and add it to the rules object in `index.js`. For example: + + ```js + const customRule = require('./custom-rule/rule.js'); + + module.exports = { + rules: { + 'custom-rule': customRule + } + }; + ``` + +## Step 3: Add Tests for Your Custom Rule + +1. Create a test file for your rule in the `custom-rule` directory. For example, `custom-rule/rule.test.js`. + + ```bash + touch custom-rule/rule.test.js + ``` + +2. Open `custom-rule/rule.test.js` and write tests using a testing framework like Mocha or Jest. Here's a basic example using ESLint's `RuleTester`: + + ```js + const rule = require('./rule'); + const RuleTester = require('eslint').RuleTester; + + const ruleTester = new RuleTester(); + + ruleTester.run('custom-rule', rule, { + valid: [ + // Examples of valid code + ], + invalid: [ + { + code: 'const foo = 1;', + errors: [{ message: 'Your custom error message' }] + } + ] + }); + ``` + +3. Run your tests to ensure your rule works as expected: + + ```bash + yarn run test:unit + ``` + +## Step 4: Steps to add it to client + +1. Go to `app/client/.eslintrc.base.json` +2. Add your `custom-rule` entry to the rules object. e.g. + + ```javascript + "custom-rule": "warn" + ``` + +## Additional Resources + +- [ESLint Plugin Developer Guide](https://eslint.org/docs/developer-guide/working-with-plugins) +- [ESLint Rules API](https://eslint.org/docs/developer-guide/working-with-rules) +- [ESLint Testing Guidelines](https://eslint.org/docs/developer-guide/unit-testing) + +Happy linting! \ No newline at end of file diff --git a/app/client/packages/eslint-plugin/index.js b/app/client/packages/eslint-plugin/index.js index 5ba5fdcefb2..b4c56df9223 100644 --- a/app/client/packages/eslint-plugin/index.js +++ b/app/client/packages/eslint-plugin/index.js @@ -1,5 +1,5 @@ /* eslint-disable-next-line @typescript-eslint/no-var-requires */ -const { rule: objectKeysRule } = require("./object-keys-replacement/rule"); +const { rule: objectKeysRule } = require("./object-keys/rule"); module.exports = { rules: { diff --git a/app/client/packages/eslint-plugin/object-keys-replacement/rule.js b/app/client/packages/eslint-plugin/object-keys/rule.js similarity index 100% rename from app/client/packages/eslint-plugin/object-keys-replacement/rule.js rename to app/client/packages/eslint-plugin/object-keys/rule.js diff --git a/app/client/packages/eslint-plugin/object-keys/rule.test.js b/app/client/packages/eslint-plugin/object-keys/rule.test.js new file mode 100644 index 00000000000..936254e028a --- /dev/null +++ b/app/client/packages/eslint-plugin/object-keys/rule.test.js @@ -0,0 +1,20 @@ +/* eslint-disable @typescript-eslint/no-var-requires */ +const { RuleTester } = require("eslint"); +const objectKeysRule = require("./rule"); +/* eslint-enable @typescript-eslint/no-var-requires */ + +const ruleTester = new RuleTester({}); + +ruleTester.run("object-keys", objectKeysRule.rule, { + valid: [ + { + code: "objectKeys({ 'a': 'b' })", + }, + ], + invalid: [ + { + code: "Object.keys({ 'a': 'b' })", + errors: [{ messageId: "useObjectKeys" }], + }, + ], +}); diff --git a/app/client/packages/eslint-plugin/package.json b/app/client/packages/eslint-plugin/package.json index 54125d03cee..81e92f83e57 100644 --- a/app/client/packages/eslint-plugin/package.json +++ b/app/client/packages/eslint-plugin/package.json @@ -2,5 +2,8 @@ "name": "@appsmith-plugins/eslint-plugin", "version": "1.0.0", "private": true, - "main": "index.js" -} + "main": "index.js", + "scripts": { + "test:unit": "yarn g:jest" + } +} \ No newline at end of file From 8f982d99d6066ff5ce42168f946262ddf529211d Mon Sep 17 00:00:00 2001 From: Aman Agarwal Date: Wed, 14 Aug 2024 19:09:37 +0530 Subject: [PATCH 10/21] fix: prettier in jest config --- app/client/packages/utils/jest.config.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/client/packages/utils/jest.config.js b/app/client/packages/utils/jest.config.js index 41e98d5d6d3..9b706028882 100644 --- a/app/client/packages/utils/jest.config.js +++ b/app/client/packages/utils/jest.config.js @@ -1,8 +1,11 @@ module.exports = { roots: ["/src"], transform: { - "^.+\\.(ts)$": ["ts-jest", { - isolatedModules: true, - }], + "^.+\\.(ts)$": [ + "ts-jest", + { + isolatedModules: true, + }, + ], }, }; From abe98cb7869be94b9fafa620a7372b368cada201 Mon Sep 17 00:00:00 2001 From: Aman Agarwal Date: Fri, 16 Aug 2024 15:25:33 +0530 Subject: [PATCH 11/21] fix: moved eslint to typescript --- app/client/.eslintrc.base.json | 8 ++-- app/client/cypress.config.ts | 4 +- app/client/package.json | 2 +- .../packages/eslint-plugin/.eslintrc.json | 3 ++ app/client/packages/eslint-plugin/index.js | 8 ---- app/client/packages/eslint-plugin/index.ts | 14 +++++++ .../packages/eslint-plugin/jest.config.js | 11 ++++++ .../eslint-plugin/object-keys/rule.js | 35 ----------------- .../eslint-plugin/object-keys/rule.test.js | 20 ---------- .../eslint-plugin/object-keys/rule.test.ts | 18 +++++++++ .../eslint-plugin/object-keys/rule.ts | 36 ++++++++++++++++++ .../packages/eslint-plugin/package.json | 6 +-- .../packages/eslint-plugin/src/index.ts | 14 +++++++ .../src/object-keys/rule.test.ts | 18 +++++++++ .../eslint-plugin/src/object-keys/rule.ts | 36 ++++++++++++++++++ .../packages/eslint-plugin/tsconfig.json | 4 ++ app/client/yarn.lock | 38 +++++++------------ 17 files changed, 178 insertions(+), 97 deletions(-) create mode 100644 app/client/packages/eslint-plugin/.eslintrc.json delete mode 100644 app/client/packages/eslint-plugin/index.js create mode 100644 app/client/packages/eslint-plugin/index.ts create mode 100644 app/client/packages/eslint-plugin/jest.config.js delete mode 100644 app/client/packages/eslint-plugin/object-keys/rule.js delete mode 100644 app/client/packages/eslint-plugin/object-keys/rule.test.js create mode 100644 app/client/packages/eslint-plugin/object-keys/rule.test.ts create mode 100644 app/client/packages/eslint-plugin/object-keys/rule.ts create mode 100644 app/client/packages/eslint-plugin/src/index.ts create mode 100644 app/client/packages/eslint-plugin/src/object-keys/rule.test.ts create mode 100644 app/client/packages/eslint-plugin/src/object-keys/rule.ts create mode 100644 app/client/packages/eslint-plugin/tsconfig.json diff --git a/app/client/.eslintrc.base.json b/app/client/.eslintrc.base.json index e5a152f7fc3..71233413582 100644 --- a/app/client/.eslintrc.base.json +++ b/app/client/.eslintrc.base.json @@ -17,7 +17,7 @@ "cypress", "testing-library", "jest", - "@appsmith-plugins" + "@appsmith" ], "extends": [ "plugin:react/recommended", // Uses the recommended rules from @eslint-plugin-react @@ -27,7 +27,8 @@ "plugin:react-hooks/recommended", // Note: Please keep this as the last config to make sure that this (and by extension our .prettierrc file) overrides all configuration above it // https://www.npmjs.com/package/eslint-plugin-prettier#recommended-configuration - "plugin:prettier/recommended" + "plugin:prettier/recommended", + "plugin:@appsmith/recommended" ], "parserOptions": { "ecmaVersion": 2020, // Allows for the parsing of modern ECMAScript features @@ -85,8 +86,7 @@ } ] } - ], - "@appsmith-plugins/object-keys": "warn" + ] }, "settings": { "import/resolver": { diff --git a/app/client/cypress.config.ts b/app/client/cypress.config.ts index 3d988077426..eb1ad2e61e0 100644 --- a/app/client/cypress.config.ts +++ b/app/client/cypress.config.ts @@ -26,8 +26,8 @@ export default defineConfig({ e2e: { baseUrl: "https://dev.appsmith.com/", env: { - USERNAME: "xxxx", - PASSWORD: "xxx", + USERNAME: "aman@appsmith.com", + PASSWORD: "aman@appsmith.com", grepFilterSpecs: true, grepOmitFiltered: true, }, diff --git a/app/client/package.json b/app/client/package.json index 32466ed18fb..8629c648478 100644 --- a/app/client/package.json +++ b/app/client/package.json @@ -252,7 +252,7 @@ "not op_mini all" ], "devDependencies": { - "@appsmith-plugins/eslint-plugin": "workspace:^", + "@appsmith/eslint-plugin": "workspace:^", "@babel/helper-create-regexp-features-plugin": "^7.18.6", "@babel/helper-string-parser": "^7.19.4", "@craco/craco": "^7.0.0", diff --git a/app/client/packages/eslint-plugin/.eslintrc.json b/app/client/packages/eslint-plugin/.eslintrc.json new file mode 100644 index 00000000000..b6652ce70c7 --- /dev/null +++ b/app/client/packages/eslint-plugin/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": ["../../.eslintrc.base.json"] +} diff --git a/app/client/packages/eslint-plugin/index.js b/app/client/packages/eslint-plugin/index.js deleted file mode 100644 index b4c56df9223..00000000000 --- a/app/client/packages/eslint-plugin/index.js +++ /dev/null @@ -1,8 +0,0 @@ -/* eslint-disable-next-line @typescript-eslint/no-var-requires */ -const { rule: objectKeysRule } = require("./object-keys/rule"); - -module.exports = { - rules: { - "object-keys": objectKeysRule, - }, -}; diff --git a/app/client/packages/eslint-plugin/index.ts b/app/client/packages/eslint-plugin/index.ts new file mode 100644 index 00000000000..12d65cf89c1 --- /dev/null +++ b/app/client/packages/eslint-plugin/index.ts @@ -0,0 +1,14 @@ +import { rule as objectKeysRule } from "./object-keys/rule"; + +export default { + rules: { + "object-keys": objectKeysRule, + }, + configs: { + recommended: { + rules: { + "@appsmith/object-keys": "warn", + }, + }, + }, +}; diff --git a/app/client/packages/eslint-plugin/jest.config.js b/app/client/packages/eslint-plugin/jest.config.js new file mode 100644 index 00000000000..abd33e3bca5 --- /dev/null +++ b/app/client/packages/eslint-plugin/jest.config.js @@ -0,0 +1,11 @@ +module.exports = { + roots: [""], + transform: { + "^.+\\.(ts)$": [ + "ts-jest", + { + isolatedModules: true, + }, + ], + }, +}; diff --git a/app/client/packages/eslint-plugin/object-keys/rule.js b/app/client/packages/eslint-plugin/object-keys/rule.js deleted file mode 100644 index c9fb92a09ea..00000000000 --- a/app/client/packages/eslint-plugin/object-keys/rule.js +++ /dev/null @@ -1,35 +0,0 @@ -module.exports = { - rule: { - meta: { - type: "suggestion", - docs: { - description: "Warns when Object.keys is used instead of objectKeys", - recommended: true, - }, - schema: [], // No options - messages: { - useObjectKeys: - "Use objectKeys from '@appsmith/utils' package instead of Object.keys", - }, - }, - create(context) { - return { - CallExpression(node) { - // Check if the callee is Object.keys - if ( - node.callee.type === "MemberExpression" && - node.callee.object.type === "Identifier" && - node.callee.object.name === "Object" && - node.callee.property.type === "Identifier" && - node.callee.property.name === "keys" - ) { - context.report({ - node, - messageId: "useObjectKeys", - }); - } - }, - }; - }, - }, -}; diff --git a/app/client/packages/eslint-plugin/object-keys/rule.test.js b/app/client/packages/eslint-plugin/object-keys/rule.test.js deleted file mode 100644 index 936254e028a..00000000000 --- a/app/client/packages/eslint-plugin/object-keys/rule.test.js +++ /dev/null @@ -1,20 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { RuleTester } = require("eslint"); -const objectKeysRule = require("./rule"); -/* eslint-enable @typescript-eslint/no-var-requires */ - -const ruleTester = new RuleTester({}); - -ruleTester.run("object-keys", objectKeysRule.rule, { - valid: [ - { - code: "objectKeys({ 'a': 'b' })", - }, - ], - invalid: [ - { - code: "Object.keys({ 'a': 'b' })", - errors: [{ messageId: "useObjectKeys" }], - }, - ], -}); diff --git a/app/client/packages/eslint-plugin/object-keys/rule.test.ts b/app/client/packages/eslint-plugin/object-keys/rule.test.ts new file mode 100644 index 00000000000..901c0ea4b4b --- /dev/null +++ b/app/client/packages/eslint-plugin/object-keys/rule.test.ts @@ -0,0 +1,18 @@ +import { TSESLint } from "@typescript-eslint/utils"; +import { rule } from "./rule"; + +const ruleTester = new TSESLint.RuleTester(); + +ruleTester.run("object-keys", rule, { + valid: [ + { + code: "objectKeys({ 'a': 'b' })", + }, + ], + invalid: [ + { + code: "Object.keys({ 'a': 'b' })", + errors: [{ messageId: "useObjectKeys" }], + }, + ], +}); diff --git a/app/client/packages/eslint-plugin/object-keys/rule.ts b/app/client/packages/eslint-plugin/object-keys/rule.ts new file mode 100644 index 00000000000..612746a671a --- /dev/null +++ b/app/client/packages/eslint-plugin/object-keys/rule.ts @@ -0,0 +1,36 @@ +import { TSESLint } from "@typescript-eslint/utils"; + +export const rule: TSESLint.RuleModule<"useObjectKeys"> = { + defaultOptions: [], + meta: { + type: "suggestion", + docs: { + description: "Warns when Object.keys is used instead of objectKeys", + recommended: "warn", + }, + schema: [], // No options + messages: { + useObjectKeys: + "Use objectKeys from '@appsmith/utils' package instead of Object.keys", + }, + }, + create(context) { + return { + CallExpression(node) { + // Check if the callee is Object.keys + if ( + node.callee.type === "MemberExpression" && + node.callee.object.type === "Identifier" && + node.callee.object.name === "Object" && + node.callee.property.type === "Identifier" && + node.callee.property.name === "keys" + ) { + context.report({ + node, + messageId: "useObjectKeys", + }); + } + }, + }; + }, +}; diff --git a/app/client/packages/eslint-plugin/package.json b/app/client/packages/eslint-plugin/package.json index 81e92f83e57..6852c157958 100644 --- a/app/client/packages/eslint-plugin/package.json +++ b/app/client/packages/eslint-plugin/package.json @@ -1,9 +1,9 @@ { - "name": "@appsmith-plugins/eslint-plugin", + "name": "@appsmith/eslint-plugin", "version": "1.0.0", "private": true, - "main": "index.js", + "main": "src/index.ts", "scripts": { "test:unit": "yarn g:jest" } -} \ No newline at end of file +} diff --git a/app/client/packages/eslint-plugin/src/index.ts b/app/client/packages/eslint-plugin/src/index.ts new file mode 100644 index 00000000000..274bd01a404 --- /dev/null +++ b/app/client/packages/eslint-plugin/src/index.ts @@ -0,0 +1,14 @@ +import { rule as objectKeysRule } from "./object-keys/rule"; + +module.exports = { + rules: { + "object-keys": objectKeysRule, + }, + configs: { + recommended: { + rules: { + "@appsmith/object-keys": "warn", + }, + }, + }, +}; diff --git a/app/client/packages/eslint-plugin/src/object-keys/rule.test.ts b/app/client/packages/eslint-plugin/src/object-keys/rule.test.ts new file mode 100644 index 00000000000..901c0ea4b4b --- /dev/null +++ b/app/client/packages/eslint-plugin/src/object-keys/rule.test.ts @@ -0,0 +1,18 @@ +import { TSESLint } from "@typescript-eslint/utils"; +import { rule } from "./rule"; + +const ruleTester = new TSESLint.RuleTester(); + +ruleTester.run("object-keys", rule, { + valid: [ + { + code: "objectKeys({ 'a': 'b' })", + }, + ], + invalid: [ + { + code: "Object.keys({ 'a': 'b' })", + errors: [{ messageId: "useObjectKeys" }], + }, + ], +}); diff --git a/app/client/packages/eslint-plugin/src/object-keys/rule.ts b/app/client/packages/eslint-plugin/src/object-keys/rule.ts new file mode 100644 index 00000000000..612746a671a --- /dev/null +++ b/app/client/packages/eslint-plugin/src/object-keys/rule.ts @@ -0,0 +1,36 @@ +import { TSESLint } from "@typescript-eslint/utils"; + +export const rule: TSESLint.RuleModule<"useObjectKeys"> = { + defaultOptions: [], + meta: { + type: "suggestion", + docs: { + description: "Warns when Object.keys is used instead of objectKeys", + recommended: "warn", + }, + schema: [], // No options + messages: { + useObjectKeys: + "Use objectKeys from '@appsmith/utils' package instead of Object.keys", + }, + }, + create(context) { + return { + CallExpression(node) { + // Check if the callee is Object.keys + if ( + node.callee.type === "MemberExpression" && + node.callee.object.type === "Identifier" && + node.callee.object.name === "Object" && + node.callee.property.type === "Identifier" && + node.callee.property.name === "keys" + ) { + context.report({ + node, + messageId: "useObjectKeys", + }); + } + }, + }; + }, +}; diff --git a/app/client/packages/eslint-plugin/tsconfig.json b/app/client/packages/eslint-plugin/tsconfig.json new file mode 100644 index 00000000000..63e20a2cf0b --- /dev/null +++ b/app/client/packages/eslint-plugin/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "../../tsconfig.json", + "include": ["./**/*"] +} diff --git a/app/client/yarn.lock b/app/client/yarn.lock index 16adafac06b..562b8671a92 100644 --- a/app/client/yarn.lock +++ b/app/client/yarn.lock @@ -171,12 +171,6 @@ __metadata: languageName: node linkType: hard -"@appsmith-plugins/eslint-plugin@workspace:^, @appsmith-plugins/eslint-plugin@workspace:packages/eslint-plugin": - version: 0.0.0-use.local - resolution: "@appsmith-plugins/eslint-plugin@workspace:packages/eslint-plugin" - languageName: unknown - linkType: soft - "@appsmith/ads-old@workspace:^, @appsmith/ads-old@workspace:packages/design-system/ads-old": version: 0.0.0-use.local resolution: "@appsmith/ads-old@workspace:packages/design-system/ads-old" @@ -231,6 +225,12 @@ __metadata: languageName: unknown linkType: soft +"@appsmith/eslint-plugin@workspace:^, @appsmith/eslint-plugin@workspace:packages/eslint-plugin": + version: 0.0.0-use.local + resolution: "@appsmith/eslint-plugin@workspace:packages/eslint-plugin" + languageName: unknown + linkType: soft + "@appsmith/utils@workspace:^, @appsmith/utils@workspace:packages/utils": version: 0.0.0-use.local resolution: "@appsmith/utils@workspace:packages/utils" @@ -13175,11 +13175,12 @@ __metadata: version: 0.0.0-use.local resolution: "appsmith@workspace:." dependencies: - "@appsmith-plugins/eslint-plugin": "workspace:^" "@appsmith/ads": "workspace:^" "@appsmith/ads-old": "workspace:^" "@appsmith/wds": "workspace:^" "@appsmith/wds-theming": "workspace:^" + "@appsmith/eslint-plugin": "workspace:^" + "@appsmith/utils": "workspace:^" "@aws-sdk/client-s3": ^3.622.0 "@aws-sdk/lib-storage": ^3.622.0 "@babel/helper-create-regexp-features-plugin": ^7.18.6 @@ -24806,15 +24807,6 @@ __metadata: languageName: node linkType: hard -"lru-cache@npm:^6.0.0": - version: 6.0.0 - resolution: "lru-cache@npm:6.0.0" - dependencies: - yallist: ^4.0.0 - checksum: f97f499f898f23e4585742138a22f22526254fdba6d75d41a1c2526b3b6cc5747ef59c5612ba7375f42aca4f8461950e925ba08c991ead0651b4918b7c978297 - languageName: node - linkType: hard - "lru-cache@npm:^7.7.1": version: 7.17.0 resolution: "lru-cache@npm:7.17.0" @@ -32018,13 +32010,11 @@ __metadata: linkType: hard "semver@npm:7.x, semver@npm:^7.3.2, semver@npm:^7.3.4, semver@npm:^7.3.5, semver@npm:^7.3.7, semver@npm:^7.3.8, semver@npm:^7.5.2, semver@npm:^7.5.3, semver@npm:^7.5.4": - version: 7.5.4 - resolution: "semver@npm:7.5.4" - dependencies: - lru-cache: ^6.0.0 + version: 7.6.3 + resolution: "semver@npm:7.6.3" bin: semver: bin/semver.js - checksum: 12d8ad952fa353b0995bf180cdac205a4068b759a140e5d3c608317098b3575ac2f1e09182206bf2eb26120e1c0ed8fb92c48c592f6099680de56bb071423ca3 + checksum: 4110ec5d015c9438f322257b1c51fe30276e5f766a3f64c09edd1d7ea7118ecbc3f379f3b69032bacf13116dc7abc4ad8ce0d7e2bd642e26b0d271b56b61a7d8 languageName: node linkType: hard @@ -34044,11 +34034,11 @@ __metadata: linkType: hard "ts-api-utils@npm:^1.0.1": - version: 1.0.3 - resolution: "ts-api-utils@npm:1.0.3" + version: 1.3.0 + resolution: "ts-api-utils@npm:1.3.0" peerDependencies: typescript: ">=4.2.0" - checksum: 441cc4489d65fd515ae6b0f4eb8690057add6f3b6a63a36073753547fb6ce0c9ea0e0530220a0b282b0eec535f52c4dfc315d35f8a4c9a91c0def0707a714ca6 + checksum: c746ddabfdffbf16cb0b0db32bb287236a19e583057f8649ee7c49995bb776e1d3ef384685181c11a1a480369e022ca97512cb08c517b2d2bd82c83754c97012 languageName: node linkType: hard From f26b75901767d824d4648c8b4cc68a04f74da992 Mon Sep 17 00:00:00 2001 From: Valera Melnikov Date: Fri, 16 Aug 2024 14:52:17 +0300 Subject: [PATCH 12/21] chore: add build script for custom lint rules --- app/client/.eslintrc.base.json | 6 ++-- .../design-system/widgets/package.json | 4 +-- app/client/packages/eslint-plugin/index.ts | 14 -------- .../packages/eslint-plugin/jest.config.js | 11 ------ .../eslint-plugin/object-keys/rule.test.ts | 18 ---------- .../eslint-plugin/object-keys/rule.ts | 36 ------------------- .../packages/eslint-plugin/package.json | 7 +++- .../packages/eslint-plugin/src/index.ts | 6 ++-- .../src/object-keys/rule.test.ts | 4 +-- .../eslint-plugin/src/object-keys/rule.ts | 4 +-- .../packages/eslint-plugin/tsconfig.json | 11 ++++-- app/client/yarn.lock | 33 ++++------------- 12 files changed, 34 insertions(+), 120 deletions(-) delete mode 100644 app/client/packages/eslint-plugin/index.ts delete mode 100644 app/client/packages/eslint-plugin/jest.config.js delete mode 100644 app/client/packages/eslint-plugin/object-keys/rule.test.ts delete mode 100644 app/client/packages/eslint-plugin/object-keys/rule.ts diff --git a/app/client/.eslintrc.base.json b/app/client/.eslintrc.base.json index 71233413582..f5870275da5 100644 --- a/app/client/.eslintrc.base.json +++ b/app/client/.eslintrc.base.json @@ -17,7 +17,7 @@ "cypress", "testing-library", "jest", - "@appsmith" + "@appsmith" ], "extends": [ "plugin:react/recommended", // Uses the recommended rules from @eslint-plugin-react @@ -25,10 +25,10 @@ "plugin:cypress/recommended", "plugin:testing-library/react", "plugin:react-hooks/recommended", + "plugin:@appsmith/recommended", // Note: Please keep this as the last config to make sure that this (and by extension our .prettierrc file) overrides all configuration above it // https://www.npmjs.com/package/eslint-plugin-prettier#recommended-configuration - "plugin:prettier/recommended", - "plugin:@appsmith/recommended" + "plugin:prettier/recommended" ], "parserOptions": { "ecmaVersion": 2020, // Allows for the parsing of modern ECMAScript features diff --git a/app/client/packages/design-system/widgets/package.json b/app/client/packages/design-system/widgets/package.json index a4bd6bf71aa..b1267b65562 100644 --- a/app/client/packages/design-system/widgets/package.json +++ b/app/client/packages/design-system/widgets/package.json @@ -12,8 +12,8 @@ }, "dependencies": { "@appsmith/utils": "workspace:^", - "@design-system/headless": "workspace:^", - "@design-system/theming": "workspace:^", + "@appsmith/wds-headless": "workspace:^", + "@appsmith/wds-theming": "workspace:^", "@emotion/css": "^11.11.2", "@react-aria/actiongroup": "^3.7.0", "@react-aria/utils": "^3.16.0", diff --git a/app/client/packages/eslint-plugin/index.ts b/app/client/packages/eslint-plugin/index.ts deleted file mode 100644 index 12d65cf89c1..00000000000 --- a/app/client/packages/eslint-plugin/index.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { rule as objectKeysRule } from "./object-keys/rule"; - -export default { - rules: { - "object-keys": objectKeysRule, - }, - configs: { - recommended: { - rules: { - "@appsmith/object-keys": "warn", - }, - }, - }, -}; diff --git a/app/client/packages/eslint-plugin/jest.config.js b/app/client/packages/eslint-plugin/jest.config.js deleted file mode 100644 index abd33e3bca5..00000000000 --- a/app/client/packages/eslint-plugin/jest.config.js +++ /dev/null @@ -1,11 +0,0 @@ -module.exports = { - roots: [""], - transform: { - "^.+\\.(ts)$": [ - "ts-jest", - { - isolatedModules: true, - }, - ], - }, -}; diff --git a/app/client/packages/eslint-plugin/object-keys/rule.test.ts b/app/client/packages/eslint-plugin/object-keys/rule.test.ts deleted file mode 100644 index 901c0ea4b4b..00000000000 --- a/app/client/packages/eslint-plugin/object-keys/rule.test.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { TSESLint } from "@typescript-eslint/utils"; -import { rule } from "./rule"; - -const ruleTester = new TSESLint.RuleTester(); - -ruleTester.run("object-keys", rule, { - valid: [ - { - code: "objectKeys({ 'a': 'b' })", - }, - ], - invalid: [ - { - code: "Object.keys({ 'a': 'b' })", - errors: [{ messageId: "useObjectKeys" }], - }, - ], -}); diff --git a/app/client/packages/eslint-plugin/object-keys/rule.ts b/app/client/packages/eslint-plugin/object-keys/rule.ts deleted file mode 100644 index 612746a671a..00000000000 --- a/app/client/packages/eslint-plugin/object-keys/rule.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { TSESLint } from "@typescript-eslint/utils"; - -export const rule: TSESLint.RuleModule<"useObjectKeys"> = { - defaultOptions: [], - meta: { - type: "suggestion", - docs: { - description: "Warns when Object.keys is used instead of objectKeys", - recommended: "warn", - }, - schema: [], // No options - messages: { - useObjectKeys: - "Use objectKeys from '@appsmith/utils' package instead of Object.keys", - }, - }, - create(context) { - return { - CallExpression(node) { - // Check if the callee is Object.keys - if ( - node.callee.type === "MemberExpression" && - node.callee.object.type === "Identifier" && - node.callee.object.name === "Object" && - node.callee.property.type === "Identifier" && - node.callee.property.name === "keys" - ) { - context.report({ - node, - messageId: "useObjectKeys", - }); - } - }, - }; - }, -}; diff --git a/app/client/packages/eslint-plugin/package.json b/app/client/packages/eslint-plugin/package.json index 6852c157958..389406b120b 100644 --- a/app/client/packages/eslint-plugin/package.json +++ b/app/client/packages/eslint-plugin/package.json @@ -2,8 +2,13 @@ "name": "@appsmith/eslint-plugin", "version": "1.0.0", "private": true, - "main": "src/index.ts", + "main": "dist/index.js", "scripts": { + "build": "npx tsc", + "build:watch": "npx tsc --watch", + "lint": "yarn g:lint", + "prettier": "yarn g:prettier", + "postinstall": "yarn build", "test:unit": "yarn g:jest" } } diff --git a/app/client/packages/eslint-plugin/src/index.ts b/app/client/packages/eslint-plugin/src/index.ts index 274bd01a404..9dc8a6b200f 100644 --- a/app/client/packages/eslint-plugin/src/index.ts +++ b/app/client/packages/eslint-plugin/src/index.ts @@ -1,6 +1,6 @@ -import { rule as objectKeysRule } from "./object-keys/rule"; +import { objectKeysRule } from "./object-keys/rule"; -module.exports = { +const plugin = { rules: { "object-keys": objectKeysRule, }, @@ -12,3 +12,5 @@ module.exports = { }, }, }; + +export = plugin; diff --git a/app/client/packages/eslint-plugin/src/object-keys/rule.test.ts b/app/client/packages/eslint-plugin/src/object-keys/rule.test.ts index 901c0ea4b4b..0a2f2510462 100644 --- a/app/client/packages/eslint-plugin/src/object-keys/rule.test.ts +++ b/app/client/packages/eslint-plugin/src/object-keys/rule.test.ts @@ -1,9 +1,9 @@ import { TSESLint } from "@typescript-eslint/utils"; -import { rule } from "./rule"; +import { objectKeysRule } from "./rule"; const ruleTester = new TSESLint.RuleTester(); -ruleTester.run("object-keys", rule, { +ruleTester.run("object-keys", objectKeysRule, { valid: [ { code: "objectKeys({ 'a': 'b' })", diff --git a/app/client/packages/eslint-plugin/src/object-keys/rule.ts b/app/client/packages/eslint-plugin/src/object-keys/rule.ts index 612746a671a..a5e5dbb9a13 100644 --- a/app/client/packages/eslint-plugin/src/object-keys/rule.ts +++ b/app/client/packages/eslint-plugin/src/object-keys/rule.ts @@ -1,6 +1,6 @@ -import { TSESLint } from "@typescript-eslint/utils"; +import type { TSESLint } from "@typescript-eslint/utils"; -export const rule: TSESLint.RuleModule<"useObjectKeys"> = { +export const objectKeysRule: TSESLint.RuleModule<"useObjectKeys"> = { defaultOptions: [], meta: { type: "suggestion", diff --git a/app/client/packages/eslint-plugin/tsconfig.json b/app/client/packages/eslint-plugin/tsconfig.json index 63e20a2cf0b..4cd8be2f136 100644 --- a/app/client/packages/eslint-plugin/tsconfig.json +++ b/app/client/packages/eslint-plugin/tsconfig.json @@ -1,4 +1,11 @@ { - "extends": "../../tsconfig.json", - "include": ["./**/*"] + "compilerOptions": { + "outDir": "dist", + "target": "es2022", + "module": "commonjs", + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "strict": true, + "skipLibCheck": true + } } diff --git a/app/client/yarn.lock b/app/client/yarn.lock index 562b8671a92..cb2d86aff74 100644 --- a/app/client/yarn.lock +++ b/app/client/yarn.lock @@ -1,3 +1,6 @@ +# This file is generated by running "yarn install" inside your project. +# Manual changes might be lost - proceed with caution! + __metadata: version: 6 cacheKey: 8 @@ -286,6 +289,7 @@ __metadata: version: 0.0.0-use.local resolution: "@appsmith/wds@workspace:packages/design-system/widgets" dependencies: + "@appsmith/utils": "workspace:^" "@appsmith/wds-headless": "workspace:^" "@appsmith/wds-theming": "workspace:^" "@emotion/css": ^11.11.2 @@ -3217,31 +3221,6 @@ __metadata: languageName: unknown linkType: soft -"@design-system/widgets@workspace:^, @design-system/widgets@workspace:packages/design-system/widgets": - version: 0.0.0-use.local - resolution: "@design-system/widgets@workspace:packages/design-system/widgets" - dependencies: - "@appsmith/utils": "workspace:^" - "@design-system/headless": "workspace:^" - "@design-system/theming": "workspace:^" - "@emotion/css": ^11.11.2 - "@react-aria/actiongroup": ^3.7.0 - "@react-aria/utils": ^3.16.0 - "@react-aria/visually-hidden": ^3.8.0 - "@react-types/actiongroup": ^3.4.6 - "@react-types/shared": ^3.23.1 - "@tabler/icons-react": ^3.10.0 - "@types/fs-extra": ^11.0.4 - clsx: ^2.0.0 - colorjs.io: ^0.5.2 - eslint-plugin-storybook: ^0.6.10 - lodash: "*" - react-aria-components: ^1.2.1 - peerDependencies: - react: ^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 - languageName: unknown - linkType: soft - "@emotion/babel-plugin@npm:^11.11.0": version: 11.11.0 resolution: "@emotion/babel-plugin@npm:11.11.0" @@ -13177,10 +13156,10 @@ __metadata: dependencies: "@appsmith/ads": "workspace:^" "@appsmith/ads-old": "workspace:^" - "@appsmith/wds": "workspace:^" - "@appsmith/wds-theming": "workspace:^" "@appsmith/eslint-plugin": "workspace:^" "@appsmith/utils": "workspace:^" + "@appsmith/wds": "workspace:^" + "@appsmith/wds-theming": "workspace:^" "@aws-sdk/client-s3": ^3.622.0 "@aws-sdk/lib-storage": ^3.622.0 "@babel/helper-create-regexp-features-plugin": ^7.18.6 From d09df0f1ae2f114174b4babd13b34cc8f72e2853 Mon Sep 17 00:00:00 2001 From: Aman Agarwal Date: Fri, 16 Aug 2024 21:39:04 +0530 Subject: [PATCH 13/21] fix: jest config --- app/client/packages/eslint-plugin/jest.config.js | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 app/client/packages/eslint-plugin/jest.config.js diff --git a/app/client/packages/eslint-plugin/jest.config.js b/app/client/packages/eslint-plugin/jest.config.js new file mode 100644 index 00000000000..9b706028882 --- /dev/null +++ b/app/client/packages/eslint-plugin/jest.config.js @@ -0,0 +1,11 @@ +module.exports = { + roots: ["/src"], + transform: { + "^.+\\.(ts)$": [ + "ts-jest", + { + isolatedModules: true, + }, + ], + }, +}; From 0809b7eeccbc476dc0c6678adcc0c7cf3bbc5ad3 Mon Sep 17 00:00:00 2001 From: Aman Agarwal Date: Fri, 16 Aug 2024 21:48:06 +0530 Subject: [PATCH 14/21] fix: eslint and prettierconfig --- app/client/packages/eslint-plugin/.eslintrc.json | 1 + app/client/packages/eslint-plugin/.prettierignore | 5 +++++ 2 files changed, 6 insertions(+) create mode 100644 app/client/packages/eslint-plugin/.prettierignore diff --git a/app/client/packages/eslint-plugin/.eslintrc.json b/app/client/packages/eslint-plugin/.eslintrc.json index b6652ce70c7..7ac30ff73cb 100644 --- a/app/client/packages/eslint-plugin/.eslintrc.json +++ b/app/client/packages/eslint-plugin/.eslintrc.json @@ -1,3 +1,4 @@ { + "ignorePatterns": ["dist/*"], "extends": ["../../.eslintrc.base.json"] } diff --git a/app/client/packages/eslint-plugin/.prettierignore b/app/client/packages/eslint-plugin/.prettierignore new file mode 100644 index 00000000000..e215fdd6dff --- /dev/null +++ b/app/client/packages/eslint-plugin/.prettierignore @@ -0,0 +1,5 @@ +dist/ +node_modules/ +package-lock.json +yarn.lock +package.json From 0407be6454b8eb6bceb951aa5bc64ab9706c87d4 Mon Sep 17 00:00:00 2001 From: Aman Agarwal Date: Fri, 16 Aug 2024 21:56:43 +0530 Subject: [PATCH 15/21] fix: updated the design-sytem package, removed readme from prettier, eslint --- .../Button/chromatic/Button.chromatic.stories.tsx | 2 +- .../src/components/Button/stories/Button.stories.tsx | 8 +------- .../components/IconButton/stories/IconButton.stories.tsx | 2 +- .../ToolbarButtons/stories/ToolbarButtons.stories.tsx | 2 +- app/client/packages/eslint-plugin/.eslintrc.json | 2 +- app/client/packages/eslint-plugin/.prettierignore | 1 + .../widgets/wds/WDSButtonWidget/config/defaultsConfig.ts | 2 +- .../config/propertyPaneConfig/styleConfig.ts | 2 +- .../wds/WDSIconButtonWidget/config/defaultsConfig.ts | 2 +- .../config/propertyPaneConfig/styleConfig.ts | 2 +- .../config/propertyPaneConfig/contentConfig.ts | 2 +- .../wds/WDSMenuButtonWidget/config/defaultsConfig.ts | 2 +- .../config/propertyPaneConfig/styleConfig.ts | 2 +- .../config/propertyPaneConfig/PanelConfig/General.ts | 2 +- .../config/propertyPaneConfig/styleConfig.ts | 2 +- 15 files changed, 15 insertions(+), 20 deletions(-) diff --git a/app/client/packages/design-system/widgets/src/components/Button/chromatic/Button.chromatic.stories.tsx b/app/client/packages/design-system/widgets/src/components/Button/chromatic/Button.chromatic.stories.tsx index 3242f0f4b68..efbea171d2b 100644 --- a/app/client/packages/design-system/widgets/src/components/Button/chromatic/Button.chromatic.stories.tsx +++ b/app/client/packages/design-system/widgets/src/components/Button/chromatic/Button.chromatic.stories.tsx @@ -1,7 +1,7 @@ import React from "react"; import type { Meta, StoryObj } from "@storybook/react"; import { StoryGrid, DataAttrWrapper } from "@design-system/storybook"; -import { Button, BUTTON_VARIANTS, COLORS } from "@design-system/widgets"; +import { Button, BUTTON_VARIANTS, COLORS } from "@appsmith/wds"; import { objectKeys } from "@appsmith/utils"; const variants = objectKeys(BUTTON_VARIANTS); diff --git a/app/client/packages/design-system/widgets/src/components/Button/stories/Button.stories.tsx b/app/client/packages/design-system/widgets/src/components/Button/stories/Button.stories.tsx index a6b05b4833c..4fe1df9a36c 100644 --- a/app/client/packages/design-system/widgets/src/components/Button/stories/Button.stories.tsx +++ b/app/client/packages/design-system/widgets/src/components/Button/stories/Button.stories.tsx @@ -1,12 +1,6 @@ import React from "react"; import type { Meta, StoryObj } from "@storybook/react"; -import { - Button, - Flex, - BUTTON_VARIANTS, - COLORS, - SIZES, -} from "@design-system/widgets"; +import { Button, Flex, BUTTON_VARIANTS, COLORS, SIZES } from "@appsmith/wds"; import { objectKeys } from "@appsmith/utils"; /** diff --git a/app/client/packages/design-system/widgets/src/components/IconButton/stories/IconButton.stories.tsx b/app/client/packages/design-system/widgets/src/components/IconButton/stories/IconButton.stories.tsx index f73f45aade8..4dcb9e0a616 100644 --- a/app/client/packages/design-system/widgets/src/components/IconButton/stories/IconButton.stories.tsx +++ b/app/client/packages/design-system/widgets/src/components/IconButton/stories/IconButton.stories.tsx @@ -6,7 +6,7 @@ import { SIZES, BUTTON_VARIANTS, COLORS, -} from "@design-system/widgets"; +} from "@appsmith/wds"; import { objectKeys } from "@appsmith/utils"; /** diff --git a/app/client/packages/design-system/widgets/src/components/ToolbarButtons/stories/ToolbarButtons.stories.tsx b/app/client/packages/design-system/widgets/src/components/ToolbarButtons/stories/ToolbarButtons.stories.tsx index 439d32b907a..b2723487906 100644 --- a/app/client/packages/design-system/widgets/src/components/ToolbarButtons/stories/ToolbarButtons.stories.tsx +++ b/app/client/packages/design-system/widgets/src/components/ToolbarButtons/stories/ToolbarButtons.stories.tsx @@ -6,7 +6,7 @@ import { Flex, ToolbarButtons, SIZES, -} from "@design-system/widgets"; +} from "@appsmith/wds"; import { objectKeys } from "@appsmith/utils"; import { itemList, diff --git a/app/client/packages/eslint-plugin/.eslintrc.json b/app/client/packages/eslint-plugin/.eslintrc.json index 7ac30ff73cb..7720378e09b 100644 --- a/app/client/packages/eslint-plugin/.eslintrc.json +++ b/app/client/packages/eslint-plugin/.eslintrc.json @@ -1,4 +1,4 @@ { - "ignorePatterns": ["dist/*"], + "ignorePatterns": ["dist/*", "Readme.md"], "extends": ["../../.eslintrc.base.json"] } diff --git a/app/client/packages/eslint-plugin/.prettierignore b/app/client/packages/eslint-plugin/.prettierignore index e215fdd6dff..dbea052ebc1 100644 --- a/app/client/packages/eslint-plugin/.prettierignore +++ b/app/client/packages/eslint-plugin/.prettierignore @@ -3,3 +3,4 @@ node_modules/ package-lock.json yarn.lock package.json +Readme.md diff --git a/app/client/src/widgets/wds/WDSButtonWidget/config/defaultsConfig.ts b/app/client/src/widgets/wds/WDSButtonWidget/config/defaultsConfig.ts index 1d22e0cee09..afb0ed2fa91 100644 --- a/app/client/src/widgets/wds/WDSButtonWidget/config/defaultsConfig.ts +++ b/app/client/src/widgets/wds/WDSButtonWidget/config/defaultsConfig.ts @@ -1,5 +1,5 @@ import { RecaptchaTypes } from "components/constants"; -import { COLORS, BUTTON_VARIANTS } from "@design-system/widgets"; +import { COLORS, BUTTON_VARIANTS } from "@appsmith/wds"; import { ResponsiveBehavior } from "layoutSystems/common/utils/constants"; import { objectKeys } from "@appsmith/utils"; import { diff --git a/app/client/src/widgets/wds/WDSButtonWidget/config/propertyPaneConfig/styleConfig.ts b/app/client/src/widgets/wds/WDSButtonWidget/config/propertyPaneConfig/styleConfig.ts index 309ed24cfab..249b14196ce 100644 --- a/app/client/src/widgets/wds/WDSButtonWidget/config/propertyPaneConfig/styleConfig.ts +++ b/app/client/src/widgets/wds/WDSButtonWidget/config/propertyPaneConfig/styleConfig.ts @@ -1,6 +1,6 @@ import { capitalize } from "lodash"; import { ValidationTypes } from "constants/WidgetValidation"; -import { COLORS, BUTTON_VARIANTS } from "@design-system/widgets"; +import { COLORS, BUTTON_VARIANTS } from "@appsmith/wds"; import { objectKeys } from "@appsmith/utils"; export const propertyPaneStyleConfig = [ diff --git a/app/client/src/widgets/wds/WDSIconButtonWidget/config/defaultsConfig.ts b/app/client/src/widgets/wds/WDSIconButtonWidget/config/defaultsConfig.ts index 3859696f77c..8e381fa449b 100644 --- a/app/client/src/widgets/wds/WDSIconButtonWidget/config/defaultsConfig.ts +++ b/app/client/src/widgets/wds/WDSIconButtonWidget/config/defaultsConfig.ts @@ -1,4 +1,4 @@ -import { BUTTON_VARIANTS, COLORS } from "@design-system/widgets"; +import { BUTTON_VARIANTS, COLORS } from "@appsmith/wds"; import { objectKeys } from "@appsmith/utils"; import { ResponsiveBehavior } from "layoutSystems/common/utils/constants"; diff --git a/app/client/src/widgets/wds/WDSIconButtonWidget/config/propertyPaneConfig/styleConfig.ts b/app/client/src/widgets/wds/WDSIconButtonWidget/config/propertyPaneConfig/styleConfig.ts index 5f222107cc6..787a2e1d8e7 100644 --- a/app/client/src/widgets/wds/WDSIconButtonWidget/config/propertyPaneConfig/styleConfig.ts +++ b/app/client/src/widgets/wds/WDSIconButtonWidget/config/propertyPaneConfig/styleConfig.ts @@ -1,5 +1,5 @@ import { capitalize } from "lodash"; -import { BUTTON_VARIANTS, COLORS } from "@design-system/widgets"; +import { BUTTON_VARIANTS, COLORS } from "@appsmith/wds"; import { objectKeys } from "@appsmith/utils"; import { ValidationTypes } from "constants/WidgetValidation"; diff --git a/app/client/src/widgets/wds/WDSInlineButtonsWidget/config/propertyPaneConfig/contentConfig.ts b/app/client/src/widgets/wds/WDSInlineButtonsWidget/config/propertyPaneConfig/contentConfig.ts index ac58ba52d95..939e9d599ab 100644 --- a/app/client/src/widgets/wds/WDSInlineButtonsWidget/config/propertyPaneConfig/contentConfig.ts +++ b/app/client/src/widgets/wds/WDSInlineButtonsWidget/config/propertyPaneConfig/contentConfig.ts @@ -1,4 +1,4 @@ -import { BUTTON_VARIANTS, COLORS } from "@design-system/widgets"; +import { BUTTON_VARIANTS, COLORS } from "@appsmith/wds"; import { BUTTON_WIDGET_DEFAULT_LABEL, createMessage, diff --git a/app/client/src/widgets/wds/WDSMenuButtonWidget/config/defaultsConfig.ts b/app/client/src/widgets/wds/WDSMenuButtonWidget/config/defaultsConfig.ts index 244cbfc4e59..41cd481fe90 100644 --- a/app/client/src/widgets/wds/WDSMenuButtonWidget/config/defaultsConfig.ts +++ b/app/client/src/widgets/wds/WDSMenuButtonWidget/config/defaultsConfig.ts @@ -1,4 +1,4 @@ -import { BUTTON_VARIANTS, COLORS } from "@design-system/widgets"; +import { BUTTON_VARIANTS, COLORS } from "@appsmith/wds"; import type { WidgetDefaultProps } from "WidgetProvider/constants"; import { objectKeys } from "@appsmith/utils"; diff --git a/app/client/src/widgets/wds/WDSMenuButtonWidget/config/propertyPaneConfig/styleConfig.ts b/app/client/src/widgets/wds/WDSMenuButtonWidget/config/propertyPaneConfig/styleConfig.ts index d92407fd2dc..7a440bacf9b 100644 --- a/app/client/src/widgets/wds/WDSMenuButtonWidget/config/propertyPaneConfig/styleConfig.ts +++ b/app/client/src/widgets/wds/WDSMenuButtonWidget/config/propertyPaneConfig/styleConfig.ts @@ -1,6 +1,6 @@ import { capitalize } from "lodash"; import { ValidationTypes } from "constants/WidgetValidation"; -import { BUTTON_VARIANTS, COLORS, ICONS } from "@design-system/widgets"; +import { BUTTON_VARIANTS, COLORS, ICONS } from "@appsmith/wds"; import { objectKeys } from "@appsmith/utils"; import type { MenuButtonWidgetProps } from "../../widget/types"; diff --git a/app/client/src/widgets/wds/WDSTableWidget/config/propertyPaneConfig/PanelConfig/General.ts b/app/client/src/widgets/wds/WDSTableWidget/config/propertyPaneConfig/PanelConfig/General.ts index f15d65d7221..fdb04dc0e98 100644 --- a/app/client/src/widgets/wds/WDSTableWidget/config/propertyPaneConfig/PanelConfig/General.ts +++ b/app/client/src/widgets/wds/WDSTableWidget/config/propertyPaneConfig/PanelConfig/General.ts @@ -2,7 +2,7 @@ import { ValidationTypes } from "constants/WidgetValidation"; import type { TableWidgetProps } from "widgets/wds/WDSTableWidget/constants"; import { ColumnTypes } from "widgets/wds/WDSTableWidget/constants"; import { hideByColumnType } from "../../../widget/propertyUtils"; -import { BUTTON_VARIANTS } from "@design-system/widgets"; +import { BUTTON_VARIANTS } from "@appsmith/wds"; import { objectKeys } from "@appsmith/utils"; export default { diff --git a/app/client/src/widgets/wds/WDSToolbarButtonsWidget/config/propertyPaneConfig/styleConfig.ts b/app/client/src/widgets/wds/WDSToolbarButtonsWidget/config/propertyPaneConfig/styleConfig.ts index 45053da515d..40c9451493f 100644 --- a/app/client/src/widgets/wds/WDSToolbarButtonsWidget/config/propertyPaneConfig/styleConfig.ts +++ b/app/client/src/widgets/wds/WDSToolbarButtonsWidget/config/propertyPaneConfig/styleConfig.ts @@ -1,4 +1,4 @@ -import { BUTTON_VARIANTS, COLORS } from "@design-system/widgets"; +import { BUTTON_VARIANTS, COLORS } from "@appsmith/wds"; import { ValidationTypes } from "constants/WidgetValidation"; import { capitalize } from "lodash"; import { objectKeys } from "@appsmith/utils"; From 7463e68ad05b46d06242b9f84437b6ccdcd5b7bf Mon Sep 17 00:00:00 2001 From: Aman Agarwal Date: Wed, 21 Aug 2024 17:11:35 +0530 Subject: [PATCH 16/21] fix: removed cypress config change --- app/client/cypress.config.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/client/cypress.config.ts b/app/client/cypress.config.ts index 6ba540d78dc..12603c6ad37 100644 --- a/app/client/cypress.config.ts +++ b/app/client/cypress.config.ts @@ -26,8 +26,8 @@ export default defineConfig({ e2e: { baseUrl: "https://dev.appsmith.com/", env: { - USERNAME: "aman@appsmith.com", - PASSWORD: "aman@appsmith.com", + USERNAME: "xxxx", + PASSWORD: "xxx", grepFilterSpecs: true, grepOmitFiltered: true, }, From 491ccbf7eebb2c796591fcb188ee8751a8b9c7bd Mon Sep 17 00:00:00 2001 From: Aman Agarwal Date: Wed, 21 Aug 2024 19:04:57 +0530 Subject: [PATCH 17/21] fix: changed the export format --- app/client/packages/eslint-plugin/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/client/packages/eslint-plugin/src/index.ts b/app/client/packages/eslint-plugin/src/index.ts index 9dc8a6b200f..89cd1337513 100644 --- a/app/client/packages/eslint-plugin/src/index.ts +++ b/app/client/packages/eslint-plugin/src/index.ts @@ -13,4 +13,4 @@ const plugin = { }, }; -export = plugin; +export default plugin; From cebbf83e4c5f03225ecaca0fd0b068a135b267aa Mon Sep 17 00:00:00 2001 From: Aman Agarwal Date: Thu, 22 Aug 2024 01:00:58 +0530 Subject: [PATCH 18/21] fix: changed to module exports --- app/client/packages/eslint-plugin/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/client/packages/eslint-plugin/src/index.ts b/app/client/packages/eslint-plugin/src/index.ts index 89cd1337513..e3e454c20e2 100644 --- a/app/client/packages/eslint-plugin/src/index.ts +++ b/app/client/packages/eslint-plugin/src/index.ts @@ -13,4 +13,4 @@ const plugin = { }, }; -export default plugin; +module.exports = plugin; From fe4709eecfc21bfa10abcd031a8fa50b558b9dd9 Mon Sep 17 00:00:00 2001 From: Aman Agarwal Date: Thu, 22 Aug 2024 16:42:07 +0530 Subject: [PATCH 19/21] fix: removed prettier and updated package json, readme --- .../packages/eslint-plugin/.prettierignore | 6 ---- .../eslint-plugin/{Readme.md => README-2.md} | 28 +++++++++---------- .../packages/eslint-plugin/package.json | 2 +- 3 files changed, 15 insertions(+), 21 deletions(-) delete mode 100644 app/client/packages/eslint-plugin/.prettierignore rename app/client/packages/eslint-plugin/{Readme.md => README-2.md} (85%) diff --git a/app/client/packages/eslint-plugin/.prettierignore b/app/client/packages/eslint-plugin/.prettierignore deleted file mode 100644 index dbea052ebc1..00000000000 --- a/app/client/packages/eslint-plugin/.prettierignore +++ /dev/null @@ -1,6 +0,0 @@ -dist/ -node_modules/ -package-lock.json -yarn.lock -package.json -Readme.md diff --git a/app/client/packages/eslint-plugin/Readme.md b/app/client/packages/eslint-plugin/README-2.md similarity index 85% rename from app/client/packages/eslint-plugin/Readme.md rename to app/client/packages/eslint-plugin/README-2.md index 66b0ac67738..ebf21349139 100644 --- a/app/client/packages/eslint-plugin/Readme.md +++ b/app/client/packages/eslint-plugin/README-2.md @@ -23,17 +23,17 @@ You can create one by following the [official ESLint custom rule](https://eslint docs: { description: "A description of what the rule does", category: "Best Practices", - recommended: false + recommended: false, }, fixable: null, // or "code" if the rule can fix issues automatically - schema: [] // JSON Schema for rule options + schema: [], // JSON Schema for rule options }, create(context) { return { // Define the rule's behavior here // e.g., "Identifier": (node) => { /* logic */ } }; - } + }, }; ``` @@ -44,12 +44,12 @@ You can create one by following the [official ESLint custom rule](https://eslint 2. Import your custom rule and add it to the rules object in `index.js`. For example: ```js - const customRule = require('./custom-rule/rule.js'); + const customRule = require("./custom-rule/rule.js"); module.exports = { rules: { - 'custom-rule': customRule - } + "custom-rule": customRule, + }, }; ``` @@ -64,21 +64,21 @@ You can create one by following the [official ESLint custom rule](https://eslint 2. Open `custom-rule/rule.test.js` and write tests using a testing framework like Mocha or Jest. Here's a basic example using ESLint's `RuleTester`: ```js - const rule = require('./rule'); - const RuleTester = require('eslint').RuleTester; + const rule = require("./rule"); + const RuleTester = require("eslint").RuleTester; const ruleTester = new RuleTester(); - ruleTester.run('custom-rule', rule, { + ruleTester.run("custom-rule", rule, { valid: [ // Examples of valid code ], invalid: [ { - code: 'const foo = 1;', - errors: [{ message: 'Your custom error message' }] - } - ] + code: "const foo = 1;", + errors: [{ message: "Your custom error message" }], + }, + ], }); ``` @@ -103,4 +103,4 @@ You can create one by following the [official ESLint custom rule](https://eslint - [ESLint Rules API](https://eslint.org/docs/developer-guide/working-with-rules) - [ESLint Testing Guidelines](https://eslint.org/docs/developer-guide/unit-testing) -Happy linting! \ No newline at end of file +Happy linting! diff --git a/app/client/packages/eslint-plugin/package.json b/app/client/packages/eslint-plugin/package.json index 389406b120b..46f1726ebec 100644 --- a/app/client/packages/eslint-plugin/package.json +++ b/app/client/packages/eslint-plugin/package.json @@ -11,4 +11,4 @@ "postinstall": "yarn build", "test:unit": "yarn g:jest" } -} +} \ No newline at end of file From eb5f9fed2f76472ecb77d7b49ffb219cfd75e4ca Mon Sep 17 00:00:00 2001 From: Aman Agarwal Date: Thu, 22 Aug 2024 16:42:28 +0530 Subject: [PATCH 20/21] fix: updated readme md --- app/client/packages/eslint-plugin/{README-2.md => README.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename app/client/packages/eslint-plugin/{README-2.md => README.md} (100%) diff --git a/app/client/packages/eslint-plugin/README-2.md b/app/client/packages/eslint-plugin/README.md similarity index 100% rename from app/client/packages/eslint-plugin/README-2.md rename to app/client/packages/eslint-plugin/README.md From f5e0eefd2a4bc8ac9812dc3f8c6b012e300cc57a Mon Sep 17 00:00:00 2001 From: Aman Agarwal Date: Thu, 22 Aug 2024 16:55:28 +0530 Subject: [PATCH 21/21] fix: added prettier for dist --- app/client/packages/eslint-plugin/.prettierignore | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 app/client/packages/eslint-plugin/.prettierignore diff --git a/app/client/packages/eslint-plugin/.prettierignore b/app/client/packages/eslint-plugin/.prettierignore new file mode 100644 index 00000000000..cc72819ae20 --- /dev/null +++ b/app/client/packages/eslint-plugin/.prettierignore @@ -0,0 +1,4 @@ +dist/ +node_modules/ +package-lock.json +yarn.lock