@bigbinary/neeto-commons-frontend 2.0.25 → 2.0.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,92 @@
1
+ module.exports = {
2
+ rules: {
3
+ // not-auto-fixable: Prevent missing props validation in a React component definition.
4
+ "react/prop-types": "off",
5
+ // not-auto-fixable: Detect unescaped HTML entities, which might represent malformed tags.
6
+ "react/no-unescaped-entities": "off",
7
+ // not-auto-fixable: Prevent missing displayName in a React component definition. Useful when using React extensions in browser and checking for component name.
8
+ "react/display-name": "error",
9
+ // not-auto-fixable: Reports when this.state is accessed within setState.
10
+ "react/no-access-state-in-setstate": "error",
11
+ // not-auto-fixable: Prevent usage of dangerous JSX props. Currently jam3 plugin will take care of handling this.
12
+ "react/no-danger": "off",
13
+ // not-auto-fixable: Report when a DOM element is using both children and dangerouslySetInnerHTML.
14
+ "react/no-danger-with-children": "warn",
15
+ // not-auto-fixable: Prevent definitions of unused prop types.
16
+ "react/no-unused-prop-types": "error",
17
+ // not-auto-fixable: Report missing key props in iterators/collection literals. Important rule!
18
+ "react/jsx-key": ["error", { checkFragmentShorthand: true }],
19
+ // not-auto-fixable: Enforce no duplicate props.
20
+ "react/jsx-no-duplicate-props": "error",
21
+ // not-auto-fixable: Disallow undeclared variables in JSX.
22
+ "react/jsx-no-undef": "error",
23
+ // not-auto-fixable: Enforce PascalCase for user-defined JSX components.
24
+ "react/jsx-pascal-case": ["error", { allowNamespace: true }],
25
+ // not-auto-fixable: Prevent React to be incorrectly marked as unused.
26
+ "react/jsx-uses-react": "error",
27
+ // not-auto-fixable: Prevent variables used in JSX to be marked as unused.
28
+ "react/jsx-uses-vars": "error",
29
+ // not-auto-fixable: Ensures https://reactjs.org/docs/hooks-rules.html.
30
+ "react-hooks/rules-of-hooks": "error",
31
+ // not-auto-fixable: Ensures https://reactjs.org/docs/hooks-rules.html - Checks effect dependencies.
32
+ "react-hooks/exhaustive-deps": "warn",
33
+ // auto-fixable: A fragment is redundant if it contains only one child, or if it is the child of a html element, and is not a keyed fragment.
34
+ "react/jsx-no-useless-fragment": ["error", { allowExpressions: true }],
35
+ // auto-fixable: Prefer arrow function expressions for component declaration.
36
+ "react/function-component-definition": [
37
+ "error",
38
+ {
39
+ namedComponents: "arrow-function",
40
+ unnamedComponents: "arrow-function",
41
+ },
42
+ ],
43
+ // auto-fixable: Components without children can be self-closed to avoid unnecessary extra closing tag.
44
+ "react/self-closing-comp": [
45
+ "error",
46
+ {
47
+ component: true,
48
+ html: true,
49
+ },
50
+ ],
51
+ // auto-fixable: Wrapping multiline JSX in parentheses can improve readability and/or convenience.
52
+ "react/jsx-wrap-multilines": [
53
+ "error",
54
+ {
55
+ declaration: "parens-new-line",
56
+ assignment: "parens-new-line",
57
+ return: "parens-new-line",
58
+ arrow: "parens-new-line",
59
+ condition: "parens-new-line",
60
+ logical: "parens-new-line",
61
+ prop: "ignore",
62
+ },
63
+ ],
64
+ // not-auto-fixable: Make sure files containing JSX is having .jsx extension.
65
+ "react/jsx-filename-extension": ["error", { allow: "as-needed" }],
66
+ // auto-fixable: Omit mentioning the "true" value if it can be implicitly understood in props.
67
+ "react/jsx-boolean-value": "error",
68
+ // auto-fixable: Partially fixable. Make sure the state and setter have symmertic naming.
69
+ "react/hook-use-state": "error",
70
+ // auto-fixable: Shorthand notations should always be at the top and also enforce props alphabetical sorting.
71
+ "react/jsx-sort-props": [
72
+ "error",
73
+ {
74
+ callbacksLast: true,
75
+ shorthandFirst: true,
76
+ multiline: "last",
77
+ reservedFirst: false,
78
+ locale: "auto",
79
+ },
80
+ ],
81
+ // auto-fixable: Disallow unnecessary curly braces in JSX props and/or children.
82
+ "react/jsx-curly-brace-presence": [
83
+ "error",
84
+ {
85
+ props: "never",
86
+ children: "never",
87
+ // JSX prop values that are JSX elements should be enclosed in braces.
88
+ propElementValues: "always",
89
+ },
90
+ ],
91
+ },
92
+ };
@@ -0,0 +1,16 @@
1
+ module.exports = {
2
+ tailwindConfig: "./tailwind.config.js",
3
+ trailingComma: "es5",
4
+ arrowParens: "avoid",
5
+ printWidth: 80,
6
+ tabWidth: 2,
7
+ useTabs: false,
8
+ semi: true,
9
+ quoteProps: "as-needed",
10
+ jsxSingleQuote: false,
11
+ singleQuote: false,
12
+ bracketSpacing: true,
13
+ bracketSameLine: false,
14
+ proseWrap: "always",
15
+ endOfLine: "lf",
16
+ };
@@ -0,0 +1,13 @@
1
+ module.exports = {
2
+ important: true,
3
+ purge: {
4
+ enabled: process.env.NODE_ENV === "production",
5
+ content: [
6
+ "./app/javascript/**/*.{js,jsx}",
7
+ "./app/views/**/*.html.erb",
8
+ "./app/views/**/*.slim",
9
+ "./node_modules/@bigbinary/**/*.js",
10
+ ],
11
+ defaultExtractor: content => content.match(/[A-Za-z0-9-_:/]+/g) || [],
12
+ },
13
+ };
@@ -0,0 +1,57 @@
1
+ /*
2
+ Customize default webpack rules/loaders configuration.
3
+ A custom helpers till shakapacker introduces the feature.
4
+ Track the following the issues to get the status of feature development in shakapacker:
5
+ https://github.com/shakacode/shakapacker/issues/80
6
+ https://github.com/shakacode/shakapacker/issues/87
7
+ Usage:
8
+ const customizeWebpackDefaultRules = require("./helpers/customize-default-rules");
9
+ const defaultRules = {
10
+ "asset/resource": {
11
+ test: /\.(bmp|gif|jpe?g|png|tiff|ico|avif|webp|eot|otf|ttf|woff|woff2)$/
12
+ },
13
+ "asset/source": {
14
+ exclude: /\.(js|mjs|jsx|ts|tsx|js)$/,
15
+ },
16
+ };
17
+ const customWebpackConfig = customizeWebpackDefaultRules(webpackConfig, defaultRules);
18
+ NOTE:
19
+ - Check if the option to output default configuration is introduced or not before upgrading further.
20
+ - Update the defaultRuleType constant whenever shakapacker introduces a new default rule/loader.
21
+ */
22
+ const {
23
+ findBy,
24
+ findIndexBy,
25
+ } = require("@bigbinary/neeto-commons-frontend/pure");
26
+
27
+ const modifyDefaultRulesConfig = (webpackConfig, rules = {}) => {
28
+ const defaultRuleType = ["asset/resource", "asset/source"];
29
+
30
+ Object.keys(rules).forEach(ruleName => {
31
+ if (defaultRuleType.includes(ruleName)) {
32
+ const rule = findBy(
33
+ { type: "asset/resource" },
34
+ webpackConfig.module.rules
35
+ );
36
+
37
+ const rulePosition = findIndexBy(
38
+ { type: ruleName },
39
+ webpackConfig.module.rules
40
+ );
41
+
42
+ Object.keys(rules[ruleName]).forEach(attribute => {
43
+ if (rule[attribute] !== undefined) {
44
+ rule[attribute] = rules[ruleName][attribute];
45
+ }
46
+ });
47
+
48
+ webpackConfig.module.rules[rulePosition] = rule;
49
+ } else {
50
+ throw new Error("Invalid default rule type");
51
+ }
52
+ });
53
+
54
+ return webpackConfig;
55
+ };
56
+
57
+ module.exports = modifyDefaultRulesConfig;
@@ -0,0 +1,41 @@
1
+ const process = require("process");
2
+
3
+ const Dotenv = require("dotenv-webpack");
4
+ const { webpackConfig, merge } = require("shakapacker");
5
+ const webpack = require("webpack");
6
+
7
+ const customizeWebpackDefaultRules = require("./helpers/customize-default-rules");
8
+ const resolve = require("./resolve");
9
+ const rules = require("./rules");
10
+
11
+ const dotEnvFileSuffix =
12
+ process.env.NODE_ENV === "production" ? "" : `.${process.env.NODE_ENV}`;
13
+
14
+ const commonOptions = {
15
+ infrastructureLogging: { level: "warn" },
16
+ devtool: "source-map",
17
+ resolve,
18
+ module: { rules },
19
+ plugins: [
20
+ new webpack.ProvidePlugin({ process: "process/browser" }),
21
+ new Dotenv({
22
+ path: `./.env${dotEnvFileSuffix}`,
23
+ systemvars: true,
24
+ silent: true,
25
+ }),
26
+ ],
27
+ };
28
+
29
+ // This rule is causing issues to react-svg-loader
30
+ const defaultRules = {
31
+ "asset/resource": {
32
+ test: /\.(bmp|gif|jpe?g|png|tiff|ico|avif|webp|eot|otf|ttf|woff|woff2)$/,
33
+ },
34
+ };
35
+
36
+ const customWebpackConfig = customizeWebpackDefaultRules(
37
+ webpackConfig,
38
+ defaultRules
39
+ );
40
+
41
+ module.exports = merge(customWebpackConfig, commonOptions);
@@ -0,0 +1,47 @@
1
+ const path = require("path");
2
+
3
+ const absolutePath = basePath =>
4
+ path.resolve(__dirname, "../../../../../", `app/javascript/${basePath}`);
5
+
6
+ module.exports = {
7
+ alias: {
8
+ apis: absolutePath("src/apis"),
9
+ assets: absolutePath("src/assets"),
10
+ components: absolutePath("src/components"),
11
+ hooks: absolutePath("src/hooks"),
12
+ reducers: absolutePath("src/reducers"),
13
+ routes: absolutePath("src/routes"),
14
+ stores: absolutePath("src/stores"),
15
+ translations: absolutePath("src/translations"),
16
+ utils: absolutePath("src/utils"),
17
+ src: absolutePath("src"),
18
+ neetoui: "@bigbinary/neetoui",
19
+ neetocommons: "@bigbinary/neeto-commons-frontend",
20
+ neetoicons: "@bigbinary/neeto-icons",
21
+ neetoteam: "@bigbinary/neeto-team-members-frontend",
22
+ neetoeditor: "@bigbinary/neeto-editor",
23
+ neetofilters: "@bigbinary/neeto-filters-frontend",
24
+ images: path.resolve(__dirname, "../../../../../", "app/assets/images"),
25
+ },
26
+ extensions: [
27
+ ".ts",
28
+ ".mjs",
29
+ ".js",
30
+ ".sass",
31
+ ".scss",
32
+ ".css",
33
+ ".module.sass",
34
+ ".module.scss",
35
+ ".module.css",
36
+ ".png",
37
+ ".svg",
38
+ ".gif",
39
+ ".jpeg",
40
+ ".jpg",
41
+ ],
42
+ fallback: {
43
+ util: require.resolve("util/"),
44
+ url: require.resolve("url/"),
45
+ fs: false,
46
+ },
47
+ };
@@ -0,0 +1,43 @@
1
+ module.exports = [
2
+ {
3
+ test: /\.svg$/i,
4
+ use: [
5
+ {
6
+ loader: "@svgr/webpack",
7
+ options: {
8
+ svgoConfig: { plugins: ["preset-default"] },
9
+ },
10
+ },
11
+ ],
12
+ },
13
+ {
14
+ test: /\.ts$/,
15
+ exclude: /node_modules/,
16
+ use: {
17
+ loader: "babel-loader",
18
+ options: {
19
+ presets: ["@babel/preset-env", "@babel/preset-typescript"],
20
+ },
21
+ },
22
+ },
23
+ {
24
+ test: /\.mp3$/,
25
+ use: [
26
+ "babel-loader",
27
+ {
28
+ loader: "file-loader",
29
+ options: {
30
+ query: {
31
+ name: "static/media/[name].[hash:8].[ext]",
32
+ },
33
+ },
34
+ },
35
+ ],
36
+ },
37
+ {
38
+ test: /\.m?js$/,
39
+ resolve: {
40
+ fullySpecified: false, // allows webpack to ignore some package rules as the Strict EcmaScript Module mode.
41
+ },
42
+ },
43
+ ];
@@ -1142,9 +1142,9 @@ var neetoCommons = {
1142
1142
  },
