@adbayb/stack 0.0.0-next-1ee86fc → 0.0.0-next-730a06d

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,5 @@
1
+ import { cwd } from "node:process";
2
+
3
+ export const CWD = cwd();
4
+
5
+ export const JAVASCRIPT_LIKE_FILES = ["**/*.{js,ts,jsx,tsx,cjs,cts,mjs,mts}"];
@@ -0,0 +1,6 @@
1
+ import { createRequire } from "node:module";
2
+
3
+ import tseslint from "typescript-eslint";
4
+
5
+ export const require = createRequire(import.meta.url);
6
+ export const createConfig = tseslint.config;
@@ -0,0 +1,33 @@
1
+ import { config as uncategorizedConfig } from "./presets/uncategorized.js";
2
+ import { config as typescriptConfig } from "./presets/typescript.js";
3
+ import { config as testConfig } from "./presets/test.js";
4
+ import { config as sonarConfig } from "./presets/sonar.js";
5
+ import { config as reactConfig } from "./presets/react.js";
6
+ import { config as overridableConfig } from "./presets/overridable.js";
7
+ import { config as nodeConfig } from "./presets/node.js";
8
+ import { config as jsdocConfig } from "./presets/jsdoc.js";
9
+ import { config as importConfig } from "./presets/import.js";
10
+ import { config as eslintConfig } from "./presets/eslint.js";
11
+ import { config as baseConfig } from "./presets/base.js";
12
+ import { createConfig } from "./helpers.js";
13
+
14
+ /**
15
+ * TODO:
16
+ * - Review TS rules: attempt to include all rules from https://typescript-eslint.io/users/configs/#strict-type-checked and https://typescript-eslint.io/users/configs/#stylistic-type-checked ?
17
+ * - Review JSDoc rules.
18
+ */
19
+
20
+ export default createConfig(
21
+ // The insertion order is important (last same config items overrides previous ones):
22
+ ...baseConfig,
23
+ ...eslintConfig,
24
+ ...typescriptConfig,
25
+ ...importConfig,
26
+ ...nodeConfig,
27
+ ...sonarConfig,
28
+ ...jsdocConfig,
29
+ ...reactConfig,
30
+ ...testConfig,
31
+ ...uncategorizedConfig,
32
+ ...overridableConfig,
33
+ );
@@ -0,0 +1,26 @@
1
+ import { resolve } from "node:path";
2
+
3
+ import globals from "globals";
4
+ import { includeIgnoreFile } from "@eslint/compat";
5
+
6
+ import { CWD } from "../constants.js";
7
+
8
+ export const config = [
9
+ {
10
+ languageOptions: {
11
+ ecmaVersion: "latest",
12
+ globals: {
13
+ ...globals.browser,
14
+ ...globals.node,
15
+ ...globals.worker,
16
+ },
17
+ parserOptions: {
18
+ ecmaFeatures: {
19
+ jsx: true,
20
+ },
21
+ },
22
+ sourceType: "module",
23
+ },
24
+ },
25
+ includeIgnoreFile(resolve(CWD, ".gitignore")),
26
+ ];
@@ -0,0 +1,135 @@
1
+ import { JAVASCRIPT_LIKE_FILES } from "../constants.js";
2
+
3
+ export const config = [
4
+ {
5
+ files: JAVASCRIPT_LIKE_FILES,
6
+ rules: {
7
+ "constructor-super": "error",
8
+ "eqeqeq": "error",
9
+ "for-direction": "error",
10
+ "getter-return": "error",
11
+ "no-alert": "error",
12
+ "no-async-promise-executor": "error",
13
+ "no-case-declarations": "error",
14
+ "no-class-assign": "error",
15
+ "no-compare-neg-zero": "error",
16
+ "no-cond-assign": "error",
17
+ "no-const-assign": "error",
18
+ "no-constant-binary-expression": "error",
19
+ "no-constant-condition": "error",
20
+ "no-control-regex": "error",
21
+ "no-debugger": "error",
22
+ "no-delete-var": "error",
23
+ "no-dupe-args": "error",
24
+ "no-dupe-else-if": "error",
25
+ "no-dupe-keys": "error",
26
+ "no-duplicate-case": "error",
27
+ "no-empty": "error",
28
+ "no-empty-character-class": "error",
29
+ "no-empty-pattern": "error",
30
+ "no-empty-static-block": "error",
31
+ "no-ex-assign": "error",
32
+ "no-extra-boolean-cast": "error",
33
+ "no-fallthrough": "error",
34
+ "no-func-assign": "error",
35
+ "no-global-assign": "error",
36
+ "no-import-assign": "error",
37
+ "no-invalid-regexp": "error",
38
+ "no-irregular-whitespace": "error",
39
+ "no-loss-of-precision": "error",
40
+ "no-misleading-character-class": "error",
41
+ "no-new-native-nonconstructor": "error",
42
+ "no-nonoctal-decimal-escape": "error",
43
+ "no-obj-calls": "error",
44
+ "no-octal": "error",
45
+ "no-prototype-builtins": "error",
46
+ "no-redeclare": "error",
47
+ "no-regex-spaces": "error",
48
+ "no-restricted-syntax": [
49
+ "error",
50
+ {
51
+ message: "Use undefined instead of null",
52
+ // https://medium.com/@hbarcelos/why-i-banned-null-from-my-js-code-and-why-you-should-too-13df90323cfa
53
+ selector: "Literal[raw='null']",
54
+ },
55
+ ],
56
+ "no-self-assign": "error",
57
+ "no-setter-return": "error",
58
+ "no-shadow-restricted-names": "error",
59
+ "no-sparse-arrays": "error",
60
+ "no-this-before-super": "error",
61
+ "no-undef": "error",
62
+ "no-unexpected-multiline": "error",
63
+ "no-unreachable": "error",
64
+ "no-unsafe-finally": "error",
65
+ "no-unsafe-negation": "error",
66
+ "no-unsafe-optional-chaining": "error",
67
+ "no-unused-labels": "error",
68
+ "no-unused-private-class-members": "error",
69
+ "no-useless-backreference": "error",
70
+ "no-useless-catch": "error",
71
+ "no-useless-escape": "error",
72
+ "no-var": "error",
73
+ "no-with": "error",
74
+ "object-shorthand": ["error", "always"],
75
+ "padding-line-between-statements": [
76
+ "error",
77
+ {
78
+ blankLine: "always",
79
+ next: "*",
80
+ prev: "*",
81
+ },
82
+ {
83
+ blankLine: "never",
84
+ next: ["const", "let", "var"],
85
+ prev: ["const", "let", "var"],
86
+ },
87
+ {
88
+ blankLine: "never",
89
+ next: ["case", "default"],
90
+ prev: ["case", "default"],
91
+ },
92
+ {
93
+ blankLine: "always",
94
+ next: ["const", "let", "var"],
95
+ prev: ["multiline-const", "multiline-let", "multiline-var"],
96
+ },
97
+ {
98
+ blankLine: "always",
99
+ next: ["multiline-const", "multiline-let", "multiline-var"],
100
+ prev: ["const", "let", "var"],
101
+ },
102
+ {
103
+ blankLine: "any",
104
+ next: ["expression"],
105
+ prev: ["expression"],
106
+ },
107
+ {
108
+ blankLine: "any",
109
+ next: ["const", "let", "var"],
110
+ prev: ["cjs-import"],
111
+ },
112
+ {
113
+ blankLine: "any",
114
+ next: ["cjs-import", "import"],
115
+ prev: ["cjs-import", "import"],
116
+ },
117
+ {
118
+ blankLine: "any",
119
+ next: ["cjs-export", "export"],
120
+ prev: ["cjs-export", "export"],
121
+ },
122
+ ],
123
+ "prefer-arrow-callback": ["error", { allowNamedFunctions: true }],
124
+ "prefer-const": "error",
125
+ "prefer-rest-params": "error",
126
+ "prefer-spread": "error",
127
+ "prefer-template": "error",
128
+ "require-yield": "error",
129
+ "sort-imports": ["error", { ignoreDeclarationSort: true }],
130
+ "sort-vars": "error",
131
+ "use-isnan": "error",
132
+ "valid-typeof": "error",
133
+ },
134
+ },
135
+ ];
@@ -0,0 +1,71 @@
1
+ import importPlugin from "eslint-plugin-import-x";
2
+
3
+ import { JAVASCRIPT_LIKE_FILES } from "../constants.js";
4
+
5
+ export const config = [
6
+ importPlugin.flatConfigs.typescript,
7
+ {
8
+ files: JAVASCRIPT_LIKE_FILES,
9
+ plugins: {
10
+ "import-x": importPlugin,
11
+ },
12
+ rules: {
13
+ "import-x/consistent-type-specifier-style": ["error", "prefer-top-level"],
14
+ "import-x/export": "error",
15
+ "import-x/first": "error",
16
+ "import-x/newline-after-import": "error",
17
+ "import-x/no-absolute-path": "error",
18
+ "import-x/no-amd": "error",
19
+ "import-x/no-anonymous-default-export": "error",
20
+ "import-x/no-commonjs": "error",
21
+ "import-x/no-cycle": "error",
22
+ "import-x/no-default-export": "error",
23
+ "import-x/no-deprecated": "error",
24
+ "import-x/no-duplicates": "error",
25
+ "import-x/no-empty-named-blocks": "error",
26
+ "import-x/no-extraneous-dependencies": "error",
27
+ "import-x/no-import-module-exports": "error",
28
+ "import-x/no-mutable-exports": "error",
29
+ "import-x/no-named-default": "error",
30
+ "import-x/no-namespace": "error",
31
+ "import-x/no-relative-packages": "error",
32
+ "import-x/no-self-import": "error",
33
+ "import-x/no-unassigned-import": "error",
34
+ "import-x/no-unused-modules": "error",
35
+ "import-x/no-useless-path-segments": [
36
+ "error",
37
+ {
38
+ commonjs: true,
39
+ noUselessIndex: true,
40
+ },
41
+ ],
42
+ "import-x/no-webpack-loader-syntax": "error",
43
+ "import-x/order": [
44
+ "error",
45
+ {
46
+ "alphabetize": {
47
+ caseInsensitive: false,
48
+ order: "desc",
49
+ orderImportKind: "desc",
50
+ },
51
+ "groups": [
52
+ "builtin",
53
+ "external",
54
+ "internal",
55
+ ["parent", "sibling", "index"],
56
+ "object",
57
+ "unknown",
58
+ ],
59
+ "newlines-between": "always",
60
+ },
61
+ ],
62
+ "import-x/unambiguous": "error",
63
+ },
64
+ settings: {
65
+ "import-x/resolver": {
66
+ node: true,
67
+ typescript: true,
68
+ },
69
+ },
70
+ },
71
+ ];
@@ -0,0 +1,78 @@
1
+ import jsdocPlugin from "eslint-plugin-jsdoc";
2
+
3
+ import { JAVASCRIPT_LIKE_FILES } from "../constants.js";
4
+
5
+ export const config = [
6
+ {
7
+ files: JAVASCRIPT_LIKE_FILES,
8
+ plugins: {
9
+ jsdoc: jsdocPlugin,
10
+ },
11
+ rules: {
12
+ "jsdoc/check-access": "error",
13
+ "jsdoc/check-alignment": "error",
14
+ "jsdoc/check-examples": "off", // To enable once ESLint >= 8.x is supported
15
+ "jsdoc/check-indentation": "error",
16
+ "jsdoc/check-line-alignment": "error",
17
+ "jsdoc/check-param-names": "error",
18
+ "jsdoc/check-property-names": "error",
19
+ "jsdoc/check-syntax": "error",
20
+ "jsdoc/check-tag-names": "error",
21
+ "jsdoc/check-types": "error",
22
+ "jsdoc/check-values": "error",
23
+ "jsdoc/empty-tags": "error",
24
+ "jsdoc/implements-on-classes": "error",
25
+ "jsdoc/multiline-blocks": "error",
26
+ "jsdoc/no-bad-blocks": "error",
27
+ "jsdoc/no-blank-block-descriptions": "error",
28
+ "jsdoc/no-defaults": "error",
29
+ "jsdoc/no-multi-asterisks": "error",
30
+ "jsdoc/no-types": "error",
31
+ "jsdoc/require-asterisk-prefix": "error",
32
+ "jsdoc/require-description": "error",
33
+ "jsdoc/require-description-complete-sentence": "error",
34
+ "jsdoc/require-example": "error",
35
+ "jsdoc/require-hyphen-before-param-description": "error",
36
+ "jsdoc/require-jsdoc": [
37
+ // To enable once the rule can be configured to require JSDoc for exported functions at package level (only at module level right now)
38
+ "off",
39
+ {
40
+ contexts: [
41
+ "TSTypeAliasDeclaration",
42
+ "TSInterfaceDeclaration",
43
+ "TSMethodSignature",
44
+ "TSPropertySignature",
45
+ ],
46
+ publicOnly: {
47
+ ancestorsOnly: true,
48
+ cjs: true,
49
+ esm: true,
50
+ },
51
+ require: {
52
+ ArrowFunctionExpression: true,
53
+ ClassDeclaration: true,
54
+ ClassExpression: true,
55
+ FunctionDeclaration: true,
56
+ FunctionExpression: true,
57
+ MethodDefinition: true,
58
+ },
59
+ },
60
+ ],
61
+ "jsdoc/require-param": "error",
62
+ "jsdoc/require-param-description": "error",
63
+ "jsdoc/require-param-name": "error",
64
+ "jsdoc/require-property": "error",
65
+ "jsdoc/require-property-description": "error",
66
+ "jsdoc/require-property-name": "error",
67
+ "jsdoc/require-returns": "error",
68
+ "jsdoc/require-returns-check": "error",
69
+ "jsdoc/require-returns-description": "error",
70
+ "jsdoc/require-throws": "error",
71
+ "jsdoc/require-yields": "error",
72
+ "jsdoc/require-yields-check": "error",
73
+ "jsdoc/sort-tags": "error",
74
+ "jsdoc/tag-lines": "error",
75
+ "jsdoc/valid-types": "error",
76
+ },
77
+ },
78
+ ];
@@ -0,0 +1,51 @@
1
+ import { join } from "node:path";
2
+
3
+ import nodePlugin from "eslint-plugin-n";
4
+
5
+ import { require } from "../helpers.js";
6
+ import { CWD, JAVASCRIPT_LIKE_FILES } from "../constants.js";
7
+
8
+ export const config = [
9
+ {
10
+ files: JAVASCRIPT_LIKE_FILES,
11
+ plugins: {
12
+ n: nodePlugin,
13
+ },
14
+ rules: {
15
+ "n/callback-return": "error",
16
+ "n/exports-style": ["error", "module.exports"],
17
+ "n/hashbang": "error",
18
+ "n/no-exports-assign": "error",
19
+ "n/no-path-concat": "error",
20
+ "n/no-process-env": [
21
+ "error",
22
+ {
23
+ allowedVariables: ["NODE_ENV"],
24
+ },
25
+ ],
26
+ "n/no-unpublished-bin": "error",
27
+ "n/no-unsupported-features/es-builtins": "error",
28
+ "n/no-unsupported-features/es-syntax": "error",
29
+ "n/no-unsupported-features/node-builtins": [
30
+ "error",
31
+ { allowExperimental: true },
32
+ ],
33
+ "n/prefer-global/buffer": ["error", "never"],
34
+ "n/prefer-global/console": ["error", "always"],
35
+ "n/prefer-global/process": ["error", "never"],
36
+ "n/prefer-global/text-decoder": ["error", "always"],
37
+ "n/prefer-global/text-encoder": ["error", "always"],
38
+ "n/prefer-global/url": ["error", "always"],
39
+ "n/prefer-global/url-search-params": ["error", "always"],
40
+ "n/prefer-node-protocol": "error",
41
+ "n/prefer-promises/dns": "error",
42
+ "n/prefer-promises/fs": "error",
43
+ "n/process-exit-as-throw": "error",
44
+ },
45
+ settings: {
46
+ node: {
47
+ version: require(join(CWD, "package.json")).engines.node,
48
+ },
49
+ },
50
+ },
51
+ ];
@@ -0,0 +1,31 @@
1
+ import tseslint from "typescript-eslint";
2
+ import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended";
3
+
4
+ export const config = [
5
+ {
6
+ files: ["**/*.{js,jsx,cjs,mjs}"],
7
+ ...tseslint.configs.disableTypeChecked,
8
+ },
9
+ {
10
+ // Relaxed rules for example-like folder, and [config-, story-, and test]-like files
11
+ files: [
12
+ "**/.config/**",
13
+ "**/config/**",
14
+ "**/examples/**",
15
+ "**/scripts/**",
16
+ "**/website/**",
17
+ "**/config.{js,ts,cjs,cts,mjs,mts}",
18
+ "**/*.config.{js,ts,cjs,cts,mjs,mts}",
19
+ "**/stories.{js,ts,jsx,tsx,cjs,cts,mjs,mts}",
20
+ "**/*.stories.{js,ts,jsx,tsx,cjs,cts,mjs,mts}",
21
+ "**/test.{js,ts,jsx,tsx,cjs,cts,mjs,mts}",
22
+ "**/*.test.{js,ts,jsx,tsx,cjs,cts,mjs,mts}",
23
+ ],
24
+ rules: {
25
+ "import-x/no-anonymous-default-export": "off",
26
+ "import-x/no-default-export": "off",
27
+ "sonarjs/sonar-no-magic-numbers": "off",
28
+ },
29
+ },
30
+ eslintPluginPrettierRecommended,
31
+ ];
@@ -0,0 +1,75 @@
1
+ import reactHooksPlugin from "eslint-plugin-react-hooks";
2
+ import reactPlugin from "eslint-plugin-react";
3
+
4
+ export const config = [
5
+ {
6
+ files: ["**/*.{jsx,tsx}"],
7
+ plugins: {
8
+ "react": reactPlugin,
9
+ "react-hooks": reactHooksPlugin,
10
+ },
11
+ rules: {
12
+ "react-hooks/exhaustive-deps": "warn",
13
+ "react-hooks/rules-of-hooks": "error",
14
+ "react/boolean-prop-naming": [
15
+ "error",
16
+ { rule: "^(is|has)[A-Z]([A-Za-z0-9]?)+" },
17
+ ],
18
+ "react/button-has-type": "error",
19
+ "react/checked-requires-onchange-or-readonly": "error",
20
+ "react/display-name": "error",
21
+ "react/forbid-component-props": "error",
22
+ "react/forward-ref-uses-ref": "error",
23
+ "react/hook-use-state": "error",
24
+ "react/iframe-missing-sandbox": "error",
25
+ "react/jsx-boolean-value": "error",
26
+ "react/jsx-fragments": "error",
27
+ "react/jsx-handler-names": "error",
28
+ "react/jsx-key": "error",
29
+ "react/jsx-no-bind": "error",
30
+ "react/jsx-no-constructed-context-values": "error",
31
+ "react/jsx-no-leaked-render": "error",
32
+ "react/jsx-no-script-url": "error",
33
+ "react/jsx-no-target-blank": "error",
34
+ "react/jsx-no-useless-fragment": "error",
35
+ "react/jsx-pascal-case": "error",
36
+ "react/jsx-props-no-spread-multi": "error",
37
+ "react/jsx-sort-props": "error",
38
+ "react/jsx-uses-react": "error",
39
+ "react/jsx-uses-vars": "error",
40
+ "react/no-access-state-in-setstate": "error",
41
+ "react/no-array-index-key": "error",
42
+ "react/no-arrow-function-lifecycle": "error",
43
+ "react/no-children-prop": "error",
44
+ "react/no-danger-with-children": "error",
45
+ "react/no-did-mount-set-state": "error",
46
+ "react/no-did-update-set-state": "error",
47
+ "react/no-direct-mutation-state": "error",
48
+ "react/no-find-dom-node": "error",
49
+ "react/no-is-mounted": "error",
50
+ "react/no-namespace": "error",
51
+ "react/no-object-type-as-default-prop": "error",
52
+ "react/no-redundant-should-component-update": "error",
53
+ "react/no-render-return-value": "error",
54
+ "react/no-string-refs": "error",
55
+ "react/no-this-in-sfc": "error",
56
+ "react/no-typos": "error",
57
+ "react/no-unescaped-entities": "error",
58
+ "react/no-unsafe": "error",
59
+ "react/no-unstable-nested-components": "error",
60
+ "react/no-unused-class-component-methods": "error",
61
+ "react/no-unused-state": "error",
62
+ "react/no-will-update-set-state": "error",
63
+ "react/prefer-read-only-props": "error",
64
+ "react/prefer-stateless-function": "error",
65
+ "react/self-closing-comp": "error",
66
+ "react/style-prop-object": "error",
67
+ "react/void-dom-elements-no-children": "error",
68
+ },
69
+ settings: {
70
+ react: {
71
+ version: "detect",
72
+ },
73
+ },
74
+ },
75
+ ];