@adbayb/stack 0.0.0-next-1ee86fc → 0.0.0-next-1dfe647

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,10 @@
1
+ import { cwd } from "node:process";
2
+
3
+ export const CWD = cwd();
4
+
5
+ export const JAVASCRIPT_EXTENSIONS = ["**/*.{js,jsx,cjs,mjs}"];
6
+
7
+ export const JAVASCRIPT_LIKE_EXTENSIONS = [
8
+ ...JAVASCRIPT_EXTENSIONS,
9
+ "**/*.{ts,tsx,cts,mts}",
10
+ ];
@@ -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,27 @@
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
+ export default createConfig(
15
+ // The insertion order is important (last same config items overrides previous ones):
16
+ ...baseConfig,
17
+ ...eslintConfig,
18
+ ...typescriptConfig,
19
+ ...importConfig,
20
+ ...nodeConfig,
21
+ ...sonarConfig,
22
+ ...jsdocConfig,
23
+ ...reactConfig,
24
+ ...testConfig,
25
+ ...uncategorizedConfig,
26
+ ...overridableConfig,
27
+ );
@@ -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,147 @@
1
+ import {
2
+ JAVASCRIPT_EXTENSIONS,
3
+ JAVASCRIPT_LIKE_EXTENSIONS,
4
+ } from "../constants.js";
5
+
6
+ export const config = [
7
+ {
8
+ // Specific ESLint rules for javascript-only files (as they're already handled for TypeScript files by the transpiler):
9
+ // This rule list is taken from https://typescript-eslint.io/users/configs/#recommended
10
+ files: JAVASCRIPT_EXTENSIONS,
11
+ rules: {
12
+ "constructor-super": "error", // ts(2335) & ts(2377)
13
+ "getter-return": "error", // ts(2378)
14
+ "no-const-assign": "error", // ts(2588)
15
+ "no-dupe-args": "error", // ts(2300)
16
+ "no-dupe-class-members": "error", // ts(2393) & ts(2300)
17
+ "no-dupe-keys": "error", // ts(1117)
18
+ "no-func-assign": "error", // ts(2630)
19
+ "no-import-assign": "error", // ts(2632) & ts(2540)
20
+ "no-new-native-nonconstructor": "error", // ts(7009)
21
+ "no-obj-calls": "error", // ts(2349)
22
+ "no-redeclare": "error", // ts(2451)
23
+ "no-setter-return": "error", // ts(2408)
24
+ "no-this-before-super": "error", // ts(2376) & ts(17009)
25
+ "no-undef": "error", // ts(2304) & ts(2552)
26
+ "no-unreachable": "error", // ts(7027)
27
+ "no-unsafe-negation": "error", // ts(2365) & ts(2322) & ts(2358)
28
+ },
29
+ },
30
+ {
31
+ // ESLint rules for JavaScript + TypeScript files:
32
+ files: JAVASCRIPT_LIKE_EXTENSIONS,
33
+ rules: {
34
+ "eqeqeq": "error",
35
+ "for-direction": "error",
36
+ "no-alert": "error",
37
+ "no-async-promise-executor": "error",
38
+ "no-case-declarations": "error",
39
+ "no-class-assign": "error",
40
+ "no-compare-neg-zero": "error",
41
+ "no-cond-assign": "error",
42
+ "no-constant-binary-expression": "error",
43
+ "no-constant-condition": "error",
44
+ "no-control-regex": "error",
45
+ "no-debugger": "error",
46
+ "no-delete-var": "error",
47
+ "no-dupe-else-if": "error",
48
+ "no-duplicate-case": "error",
49
+ "no-empty": "error",
50
+ "no-empty-character-class": "error",
51
+ "no-empty-pattern": "error",
52
+ "no-empty-static-block": "error",
53
+ "no-ex-assign": "error",
54
+ "no-extra-boolean-cast": "error",
55
+ "no-fallthrough": "error",
56
+ "no-global-assign": "error",
57
+ "no-invalid-regexp": "error",
58
+ "no-irregular-whitespace": "error",
59
+ "no-loss-of-precision": "error",
60
+ "no-misleading-character-class": "error",
61
+ "no-nonoctal-decimal-escape": "error",
62
+ "no-octal": "error",
63
+ "no-prototype-builtins": "error",
64
+ "no-regex-spaces": "error",
65
+ "no-restricted-syntax": [
66
+ "error",
67
+ {
68
+ message: "Use undefined instead of null",
69
+ // https://medium.com/@hbarcelos/why-i-banned-null-from-my-js-code-and-why-you-should-too-13df90323cfa
70
+ selector: "Literal[raw='null']",
71
+ },
72
+ ],
73
+ "no-self-assign": "error",
74
+ "no-shadow-restricted-names": "error",
75
+ "no-sparse-arrays": "error",
76
+ "no-unexpected-multiline": "error",
77
+ "no-unsafe-finally": "error",
78
+ "no-unsafe-optional-chaining": "error",
79
+ "no-unused-labels": "error",
80
+ "no-unused-private-class-members": "error",
81
+ "no-useless-backreference": "error",
82
+ "no-useless-catch": "error",
83
+ "no-useless-escape": "error",
84
+ "no-var": "error",
85
+ "no-with": "error",
86
+ "object-shorthand": ["error", "always"],
87
+ "padding-line-between-statements": [
88
+ "error",
89
+ {
90
+ blankLine: "always",
91
+ next: "*",
92
+ prev: "*",
93
+ },
94
+ {
95
+ blankLine: "never",
96
+ next: ["const", "let", "var"],
97
+ prev: ["const", "let", "var"],
98
+ },
99
+ {
100
+ blankLine: "never",
101
+ next: ["case", "default"],
102
+ prev: ["case", "default"],
103
+ },
104
+ {
105
+ blankLine: "always",
106
+ next: ["const", "let", "var"],
107
+ prev: ["multiline-const", "multiline-let", "multiline-var"],
108
+ },
109
+ {
110
+ blankLine: "always",
111
+ next: ["multiline-const", "multiline-let", "multiline-var"],
112
+ prev: ["const", "let", "var"],
113
+ },
114
+ {
115
+ blankLine: "any",
116
+ next: ["expression"],
117
+ prev: ["expression"],
118
+ },
119
+ {
120
+ blankLine: "any",
121
+ next: ["const", "let", "var"],
122
+ prev: ["cjs-import"],
123
+ },
124
+ {
125
+ blankLine: "any",
126
+ next: ["cjs-import", "import"],
127
+ prev: ["cjs-import", "import"],
128
+ },
129
+ {
130
+ blankLine: "any",
131
+ next: ["cjs-export", "export"],
132
+ prev: ["cjs-export", "export"],
133
+ },
134
+ ],
135
+ "prefer-arrow-callback": ["error", { allowNamedFunctions: true }],
136
+ "prefer-const": "error",
137
+ "prefer-rest-params": "error",
138
+ "prefer-spread": "error",
139
+ "prefer-template": "error",
140
+ "require-yield": "error",
141
+ "sort-imports": ["error", { ignoreDeclarationSort: true }],
142
+ "sort-vars": "error",
143
+ "use-isnan": "error",
144
+ "valid-typeof": "error",
145
+ },
146
+ },
147
+ ];
@@ -0,0 +1,71 @@
1
+ import importPlugin from "eslint-plugin-import-x";
2
+
3
+ import { JAVASCRIPT_LIKE_EXTENSIONS } from "../constants.js";
4
+
5
+ export const config = [
6
+ importPlugin.flatConfigs.typescript,
7
+ {
8
+ files: JAVASCRIPT_LIKE_EXTENSIONS,
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,79 @@
1
+ import jsdocPlugin from "eslint-plugin-jsdoc";
2
+
3
+ import { JAVASCRIPT_LIKE_EXTENSIONS } from "../constants.js";
4
+
5
+ export const config = [
6
+ {
7
+ files: JAVASCRIPT_LIKE_EXTENSIONS,
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-blank-blocks": "error",
29
+ "jsdoc/no-defaults": "error",
30
+ "jsdoc/no-multi-asterisks": "error",
31
+ "jsdoc/no-types": "error",
32
+ "jsdoc/require-asterisk-prefix": "error",
33
+ "jsdoc/require-description": "error",
34
+ "jsdoc/require-description-complete-sentence": "error",
35
+ "jsdoc/require-example": "error",
36
+ "jsdoc/require-hyphen-before-param-description": "error",
37
+ "jsdoc/require-jsdoc": [
38
+ // To enable once the rule can be configured to require JSDoc for exported functions at package level (only at module level right now)
39
+ "off",
40
+ {
41
+ contexts: [
42
+ "TSTypeAliasDeclaration",
43
+ "TSInterfaceDeclaration",
44
+ "TSMethodSignature",
45
+ "TSPropertySignature",
46
+ ],
47
+ publicOnly: {
48
+ ancestorsOnly: true,
49
+ cjs: true,
50
+ esm: true,
51
+ },
52
+ require: {
53
+ ArrowFunctionExpression: true,
54
+ ClassDeclaration: true,
55
+ ClassExpression: true,
56
+ FunctionDeclaration: true,
57
+ FunctionExpression: true,
58
+ MethodDefinition: true,
59
+ },
60
+ },
61
+ ],
62
+ "jsdoc/require-param": "error",
63
+ "jsdoc/require-param-description": "error",
64
+ "jsdoc/require-param-name": "error",
65
+ "jsdoc/require-property": "error",
66
+ "jsdoc/require-property-description": "error",
67
+ "jsdoc/require-property-name": "error",
68
+ "jsdoc/require-returns": "error",
69
+ "jsdoc/require-returns-check": "error",
70
+ "jsdoc/require-returns-description": "error",
71
+ "jsdoc/require-throws": "error",
72
+ "jsdoc/require-yields": "error",
73
+ "jsdoc/require-yields-check": "error",
74
+ "jsdoc/sort-tags": "error",
75
+ "jsdoc/tag-lines": "error",
76
+ "jsdoc/valid-types": "error",
77
+ },
78
+ },
79
+ ];
@@ -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_EXTENSIONS } from "../constants.js";
7
+
8
+ export const config = [
9
+ {
10
+ files: JAVASCRIPT_LIKE_EXTENSIONS,
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
+ ];