1143
1143
  body: {
1144
1144
  values: {
1145
- embedCode: "<p>Hi,</p> <p>We are going to use {{selectedWidgets}}. Please find the code snippet for the installation of the {{selectedWidgets}} widget. You can find the documentation regarding this at <configureLink>{{neetoKbUrl}}</configureLink>.</p> <p>If you still need help then send an email to <mail>{{helpEmail}}</mail>.</p>",
1146
- userIdentity: "Hey there. This is the object structure that you can use to specify the user identity for neetoWidget. You can find the documentation at - {{userIdentityKbUrl}}.",
1147
- sessionContext: "Hey there. This is the object structure that you can use to specify the contextual values for neetoReplay sessions. You can find the documentation at - {{sessionContextKbUrl}}."
1145
+ embedCode: "<p>Hi,</p> <p>We are going to use {{selectedWidgets}}.</p> <p>Please find the code snippet for the installation of the {{selectedWidgets}} widget.</p> <p>You can find the documentation regarding this at <configureLink>{{neetoKbUrl}}</configureLink>.</p> <p>If you still need help then send an email to <mail>{{helpEmail}}</mail>.</p>",
1146
+ userIdentity: "<p>Hi,</p> <p>This is the object structure that you can use to specify the user identity for neetoWidget.</p> <p>You can find the documentation at <configureLink>{{userIdentityKbUrl}}</configureLink>.</p>",
1147
+ sessionContext: "<p>Hi,</p> <p>This is the object structure that you can use to specify the contextual values for neetoReplay sessions.</p> <p>You can find the documentation at <configureLink>{{sessionContextKbUrl}}</configureLink>.</p>"
1148
1148
  }
1149
1149
  },
