@bigbinary/neeto-editor 0.3.38 → 0.3.41

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 @@
1
+ defaults
@@ -0,0 +1 @@
1
+ module.exports = {};
@@ -0,0 +1,11 @@
1
+ module.exports = {
2
+ // Globals can be disabled with the string "off"
3
+ // "writable" to allow the variable to be overwritten or "readonly" to disallow overwriting.
4
+ globals: {
5
+ Atomics: "readonly",
6
+ SharedArrayBuffer: "readonly",
7
+ // Makes logger function available everywhere. Else eslint will complaint of undef-var.
8
+ logger: "readonly",
9
+ module: "writable"
10
+ }
11
+ };
@@ -0,0 +1,52 @@
1
+ const fs = require("fs");
2
+
3
+ const buildPathGroupsBasedOnWebpackAliases = ({
4
+ customJSRoot = "app/javascript/",
5
+ customAliasPath = "config/webpack/alias.js"
6
+ }) => {
7
+ const rootOfProject = __dirname + `/../../`;
8
+
9
+ const isFile = filePath =>
10
+ fs.existsSync(filePath) && fs.lstatSync(filePath).isFile();
11
+
12
+ const webpackAliasPath = rootOfProject + customAliasPath;
13
+
14
+ const hasWebpackAliasConfig = isFile(webpackAliasPath);
15
+
16
+ const isRailsProject = isFile(rootOfProject + "Gemfile");
17
+
18
+ const emptyPathGroups = [];
19
+
20
+ if (!hasWebpackAliasConfig || !isRailsProject) return emptyPathGroups;
21
+
22
+ const {
23
+ resolve: { alias }
24
+ } = require(webpackAliasPath);
25
+
26
+ const railsJSFilesRoot = rootOfProject + customJSRoot;
27
+
28
+ const pathGroups = Object.entries(alias).map(([name, path]) => {
29
+ // sometimes alias might be already resolved to full absolute path
30
+ const isAleadyAnAbsolutePath =
31
+ path.includes("cypress-tests/") || path.includes("app/");
32
+
33
+ const absolutePath = isAleadyAnAbsolutePath
34
+ ? path
35
+ : `${railsJSFilesRoot}${path}`;
36
+ const wildCard =
37
+ isFile(absolutePath + ".js") || isFile(absolutePath + ".jsx")
38
+ ? ""
39
+ : "/**";
40
+
41
+ let group = "internal";
42
+ if (name === "neetoui") {
43
+ group = "external";
44
+ }
45
+
46
+ return { pattern: `${name}${wildCard}`, group };
47
+ });
48
+
49
+ return pathGroups;
50
+ };
51
+
52
+ module.exports = { buildPathGroupsBasedOnWebpackAliases };
@@ -0,0 +1,20 @@
1
+ module.exports = {
2
+ rules: {
3
+ // not-auto-fixable: Prefer a default export if module exports a single name.
4
+ "import/prefer-default-export": "off",
5
+ // not-auto-fixable: Forbid a module from importing a module with a dependency path back to itself.
6
+ "import/no-cycle": ["error", { maxDepth: 1, ignoreExternal: true }],
7
+ // not-auto-fixable: Prevent unnecessary path segments in import and require statements.
8
+ "import/no-useless-path-segments": ["error", { noUselessIndex: true }],
9
+ // not-auto-fixable: Report any invalid exports, i.e. re-export of the same name.
10
+ "import/export": "error",
11
+ // not-auto-fixable: Forbid the use of mutable exports with var or let.
12
+ "import/no-mutable-exports": "error",
13
+ // not-auto-fixable: Ensure all imports appear before other statements.
14
+ "import/first": "error",
15
+ // not-auto-fixable: Ensure all exports appear after other statements.
16
+ "import/exports-last": "error",
17
+ // auto-fixable: Enforce a newline after import statements.
18
+ "import/newline-after-import": ["error", { count: 1 }]
19
+ }
20
+ };
@@ -0,0 +1,65 @@
1
+ const { buildPathGroupsBasedOnWebpackAliases } = require(__dirname +
2
+ "/../helpers");
3
+ const pathGroups = buildPathGroupsBasedOnWebpackAliases({});
4
+
5
+ const pathGroupForKeepingReactImportsAtTop = {
6
+ pattern: "react+(-native|)",
7
+ group: "external",
8
+ position: "before"
9
+ };
10
+
11
+ /*
12
+ Example pathGroups structure. Adding this here
13
+ so that if anyone wants to add custom config,
14
+ they can make use of this:
15
+ [
16
+ { pattern: 'apis/**', group: 'internal' },
17
+ { pattern: 'common/**', group: 'internal' },
18
+ { pattern: 'components/**', group: 'internal' },
19
+ { pattern: 'constants/**', group: 'internal' },
20
+ { pattern: 'contexts/**', group: 'internal' },
21
+ { pattern: 'reducers/**', group: 'internal' },
22
+ { pattern: 'Constants', group: 'internal' },
23
+ { pattern: 'neetoui/**', group: 'external' },
24
+ {
25
+ pattern: 'react+(-native|)',
26
+ group: 'external',
27
+ position: 'before'
28
+ }
29
+ ]
30
+ */
31
+ pathGroups.push(pathGroupForKeepingReactImportsAtTop);
32
+
33
+ module.exports = {
34
+ rules: {
35
+ // auto-fixable: Enforce a convention in module import order - we enforce https://www.bigbinary.com/react-best-practices/sort-import-statements
36
+ "import/order": [
37
+ "error",
38
+ {
39
+ "newlines-between": "always",
40
+ alphabetize: { order: "asc", caseInsensitive: true },
41
+ warnOnUnassignedImports: true,
42
+ groups: [
43
+ "builtin",
44
+ "external",
45
+ "internal",
46
+ "index",
47
+ "sibling",
48
+ "parent",
49
+ "object",
50
+ "type"
51
+ ],
52
+ /*
53
+ * Currently we check for existence of webpack alias
54
+ * config and then iterate over the aliases and create
55
+ * these pathGroups. Only caveat with this mechanism
56
+ * is that in VSCode eslint plugin won't dynamically
57
+ * read it. But eslint cli would!
58
+ */
59
+ pathGroups,
60
+ // Ignore react imports so that they're always ordered to the top of the file.
61
+ pathGroupsExcludedImportTypes: ["react", "react-native"]
62
+ }
63
+ ]
64
+ }
65
+ };
@@ -0,0 +1,24 @@
1
+ module.exports = {
2
+ // Currently we are using this section for excluding certain files from certain rules.
3
+ overrides: [
4
+ {
5
+ files: [
6
+ ".eslintrc.js",
7
+ ".prettierrc.js",
8
+ "app/assets/**/*",
9
+ "app/javascript/packs/**/*",
10
+ "*.json"
11
+ ],
12
+ rules: {
13
+ "import/order": "off",
14
+ "react-hooks/rules-of-hooks": "off"
15
+ }
16
+ },
17
+ {
18
+ files: ["app/javascript/packs/**/*.{js,jsx}"],
19
+ rules: {
20
+ "no-redeclare": "off"
21
+ }
22
+ }
23
+ ]
24
+ };
@@ -0,0 +1,8 @@
1
+ module.exports = {
2
+ rules: {
3
+ // not-auto-fixable: ensure people use async/await promising chaining rather than using "then-catch-finally" statements
4
+ "promise/prefer-await-to-then": "error",
5
+ // auto-fixable: avoid calling "new" on a Promise static method like reject, resolve etc
6
+ "promise/no-new-statics": "error"
7
+ }
8
+ };
@@ -0,0 +1,36 @@
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",
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
+ },
36
+ };
package/.eslintignore ADDED
@@ -0,0 +1,12 @@
1
+ public
2
+ coverage
3
+ db
4
+ docs
5
+ log
6
+ .scripts
7
+ .semaphore
8
+ test
9
+ tmp
10
+ .vscode
11
+ babel.config.js
12
+ app/javascript/packs
package/.eslintrc.js CHANGED
@@ -1,20 +1,38 @@
1
1
  module.exports = {
2
2
  env: {
3
- browser: true,
3
+ browser: true, // window object etc part of browser are made available globally.
4
+ es2020: true, // to include BigInt support
4
5
  es6: true,
6
+ commonjs: true,
7
+ node: true,
5
8
  },
6
- extends: ["eslint:recommended", "plugin:react/recommended"],
9
+ /*
10
+ * The order of extending each plugin matters a LOT!!
11
+ * Thus don't change order of items in this array
12
+ * unless you're sure of it.
13
+ */
14
+ extends: [
15
+ "plugin:cypress/recommended",
16
+ "plugin:json/recommended",
17
+ "eslint:recommended",
18
+ "plugin:react/recommended",
19
+ "./.eslint-rules/globals",
20
+ "./.eslint-rules/imports/order",
21
+ "./.eslint-rules/overrides",
22
+ // ensure that you don't add custom rules
23
+ // without taking permission from team leads.
24
+ "./.eslint-rules/custom",
25
+ // custom rules cannot override the following rules.
26
+ "./.eslint-rules/imports/enforced",
27
+ "./.eslint-rules/react",
28
+ "./.eslint-rules/promise",
29
+ "prettier",
30
+ ],
7
31
  settings: {
8
32
  react: {
9
33
  version: "detect",
10
34
  },
11
35
  },
12
- globals: {
13
- Atomics: "readonly",
14
- SharedArrayBuffer: "readonly",
15
- logger: true,
16
- __dirname: true,
17
- },
18
36
  parserOptions: {
19
37
  ecmaFeatures: {
20
38
  jsx: true,
@@ -22,11 +40,70 @@ module.exports = {
22
40
  ecmaVersion: 2018,
23
41
  sourceType: "module",
24
42
  },
25
- parser: "babel-eslint",
26
- plugins: ["react"],
43
+ // babel-eslint is deprecated now. This is the latest package.
44
+ parser: "@babel/eslint-parser",
45
+ plugins: [
46
+ "react",
47
+ "prettier",
48
+ "import",
49
+ "react-hooks",
50
+ "promise",
51
+ "jam3",
52
+ "unused-imports",
53
+ ],
27
54
  rules: {
28
- semi: ["error", "always"],
55
+ // auto-fixable: Respect all Prettier rules and apply it.
56
+ "prettier/prettier": "error",
57
+ // not-auto-fixable: No unused variables allowed.
58
+ "no-unused-vars": ["error", { argsIgnorePattern: "^_" }],
59
+ // not-auto-fixable: No undefined variables allowed.
60
+ "no-undef": "error",
61
+ // not-auto-fixable: Dont use console statements. Use logger which babel will remove during bundling.
29
62
  "no-console": "error",
30
- "react/prop-types": 0,
63
+ // not-auto-fixable: require `return` statements to either always or never specify values.
64
+ "consistent-return": "error",
65
+ // auto-fixable: sadly this doesn't support guard clauses yet.
66
+ "padding-line-between-statements": [
67
+ "error",
68
+ { blankLine: "always", prev: "if", next: ["if", "return"] },
69
+ ],
70
+ // auto-fixable: Single line statements needn't have any braces. But in all other cases enforce curly braces.
71
+ curly: ["error", "multi-line"],
72
+ // auto-fixable: Remove the else part, if the "if" or "else-if" chain has a return statement
73
+ "no-else-return": "error",
74
+ // not-auto-fixable: Prevent un-sanitized dangerouslySetInnerHTML.
75
+ "jam3/no-sanitizer-with-danger": [
76
+ 2,
77
+ {
78
+ wrapperName: ["dompurify", "sanitizer", "sanitize"],
79
+ },
80
+ ],
81
+ // auto-fixable: Requires trailing commas when the last element or property is in a different line than the closing ] or }
82
+ "comma-dangle": [
83
+ "error",
84
+ {
85
+ arrays: "always-multiline",
86
+ objects: "always-multiline",
87
+ imports: "always-multiline",
88
+ exports: "always-multiline",
89
+ functions: "never",
90
+ },
91
+ ],
92
+ // auto-fixable: If a variable is never reassigned, using the const declaration is better.
93
+ "prefer-const": "error",
94
+ // auto-fixable: It is considered good practice to use the type-safe equality operators === and !==.
95
+ eqeqeq: "error",
96
+ // not-auto-fixable: Rule flags optional chaining expressions in positions where short-circuiting to undefined causes throwing a TypeError afterward.
97
+ "no-unsafe-optional-chaining": "error",
98
+ // auto-fixable: Remove all unused imports.
99
+ "unused-imports/no-unused-imports": "error",
100
+ // auto-fixable-1-level-deep: Using nested ternary operators make the code unreadable. Use if/else or switch with if/else. If it's JSX then move it out into a function or a variable. It's fine to use nestedTernary in JSX when it makes code more readable.
101
+ "no-nested-ternary": "warn",
102
+ // auto-fixable: Enforces no braces where they can be omitted.
103
+ "arrow-body-style": ["error", "as-needed"],
104
+ // auto-fixable: Suggests using template literals instead of string concatenation.
105
+ "prefer-template": "error",
106
+ // auto-fixable: Disallows ternary operators when simpler alternatives exist.
107
+ "no-unneeded-ternary": ["error", { defaultAssignment: false }],
31
108
  },
32
109
  };
package/.node-version ADDED
@@ -0,0 +1 @@
1
+ 16.5
package/.nvmrc ADDED
@@ -0,0 +1 @@
1
+ 16.5
package/.prettierrc.js ADDED
@@ -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,6 @@
1
+ {
2
+ "files.trimTrailingWhitespace": true,
3
+ "files.trimFinalNewlines": true,
4
+ "editor.formatOnSave": true,
5
+ "yaml.format.enable": true
6
+ }
@@ -0,0 +1,15 @@
1
+ module.exports = api => {
2
+ api.cache(true);
3
+ return {
4
+ presets: ["@babel/preset-env", "@babel/preset-react"],
5
+ plugins: ["@babel/plugin-proposal-class-properties"],
6
+ env: {
7
+ production: {
8
+ plugins: [
9
+ "@babel/plugin-proposal-class-properties",
10
+ "@babel/plugin-transform-runtime",
11
+ ],
12
+ },
13
+ },
14
+ };
15
+ };