@adbayb/stack 1.16.0 → 2.0.0

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.
Files changed (111) hide show
  1. package/README.md +36 -41
  2. package/bin/index.js +8 -0
  3. package/configs/eslint/README.md +39 -0
  4. package/configs/eslint/constants.js +10 -0
  5. package/configs/eslint/helpers.js +6 -0
  6. package/configs/eslint/index.js +29 -0
  7. package/configs/eslint/presets/base.js +26 -0
  8. package/configs/eslint/presets/eslint.js +105 -0
  9. package/configs/eslint/presets/import.js +71 -0
  10. package/configs/eslint/presets/jsdoc.js +79 -0
  11. package/configs/eslint/presets/node.js +51 -0
  12. package/configs/eslint/presets/overridable.js +33 -0
  13. package/configs/eslint/presets/react.js +75 -0
  14. package/configs/eslint/presets/sonar.js +225 -0
  15. package/configs/eslint/presets/stylistic.js +69 -0
  16. package/configs/eslint/presets/test.js +59 -0
  17. package/configs/eslint/presets/typescript.js +172 -0
  18. package/configs/eslint/presets/uncategorized.js +34 -0
  19. package/configs/prettier/README.md +65 -0
  20. package/configs/prettier/index.js +25 -0
  21. package/configs/typescript/README.md +46 -0
  22. package/configs/typescript/index.json +35 -0
  23. package/dist/index.js +761 -0
  24. package/package.json +48 -18
  25. package/{template → templates/multi-projects}/.editorconfig +1 -1
  26. package/templates/multi-projects/.github/ISSUE_TEMPLATE/config.yml +4 -0
  27. package/templates/multi-projects/.github/workflows/continuous_delivery.yml +61 -0
  28. package/templates/multi-projects/.github/workflows/continuous_integration.yml +9 -0
  29. package/templates/multi-projects/.github/workflows/conventional_commit.yml +48 -0
  30. package/templates/multi-projects/.github/workflows/dependency_changelog.yml +117 -0
  31. package/templates/multi-projects/.github/workflows/workflow.yml +39 -0
  32. package/templates/multi-projects/.gitignore.tmpl +134 -0
  33. package/templates/multi-projects/.npmrc.tmpl +8 -0
  34. package/templates/multi-projects/applications/README.md +6 -0
  35. package/templates/multi-projects/eslint.config.js.tmpl +1 -0
  36. package/templates/multi-projects/examples/README.md +6 -0
  37. package/{template → templates/multi-projects}/examples/default/package.json.tmpl +2 -2
  38. package/templates/multi-projects/libraries/README.md +3 -0
  39. package/templates/multi-projects/libraries/{{projectName}}/package.json.tmpl +39 -0
  40. package/templates/multi-projects/libraries/{{projectName}}/tsconfig.json +5 -0
  41. package/{template → templates/multi-projects}/package.json.tmpl +4 -3
  42. package/{template → templates/multi-projects}/pnpm-workspace.yaml.tmpl +0 -1
  43. package/{template → templates/multi-projects}/tools/README.md +1 -1
  44. package/templates/multi-projects/tsconfig.json +4 -0
  45. package/{template → templates/multi-projects}/turbo.json +2 -1
  46. package/templates/single-project/.changeset/README.md +8 -0
  47. package/templates/single-project/.changeset/config.json.tmpl +13 -0
  48. package/templates/single-project/.changeset/welcome.md.tmpl +5 -0
  49. package/templates/single-project/.editorconfig +4 -0
  50. package/templates/single-project/.github/ISSUE_TEMPLATE/bug_report.md +34 -0
  51. package/templates/single-project/.github/ISSUE_TEMPLATE/config.yml +4 -0
  52. package/templates/single-project/.github/PULL_REQUEST_TEMPLATE.md.tmpl +29 -0
  53. package/templates/single-project/.github/renovate.json +69 -0
  54. package/templates/single-project/.github/workflows/continuous_delivery.yml +61 -0
  55. package/templates/single-project/.github/workflows/continuous_integration.yml +9 -0
  56. package/templates/single-project/.github/workflows/conventional_commit.yml +48 -0
  57. package/templates/single-project/.github/workflows/dependency_changelog.yml +117 -0
  58. package/templates/single-project/.github/workflows/workflow.yml +39 -0
  59. package/templates/single-project/.gitignore.tmpl +134 -0
  60. package/templates/single-project/.npmrc.tmpl +8 -0
  61. package/templates/single-project/.nvmrc.tmpl +1 -0
  62. package/templates/single-project/.vscode/extensions.json +8 -0
  63. package/templates/single-project/.vscode/settings.json +27 -0
  64. package/templates/single-project/CONTRIBUTING.md.tmpl +21 -0
  65. package/templates/single-project/LICENSE.tmpl +21 -0
  66. package/templates/single-project/eslint.config.js.tmpl +1 -0
  67. package/templates/single-project/examples/README.md +6 -0
  68. package/templates/single-project/examples/default/package.json.tmpl +14 -0
  69. package/templates/single-project/examples/default/src/index.ts.tmpl +3 -0
  70. package/templates/single-project/examples/default/tsconfig.json +5 -0
  71. package/templates/single-project/package.json.tmpl +27 -0
  72. package/templates/single-project/pnpm-workspace.yaml.tmpl +4 -0
  73. package/templates/single-project/tools/README.md +6 -0
  74. package/templates/single-project/tsconfig.json +4 -0
  75. package/templates/single-project/turbo.json +25 -0
  76. package/templates/single-project/{{projectName}}/README.md.tmpl +42 -0
  77. package/{template → templates/single-project}/{{projectName}}/package.json.tmpl +3 -5
  78. package/templates/single-project/{{projectName}}/src/index.test.ts.tmpl +5 -0
  79. package/templates/single-project/{{projectName}}/src/index.ts +1 -0
  80. package/bin/index.cjs +0 -7
  81. package/dist/index.cjs +0 -15
  82. package/dist/index.cjs.map +0 -7
  83. package/template/.commitlintrc.json +0 -3
  84. package/template/.eslintrc.json.tmpl +0 -3
  85. package/template/.github/ISSUE_TEMPLATE/config.yml +0 -4
  86. package/template/.github/workflows/continuous_delivery.yml +0 -49
  87. package/template/.github/workflows/continuous_integration.yml +0 -9
  88. package/template/.github/workflows/conventional_commit.yml +0 -48
  89. package/template/.github/workflows/dependency_changelog.yml +0 -117
  90. package/template/.github/workflows/workflow.yml +0 -96
  91. package/template/applications/README.md +0 -9
  92. package/template/examples/README.md +0 -6
  93. package/template/libraries/README.md +0 -9
  94. package/template/tsconfig.json +0 -3
  95. /package/{template → templates/multi-projects}/.changeset/README.md +0 -0
  96. /package/{template → templates/multi-projects}/.changeset/config.json.tmpl +0 -0
  97. /package/{template → templates/multi-projects}/.changeset/welcome.md.tmpl +0 -0
  98. /package/{template → templates/multi-projects}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
  99. /package/{template → templates/multi-projects}/.github/PULL_REQUEST_TEMPLATE.md.tmpl +0 -0
  100. /package/{template → templates/multi-projects}/.github/renovate.json +0 -0
  101. /package/{template → templates/multi-projects}/.nvmrc.tmpl +0 -0
  102. /package/{template → templates/multi-projects}/.vscode/extensions.json +0 -0
  103. /package/{template → templates/multi-projects}/.vscode/settings.json +0 -0
  104. /package/{template → templates/multi-projects}/CONTRIBUTING.md.tmpl +0 -0
  105. /package/{template → templates/multi-projects}/LICENSE.tmpl +0 -0
  106. /package/{template → templates/multi-projects}/examples/default/src/index.ts.tmpl +0 -0
  107. /package/{template → templates/multi-projects}/examples/default/tsconfig.json +0 -0
  108. /package/{template → templates/multi-projects/libraries}/{{projectName}}/README.md.tmpl +0 -0
  109. /package/{template → templates/multi-projects/libraries}/{{projectName}}/src/index.test.ts.tmpl +0 -0
  110. /package/{template → templates/multi-projects/libraries}/{{projectName}}/src/index.ts +0 -0
  111. /package/{template → templates/single-project}/{{projectName}}/tsconfig.json +0 -0