1150
1150
  actions: {
package/initializers.js CHANGED
@@ -1130,9 +1130,9 @@ var neetoCommons = {
1130
1130
  },
1131
1131
  body: {
1132
1132
  values: {
1133
- embedCode: "<p>Hi,</p> <p>We are going to use {{selectedWidgets}}. Please find the code snippet for the installation of the {{selectedWidgets}} widget. You can find the documentation regarding this at <configureLink>{{neetoKbUrl}}</configureLink>.</p> <p>If you still need help then send an email to <mail>{{helpEmail}}</mail>.</p>",
1134
- userIdentity: "Hey there. This is the object structure that you can use to specify the user identity for neetoWidget. You can find the documentation at - {{userIdentityKbUrl}}.",
1135
- sessionContext: "Hey there. This is the object structure that you can use to specify the contextual values for neetoReplay sessions. You can find the documentation at - {{sessionContextKbUrl}}."
1133
+ embedCode: "<p>Hi,</p> <p>We are going to use {{selectedWidgets}}.</p> <p>Please find the code snippet for the installation of the {{selectedWidgets}} widget.</p> <p>You can find the documentation regarding this at <configureLink>{{neetoKbUrl}}</configureLink>.</p> <p>If you still need help then send an email to <mail>{{helpEmail}}</mail>.</p>",
1134
+ userIdentity: "<p>Hi,</p> <p>This is the object structure that you can use to specify the user identity for neetoWidget.</p> <p>You can find the documentation at <configureLink>{{userIdentityKbUrl}}</configureLink>.</p>",
1135
+ sessionContext: "<p>Hi,</p> <p>This is the object structure that you can use to specify the contextual values for neetoReplay sessions.</p> <p>You can find the documentation at <configureLink>{{sessionContextKbUrl}}</configureLink>.</p>"
1136
1136
  }
1137
1137
  },
1138
1138
  actions: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bigbinary/neeto-commons-frontend",
3
- "version": "2.0.25",
3
+ "version": "2.0.26",
4
4
  "description": "A package encapsulating common code across neeto projects including initializers, utility functions, common components and hooks and so on.",
5
5
  "repository": "git@github.com:bigbinary/neeto-commons-frontend.git",
6
6
  "author": "Amaljith K <amaljith.k@bigbinary.com>",
@@ -16,7 +16,8 @@
16
16
  "initializers.*",
17
17
  "react-utils.*",
18
18
  "utils.*",
19
- "pure.*"
19
+ "pure.*",
20
+ "configs"
20
21
  ],
21
22
  "lint-staged": {
22
23
  "**/*.{js,jsx,json}": [
@@ -39,7 +40,8 @@
39
40
  "./initializers": {
40
41
  "import": "./initializers.js",
41
42
  "require": "./initializers.cjs.js"
42
- }
43
+ },
44
+ "./configs/*": "./configs/*"
43
45
  },
44
46
  "devDependencies": {
45
47
  "@babel/eslint-parser": "^7.18.2",
@@ -60,9 +62,10 @@
60
62
  "@testing-library/react-hooks": "^8.0.0",
61
63
  "@testing-library/user-event": "13.5.0",
62
64
  "antd": "4.18.7",
63
- "autoprefixer": "^10.4.7",
65
+ "autoprefixer": "^10.4.13",
64
66
  "axios": "^0.27.2",
65
67
  "babel-jest": "27.0.6",
68
+ "babel-plugin-transform-react-remove-prop-types": "^0.4.24",
66
69
  "dayjs": "1.11.1",
67
70
  "eslint": "^8.15.0",
68
71
  "eslint-config-prettier": "^8.5.0",
@@ -100,21 +103,26 @@
100
103
  "rollup-plugin-cleaner": "^1.0.0",
101
104
  "rollup-plugin-peer-deps-external": "^2.2.4",
102
105
  "yup": "^0.32.11",
103
- "zustand": "^4.1.2",
104
- "babel-plugin-transform-react-remove-prop-types": "^0.4.24"
106
+ "zustand": "^4.1.2"
105
107
  },