package/README.md CHANGED
@@ -9,13 +9,13 @@
9
9
 
10
10
  `Stack` allows creating an NPM project in a **quick**, **easy** and **opinionated** way with:
11
11
 
12
- - A unified monorepo-driven and git-driven approach for all kinds of projects (single-purpose library, multiple libraries, application(s), ...)
13
- - Support for several application templates (for now, only a default template is available, but others can be added later)
14
- - Standardized file structure including optional folder creation such as `examples`, `packages`, ...
15
- - Enable all project lifecycle steps with commands from the setup, check, fix, build, and test to the versioning and release
16
- - Built-in configuration preset setup (including Node/NPM runtime, Git ignore/hooks, TypeScript, ESLint, Prettier, EditorConfig, Renovate, Changesets, and VSCode)
17
- - A welcoming environment for users and contributors with the continuous integration setup, and the creation of `README.md`, `CONTRIBUTING.md`, and GitHub template files (including issue and pull request ones), ...
18
- - An optimized development environment with command caching (no build needed if nothing changes)
12
+ - A unified monorepo-driven and git-driven approach for all kinds of projects (single-purpose library, multiple libraries, application(s), ...)
13
+ - Support for several application templates (for now, only a default template is available, but others can be added later)
14
+ - Standardized file structure including optional folder creation such as `examples`, `packages`, ...
15
+ - Enable all project lifecycle steps with commands from the setup, check, fix, build, and test to the versioning and release
16
+ - Built-in configuration preset setup (including Node/NPM runtime, Git ignore/hooks, [TypeScript](https://github.com/adbayb/stack/blob/main/stack/configs/typescript/), [ESLint](https://github.com/adbayb/stack/blob/main/stack/configs/eslint/), [Prettier](https://github.com/adbayb/stack/blob/main/stack/configs/prettier/), EditorConfig, Renovate, Changesets, and VSCode)
17
+ - A welcoming environment for users and contributors with the continuous integration setup, and the creation of `README.md`, `CONTRIBUTING.md`, and GitHub template files (including issue and pull request ones), ...
18
+ - An optimized development environment with command caching (no build needed if nothing changes)
19
19
 
20
20
  <br>
21
21
 
@@ -59,52 +59,47 @@ stack release
59
59
 
60
60
  <br>
61
61
 
62
- ## 🏗️ Architecture
62
+ ## 🌍 Ecosystem
63
63
 
64
- ```mermaid
65
- flowchart TD
66
- N("npm init @adbayb"):::strokeWidth -- Calls --> C("<a href='https://github.com/adbayb/stack/tree/main/packages/create'>@adbayb/create</a>"):::strokeWidth
67
- C -- Uses --> S("<a href='https://github.com/adbayb/stack/tree/main/stack'>@adbayb/stack</a>"):::strokeWidth
68
- S -- "Installs" --> EC("<a href='https://github.com/adbayb/stack/tree/main/packages/eslint-config'>@adbayb/eslint-config</a>"):::strokeWidth
69
- S -- "Installs" --> PC("<a href='https://github.com/adbayb/stack/tree/main/packages/prettier-config'>@adbayb/prettier-config</a>"):::strokeWidth
70
- S -- "Installs" --> TC("<a href='https://github.com/adbayb/stack/tree/main/packages/ts-config'>@adbayb/ts-config</a>"):::strokeWidth
71
- S -- "Scaffolds" --> P("Created project"):::strokeWidth
72
- EC -- "Configures" --> P
73
- PC -- "Configures" --> P
74
- TC -- "Configures" --> P
75
- style C fill:#daf2d7,stroke:#90cf8e
76
- style S fill:#daf2d7,stroke:#90cf8e
77
- style EC fill:#daf2d7,stroke:#90cf8e
78
- style PC fill:#daf2d7,stroke:#90cf8e
79
- style TC fill:#daf2d7,stroke:#90cf8e
80
- classDef strokeWidth stroke-width:3px
81
- ```
64
+ ### Available configurations
82
65
 
83
- <br>
66
+ - [@adbayb/stack/eslint](https://github.com/adbayb/stack/blob/main/stack/configs/eslint/) to align logical and stylistic rules across projects.
67
+ - [@adbayb/stack/prettier](https://github.com/adbayb/stack/blob/main/stack/configs/prettier/) to align code formatting conventions across projects.
68
+ - [@adbayb/stack/typescript](https://github.com/adbayb/stack/blob/main/stack/configs/typescript/) to align type checking and processing across projects.
84
69
 
85
70
  ### Used technologies
86
71
 
87
- - **Static code analysis**: ESLint, Prettier
88
- - **Node package manager**: PNPM
89
- - **Task orchestration**: Turborepo
90
- - **Release**: Changesets
91
- - **Testing**: Vitest
72
+ - **Static code analysis**: ESLint, Prettier
73
+ - **Node package manager**: PNPM
74
+ - **Task orchestration**: Turborepo
75
+ - **Release**: Changesets
76
+ - **Testing**: Vitest
92
77
 
93
78
  ### Used conventions
94
79
 
95
- - [File Structure (inspired by NX)](https://nx.dev/concepts/more-concepts/folder-structure)
96
- - Monorepo-first structure to:
97
- - Keep a consistent file structure pattern across templates (ease template familiarity and onboarding)
98
- - Ease examples setup
99
- - Not clutter the published package with development-related context, metadata, and artifacts
100
- - [Commits](https://www.conventionalcommits.org/)
101
- - [Scripts](https://conventionalscripts.org/)
80
+ - [Commits](https://www.conventionalcommits.org/)
81
+ - [Scripts](https://conventionalscripts.org/)
82
+ - [File Structure](https://nx.dev/concepts/decisions/folder-structure)
83
+ - Monorepo-first structure to:
84
+ - Keep a consistent file structure pattern across templates (ease template familiarity and onboarding).
85
+ - Ease examples setup.
86
+ - Not clutter the published package with development-related context, metadata, and artifacts.
102
87
 
103
88
  <br>
104
89
 
105
- ## 👣 Roadmap
90
+ ## 🏗️ Architecture
91
+
92
+ ### Project creation workflow
106
93
 
107
- - [ ] `stack check`: Lint packages (caret range for dependencies and strict ones for dev dependencies)
94
+ ```mermaid
95
+ flowchart TD
96
+ N("npm init @adbayb"):::strokeWidth -- Runs --> C("@adbayb/create"):::strokeWidth
97
+ C -- Runs --> S("@adbayb/stack create"):::strokeWidth
98
+ S -- "Scaffolds (via template and shared configurations)" --> P("New project"):::strokeWidth
99
+ style C fill:#daf2d7,stroke:#90cf8e
100
+ style S fill:#daf2d7,stroke:#90cf8e
101
+ classDef strokeWidth stroke-width:3px
102
+ ```
108
103
 
109
104
  <br>
110
105
 
package/bin/index.js ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { join } from "node:path";
4
+ import { createRequire } from "node:module";
5
+
6
+ const pkg = createRequire(import.meta.url)("../package.json");
7
+
8
+ import(join("..", pkg.exports["."].default));
@@ -0,0 +1,39 @@
1
+ <br>
2
+ <div align="center">
3
+ <h1>@adbayb/stack/typescript</h1>
4
+ <strong>My opinionated linter standards</strong>
5
+ </div>
6
+ <br>
7
+ <br>
8
+
9
+ ## ✨ Features
10
+
11
+ This package offers opinionated but extensible **[ESLint](https://eslint.org/)** configurations to align logical and stylistic rules across projects.
12
+
13
+ It allows to:
14
+
15
+ - Make collaboration across my projects effective (including onboarding with a consistent look and writing patterns).
16
+ - Include a minimum viable and required set of rules to foster maintainable, testable, secure, and green code over time.
17
+ - Accelerate development by reusing common configuration and convention defaults.
18
+
19
+ <br />
20
+
21
+ ## 🚀 Quick Start
22
+
23
+ ### 1️⃣ Installation
24
+
25
+ At the root level of your project, run the following command:
26
+
27
+ ```bash
28
+ pnpm add @adbayb/stack --save-dev --workspace-root
29
+ ```
30
+
31
+ ### 2️⃣ Usage
32
+
33
+ Create a `eslint.config.js` file and include the following:
34
+
35
+ ```ts
36
+ export { default } from "@adbayb/stack/eslint";
37
+ ```
38
+
39
+ <br />
@@ -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,29 @@
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 stylisticConfig } from "./presets/stylistic.js";
5
+ import { config as sonarConfig } from "./presets/sonar.js";
6
+ import { config as reactConfig } from "./presets/react.js";
7
+ import { config as overridableConfig } from "./presets/overridable.js";
8
+ import { config as nodeConfig } from "./presets/node.js";
9
+ import { config as jsdocConfig } from "./presets/jsdoc.js";
10
+ import { config as importConfig } from "./presets/import.js";
11
+ import { config as eslintConfig } from "./presets/eslint.js";
12
+ import { config as baseConfig } from "./presets/base.js";
13
+ import { createConfig } from "./helpers.js";
14
+
15
+ export default createConfig(
16
+ // The insertion order is important (last same config items overrides previous ones):
17
+ ...baseConfig,
18
+ ...eslintConfig,
19
+ ...typescriptConfig,
20
+ ...importConfig,
21
+ ...jsdocConfig,
22
+ ...nodeConfig,
23
+ ...reactConfig,
24
+ ...sonarConfig,
25
+ ...stylisticConfig,
26
+ ...testConfig,
27
+ ...uncategorizedConfig,
28
+ ...overridableConfig,
29
+ );
@@ -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,105 @@
1
+ import {
2
+ JAVASCRIPT_EXTENSIONS,
3
+ JAVASCRIPT_LIKE_EXTENSIONS,
4
+ } from "../constants.js";
5
+
6
+ export const config = [
7
+ {
8
+ /*
9
+ * Specific ESLint rules for javascript-only files (as they're already handled for TypeScript files by the transpiler):
10
+ * This rule list is taken from https://typescript-eslint.io/users/configs/#recommended
11
+ */
12
+ files: JAVASCRIPT_EXTENSIONS,
13
+ rules: {
14
+ "constructor-super": "error", // ts(2335) & ts(2377)
15
+ "getter-return": "error", // ts(2378)
16
+ "no-const-assign": "error", // ts(2588)
17
+ "no-dupe-args": "error", // ts(2300)
18
+ "no-dupe-class-members": "error", // ts(2393) & ts(2300)
19
+ "no-dupe-keys": "error", // ts(1117)
20
+ "no-func-assign": "error", // ts(2630)
21
+ "no-import-assign": "error", // ts(2632) & ts(2540)
22
+ "no-new-native-nonconstructor": "error", // ts(7009)
23
+ "no-obj-calls": "error", // ts(2349)
24
+ "no-redeclare": "error", // ts(2451)
25
+ "no-setter-return": "error", // ts(2408)
26
+ "no-this-before-super": "error", // ts(2376) & ts(17009)
27
+ "no-undef": "error", // ts(2304) & ts(2552)
28
+ "no-unreachable": "error", // ts(7027)
29
+ "no-unsafe-negation": "error", // ts(2365) & ts(2322) & ts(2358)
30
+ },
31
+ },
32
+ {
33
+ // ESLint rules for JavaScript + TypeScript files:
34
+ files: JAVASCRIPT_LIKE_EXTENSIONS,
35
+ rules: {
36
+ "eqeqeq": "error",
37
+ "for-direction": "error",
38
+ "no-alert": "error",
39
+ "no-async-promise-executor": "error",
40
+ "no-case-declarations": "error",
41
+ "no-class-assign": "error",
42
+ "no-compare-neg-zero": "error",
43
+ "no-cond-assign": "error",
44
+ "no-constant-binary-expression": "error",
45
+ "no-constant-condition": "error",
46
+ "no-control-regex": "error",
47
+ "no-debugger": "error",
48
+ "no-delete-var": "error",
49
+ "no-dupe-else-if": "error",
50
+ "no-duplicate-case": "error",
51
+ "no-empty": "error",
52
+ "no-empty-character-class": "error",
53
+ "no-empty-pattern": "error",
54
+ "no-empty-static-block": "error",
55
+ "no-ex-assign": "error",
56
+ "no-extra-boolean-cast": "error",
57
+ "no-fallthrough": "error",
58
+ "no-global-assign": "error",
59
+ "no-invalid-regexp": "error",
60
+ "no-irregular-whitespace": "error",
61
+ "no-loss-of-precision": "error",
62
+ "no-misleading-character-class": "error",
63
+ "no-nonoctal-decimal-escape": "error",
64
+ "no-octal": "error",
65
+ "no-prototype-builtins": "error",
66
+ "no-regex-spaces": "error",
67
+ "no-restricted-syntax": [
68
+ "error",
69
+ // https://medium.com/@hbarcelos/why-i-banned-null-from-my-js-code-and-why-you-should-too-13df90323cfa
70
+ {
71
+ message: "Use undefined instead of null",
72
+ selector: "VariableDeclarator > Literal[raw='null']",
73
+ },
74
+ {
75
+ message: "Use undefined instead of null",
76
+ selector: "AssignmentExpression > Literal[raw='null']",
77
+ },
78
+ ],
79
+ "no-self-assign": "error",
80
+ "no-shadow-restricted-names": "error",
81
+ "no-sparse-arrays": "error",
82
+ "no-unexpected-multiline": "error",
83
+ "no-unsafe-finally": "error",
84
+ "no-unsafe-optional-chaining": "error",
85
+ "no-unused-labels": "error",
86
+ "no-unused-private-class-members": "error",
87
+ "no-useless-backreference": "error",
88
+ "no-useless-catch": "error",
89
+ "no-useless-escape": "error",
90
+ "no-var": "error",
91
+ "no-with": "error",
92
+ "object-shorthand": ["error", "always"],
93
+ "prefer-arrow-callback": ["error", { allowNamedFunctions: true }],
94
+ "prefer-const": "error",
95
+ "prefer-rest-params": "error",
96
+ "prefer-spread": "error",
97
+ "prefer-template": "error",
98
+ "require-yield": "error",
99
+ "sort-imports": ["error", { ignoreDeclarationSort: true }],
100
+ "sort-vars": "error",
101
+ "use-isnan": "error",
102
+ "valid-typeof": "error",
103
+ },
104
+ },
105
+ ];
@@ -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", "ENVIRONMENT"],
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,33 @@
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
+ "**/.configs/**",
14
+ "**/config/**",
15
+ "**/configs/**",
16
+ "**/examples/**",
17
+ "**/scripts/**",
18
+ "**/website/**",
19
+ "**/config.{js,ts,cjs,cts,mjs,mts}",
20
+ "**/*.config.{js,ts,cjs,cts,mjs,mts}",
21
+ "**/stories.{js,ts,jsx,tsx,cjs,cts,mjs,mts}",
22
+ "**/*.stories.{js,ts,jsx,tsx,cjs,cts,mjs,mts}",
23
+ "**/test.{js,ts,jsx,tsx,cjs,cts,mjs,mts}",
24
+ "**/*.test.{js,ts,jsx,tsx,cjs,cts,mjs,mts}",
25
+ ],
26
+ rules: {
27
+ "import-x/no-anonymous-default-export": "off",
28
+ "import-x/no-default-export": "off",
29
+ "sonarjs/sonar-no-magic-numbers": "off",
30
+ },
31
+ },
32
+ eslintPluginPrettierRecommended,
33
+ ];
@@ -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
+ ];