106
108
  "dependencies": {},
107
109
  "peerDependencies": {
108
110
  "@bigbinary/neeto-icons": "^1.8.35",
109
111
  "@bigbinary/neetoui": "^4.1.1",
110
112
  "@honeybadger-io/react": "2.0.1",
113
+ "@svgr/webpack": "^6.5.1",
111
114
  "antd": "4.18.7",
115
+ "autoprefixer": "^10.4.13",
112
116
  "axios": "^0.27.2",
113
117
  "dayjs": "1.11.1",
118
+ "dotenv-webpack": "^8.0.1",
114
119
  "formik": "^2.2.9",
115
120
  "i18next": "21.7.0",
116
121
  "js-logger": "^1.6.1",
117
122
  "mixpanel-browser": "^2.45.0",
123
+ "postcss-flexbugs-fixes": "^5.0.2",
124
+ "postcss-import": "^15.1.0",
125
+ "postcss-preset-env": "^7.8.3",
118
126
  "ramda": "^0.28.0",
119
127
  "react": "^17.0.2",
120
128
  "react-helmet": "^6.1.0",
@@ -122,6 +130,9 @@
122
130
  "react-query": "^3.39.2",
123
131
  "react-router-dom": "^5.2.0",
124
132
  "react-toastify": "^9.0.8",
133
+ "shakapacker": "^6.5.5",
134
+ "tailwindcss": "^3.2.4",
135
+ "webpack": "^5.75.0",
125
136
  "yup": "^0.32.11"
126
137
  }
127
138
  }