@peerigon/configs 7.0.2 → 7.1.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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ # [7.1.0](https://github.com/peerigon/configs/compare/v7.0.2...v7.1.0) (2025-08-20)
2
+
3
+ ### Features
4
+
5
+ - Add rules and instructions for AI coding agents ([#146](https://github.com/peerigon/configs/issues/146)) ([4fda35c](https://github.com/peerigon/configs/commit/4fda35c49ee8fe92559a88ffacc4dbce198fb32c)), closes [/#diff-31d17094bc63f56f4b4cc27a6e7d78e7b0a33b2a7d810f06a77f5f5814a32223R1-R77](https://github.com///issues/diff-31d17094bc63f56f4b4cc27a6e7d78e7b0a33b2a7d810f06a77f5f5814a32223R1-R77) [/#diff-687239070a6068b383fc9aab0bfacfc80b3ff2c1df6055e7f0273328b597e6d0R1-R160](https://github.com///issues/diff-687239070a6068b383fc9aab0bfacfc80b3ff2c1df6055e7f0273328b597e6d0R1-R160) [/#diff-f8bfdc4142ab84261ba9c23bfc9afeff1f98ee71da689ef951311cd54130f928R1-R14](https://github.com///issues/diff-f8bfdc4142ab84261ba9c23bfc9afeff1f98ee71da689ef951311cd54130f928R1-R14) [/#diff-97953bd7f578928372e273b64f032d3bb832202e334ea65cc2926ae1c3c27534R1-R17](https://github.com///issues/diff-97953bd7f578928372e273b64f032d3bb832202e334ea65cc2926ae1c3c27534R1-R17) [/#diff-5193a148ebdd2baf23b4f0a1c1add7ea02a8b92fb022e3a5780e886509d06693L25-R25](https://github.com///issues/diff-5193a148ebdd2baf23b4f0a1c1add7ea02a8b92fb022e3a5780e886509d06693L25-R25) [/#diff-7ae45ad102eab3b6d7e7896acd08c427a9b25b346470d7bc6507b6481575d519R44](https://github.com///issues/diff-7ae45ad102eab3b6d7e7896acd08c427a9b25b346470d7bc6507b6481575d519R44)
6
+
1
7
  ## [7.0.2](https://github.com/peerigon/configs/compare/v7.0.1...v7.0.2) (2025-08-05)
2
8
 
3
9
  ### Bug Fixes
package/README.md CHANGED
@@ -22,6 +22,16 @@ Also checkout the instructions for each respective config:
22
22
  - [Semantic release](/semantic-release/README.md)
23
23
  - [VSCode](/.vscode/README.md)
24
24
 
25
+ ### AI
26
+
27
+ Furthermore, this package also contains [rules and instructions for AI coding agents](./ai/README.md) that are based on the configurations.
28
+
29
+ If you want your AI coding agent to stick to our configs and coding principles, put this in your project-specific rules file (like `CLAUDE.md`, `.cursor/rules.mdc`, etc.):
30
+
31
+ ```md
32
+ **Important**: You **must** follow [these rules](./node_modules/@peerigon/configs/ai/rules.mdc) and its language-specific rules referenced in that file.
33
+ ```
34
+
25
35
  ## Philosophy
26
36
 
27
37
  Linting, formatting and type-checking rules are always a balance between:
package/ai/README.md ADDED
@@ -0,0 +1,17 @@
1
+ # AI
2
+
3
+ Contains resources and styleguides for coding agents.
4
+
5
+ ## Coding agent rules
6
+
7
+ [`rules.mdc`](./rules.mdc) contains Peerigon's universal coding principles and links to language-specific guides.
8
+
9
+ Put this in your project-specific rules file (like `CLAUDE.md`, `.cursor/rules.mdc`, etc.):
10
+
11
+ ```md
12
+ **Important**: You **must** follow [these rules](./node_modules/@peerigon/configs/ai/rules.mdc) and its language-specific rules referenced in that file.
13
+ ```
14
+
15
+ ## Migration Guide
16
+
17
+ [`migrate-to.md`](./migrate-to.md) provides step-by-step instructions for coding agents for migrating projects to use `@peerigon/configs`.
@@ -0,0 +1,160 @@
1
+ ---
2
+ description: HTML and CSS best practices with accessibility focus
3
+ globs: **/*.html, **/*.htm, **/*.css, **/*.scss, **/*.sass, **/*.less, **/*.tsx, **/*.jsx, **/*.vue
4
+ ---
5
+
6
+ # HTML & CSS
7
+
8
+ ## HTML
9
+
10
+ ### Semantic Elements
11
+
12
+ Use semantic elements like `header`, `nav`, `main`, `article`, `section`, `aside`, `footer`, `figure`, `time` when content has inherent meaning:
13
+
14
+ ```html
15
+ <article>
16
+ <h1>Breaking News</h1>
17
+ <time datetime="2025-01-15">January 15, 2025</time>
18
+ </article>
19
+ ```
20
+
21
+ ### Form Labels
22
+
23
+ Every input requires an associated label. Prefer wrapping the `input` with `label`. Otherwise use `for`/`id` (when using React, call `useId()`):
24
+
25
+ ```html
26
+ <!-- Good -->
27
+ <label for="user-email">Email Address</label>
28
+ <input type="email" id="user-email" name="email" />
29
+
30
+ <!-- Better -->
31
+ <label>
32
+ Email Address:
33
+ <input type="email" name="email" />
34
+ </label>
35
+ ```
36
+
37
+ ### Buttons vs. Links
38
+
39
+ Use buttons for actions, links for navigation:
40
+
41
+ ```html
42
+ <button type="button" onclick="saveData()">Save</button>
43
+ <a href="/next">Next</a>
44
+ ```
45
+
46
+ ### Image Alt Text
47
+
48
+ Provide descriptive alt text for content images, empty alt for decorative images:
49
+
50
+ ```html
51
+ <img src="chart.png" alt="Sales increased 23% in Q4 2024" />
52
+ <img src="decoration.png" alt="" />
53
+ ```
54
+
55
+ ## CSS
56
+
57
+ ### Selectors and naming
58
+
59
+ Use purpose-based named classes for styling with a maximum of 3 levels specificity.
60
+
61
+ ```css
62
+ .site-header {
63
+ }
64
+ .card {
65
+ }
66
+ .error-message {
67
+ }
68
+ .feature-highlight {
69
+ }
70
+ ```
71
+
72
+ Check what styling solution (CSS Modules, BEM, Tailwind, ...) is used in the project and follow its conventions.
73
+
74
+ ### Units
75
+
76
+ Use typography units like `rem`, `ch`, ... for typography-related spacing:
77
+
78
+ ```css
79
+ font-size: 1.125rem;
80
+ ```
81
+
82
+ Use `px` for everything else:
83
+
84
+ ```css
85
+ border: 1px solid #ccc;
86
+ ```
87
+
88
+ ## Accessibility
89
+
90
+ ### Focus Indicators
91
+
92
+ Provide visible focus for all interactive elements:
93
+
94
+ ```css
95
+ button:focus {
96
+ outline: 2px solid #007bff;
97
+ outline-offset: 2px;
98
+ }
99
+ ```
100
+
101
+ ### Color Information
102
+
103
+ Never use color alone to convey information. Use text labels or patterns to supplement color.
104
+
105
+ ### Motion Preferences
106
+
107
+ Respect reduced motion preferences:
108
+
109
+ ```css
110
+ @media (prefers-reduced-motion: reduce) {
111
+ * {
112
+ animation-duration: 0.01ms !important;
113
+ transition-duration: 0.01ms !important;
114
+ }
115
+ }
116
+ ```
117
+
118
+ ### ARIA Usage
119
+
120
+ - Only use ARIA when HTML semantics are insufficient.
121
+ - Use ARIA for custom components without HTML equivalents.
122
+ - Use `aria-label` when visible text is insufficient:
123
+
124
+ ```html
125
+ <button aria-label="Close dialog">×</button>
126
+ ```
127
+
128
+ Use `aria-describedby` for help text:
129
+
130
+ ```html
131
+ <input type="password" aria-describedby="password-help" />
132
+ <div id="password-help">Must be at least 8 characters</div>
133
+ ```
134
+
135
+ ### Screen Reader Content
136
+
137
+ Use visually hidden class for screen reader only content:
138
+
139
+ ```css
140
+ .visually-hidden {
141
+ position: absolute;
142
+ width: 1px;
143
+ height: 1px;
144
+ overflow: hidden;
145
+ white-space: nowrap;
146
+ clip-path: inset(50%);
147
+ }
148
+ ```
149
+
150
+ ### Font Loading
151
+
152
+ Use `font-display: swap` for web fonts:
153
+
154
+ ```css
155
+ @font-face {
156
+ src: url("font.woff2") format("woff2");
157
+ font-family: "CustomFont";
158
+ font-display: swap;
159
+ }
160
+ ```
@@ -0,0 +1,83 @@
1
+ ---
2
+ description: JavaScript and TypeScript best practices and conventions
3
+ globs: **/*.js, **/*.ts, **/*.mjs, **/*.cjs, **/*.mts, **/*.cts
4
+ ---
5
+
6
+ # JavaScript & TypeScript
7
+
8
+ - Use TypeScript. If .js files are requested, use JSDoc type annotations
9
+ - Prefer functional over imperative
10
+ - Prefer immutability
11
+
12
+ ## Formatting
13
+
14
+ - Use Prettier's default formatting
15
+
16
+ ## Imports & exports
17
+
18
+ - Use ESM unless you're editing a CommonJS file
19
+ - Use file extensions in import specifiers. Use .ts extension in TypeScript files.
20
+ - Avoid default imports and default exports
21
+ - Avoid barrel files (index files that only re-export) unless its a package entry file
22
+
23
+ ## Naming Conventions
24
+
25
+ - `camelCase` for variables, functions, methods
26
+ - `PascalCase` for classes, enums and React components
27
+ - `SCREAMING_SNAKE_CASE` for build-time constants
28
+ - `kebab-case` for file names, CSS classes and DOM ids
29
+ - Stick to existing naming conventions if present (e.g. `camelCase` and `PascalCase` for file names)
30
+ - Use specific names instead of unspecific abbreviations like `obj`, `arr` and `err`
31
+ - Only use abbreviations when they are widely used like `Api`
32
+ - Abbreviations should be treated as separate words (e.g. `Api` instead of `API`)
33
+ - Use short names when the variable or function is private and only accessible in the current file
34
+ - Use longer and more specific names when the variable or function is exported and visible across the whole project
35
+ - Use auxiliary verbs (e.g., isLoading, hasError) for boolean variables and type guards
36
+
37
+ ## Syntax
38
+
39
+ - Use `const` by default, `let` when necessary
40
+ - Use template literals for string interpolation
41
+ - Prefer `undefined` over `null`
42
+ - Destructure objects and arrays, especially when using default values
43
+ - Use optional chaining (`?.`) and nullish coalescing (`??`) instead of `||`
44
+
45
+ ## Control flow
46
+
47
+ - Use early returns to eliminate error and edge cases
48
+ - Use assert functions to assert assumptions
49
+ - Prefer simple if statements and avoid negated if statements where possible
50
+ - Keep indentation level low and avoid more than 5 levels of nesting
51
+
52
+ ## Error handling
53
+
54
+ - Write descriptive error messages and include error context (e.g. actual vs. expected values)
55
+ - Use try-catch blocks sparingly and only when you can actually handle the error
56
+ - Consider using Result types for operations that can fail
57
+
58
+ ## Functions
59
+
60
+ - Use arrow functions unless there is no appropriate syntax like function overloads or generators
61
+ - Use objects as parameters when there are more than 2 parameters
62
+ - Keep functions small and focused on single responsibility
63
+ - Write pure functions when possible
64
+ - Optimize function names for readability on the call side
65
+
66
+ ## Types
67
+
68
+ - Use strict mode
69
+ - Only use `interface` for interfaces that are intended to be implemented by a `class`
70
+ - Use `type` for all other cases, especially object types
71
+ - Use the generic notation for types (e.g. `Array<string>` instead of `string[]`)
72
+ - Do not use `any` to fix type errors. Search for a better alternative.
73
+ - If you have to use `any`, try with `unknown` first
74
+ - [Parse, don't validate](https://lexi-lambda.github.io/blog/2019/11/05/parse-don-t-validate/). Lift types into higher-level, special types as soon as they have been parsed (e.g. prefer explicit string literals over just `string`)
75
+ - Infer types (using type utilities like `Pick`, `Omit`, ...) instead of duplicating them
76
+ - Prefer `satisfies` over type declarations
77
+ - Use explicit return types for functions when the function is exported and the return type is not a literal or when it has high cyclomatic complexity
78
+ - Use erasable syntax only
79
+ - **Important**: Use descriptive type parameter names in generic types, do not use single letter type parameter names
80
+
81
+ ## Testing
82
+
83
+ See [Coding Styleguide Testing](./coding-styleguide-testing.mdc)
@@ -0,0 +1,14 @@
1
+ ---
2
+ description: React best practices and patterns
3
+ globs: **/*.tsx, **/*.jsx
4
+ ---
5
+
6
+ # React
7
+
8
+ - Use arrow functions for components
9
+ - Inline component props next to the component prop argument
10
+ - Derive state where possible
11
+ - Avoid unnecessary `useState` and `useEffect`
12
+ - `useEffect` **must** contain an async function call (unless it's a synchronous browser api like `localStorage`)
13
+ - Avoid `useMemo` and `useCallback` unless its absolutely necessary
14
+ - Create a story for each React component if Storybook is used
@@ -0,0 +1,17 @@
1
+ ---
2
+ description: Shell scripting best practices
3
+ globs: **/*.sh, **/*.bash, **/*.zsh
4
+ ---
5
+
6
+ # Shell scripts
7
+
8
+ - Prepend all shell scripts with
9
+
10
+ ```sh
11
+ set -o errexit # exit when there was a single error
12
+ set -o pipefail # fail when there was a pipe error
13
+ set -o nounset # fail when an env variable is not set
14
+ ```
15
+
16
+ - Make sure that shell scripts also work when file names contain spaces
17
+ - Prefer commands that work on Linux, MacOS and Windows WSL
@@ -0,0 +1,46 @@
1
+ ---
2
+ description: Best practices and conventions for testing JavaScript and TypeScript code
3
+ globs: **/*.test.js, **/*.test.ts, **/*.test.tsx
4
+ ---
5
+
6
+ # Testing
7
+
8
+ ## General principle
9
+
10
+ **Important**: Write as less tests as possible while covering all relevant scenarios. Focus on testing the behavior of the code rather than implementation details.
11
+
12
+ ## Structure & Organization
13
+
14
+ - Hierarchical grouping: Use nested describe() blocks - outer for function/class, inner for scenarios
15
+ - Logical categorization: Group by behavior, input type, or state (e.g., "with valid input", "error handling")
16
+ - Each it() should test a single behavior
17
+
18
+ ## Test Coverage
19
+
20
+ - Happy path: Test expected behavior with typical inputs
21
+ - Edge cases: Test boundaries, empty values, maximum/minimum values
22
+ - Error scenarios: Test all failure modes with proper error type/message validation
23
+ - Type variations: Test all relevant data types (primitives, objects, arrays, functions)
24
+ - Falsy values: Explicitly test null, undefined, 0, "", false, NaN
25
+
26
+ ## Type Safety
27
+
28
+ - Type annotations: Include explicit types in test variables to verify inference
29
+ - Compile-time checks: Some tests exist just to verify type compatibility
30
+
31
+ ## Best Practices
32
+
33
+ - Descriptive names: Use clear it() descriptions stating expected behavior
34
+ - Avoid "should" phrasing in it(): Use verbs like "does" or "returns" to describe behavior
35
+ - Isolation: Each test should be independent and not rely on others
36
+ - Arrange-Act-Assert: Follow AAA pattern for test structure
37
+ - DRY with helpers: Extract repetitive setup into helper functions
38
+ - Use real-life examples and descriptive names for test data
39
+
40
+ ## Assertions
41
+
42
+ - Prefer `.toMatchObject()` over `.toEqual()` for object/array content checks
43
+ - Do not over-assert: Only include relevant data into the expected value using `.toMatchObject()`
44
+ - Check for reference equality only if it matters for the test
45
+ - Multiple assertions: Group related checks in single test when testing same behavior
46
+ - Use `.toThrowErrorMatchingInlineSnapshot()` for exact error messages
@@ -0,0 +1,25 @@
1
+ I want to migrate this module to use @peerigon/configs. Follow the instructions to install the configs:
2
+
3
+ - [ESLint](https://github.com/peerigon/configs/blob/main/eslint/README.md)
4
+ - [Prettier](https://github.com/peerigon/configs/blob/main/prettier/README.md)
5
+ - [TypeScript](https://github.com/peerigon/configs/blob/main/typescript/README.md)
6
+ - [Semantic release](https://github.com/peerigon/configs/blob/main/semantic-release/README.md)
7
+ - [VSCode](https://github.com/peerigon/configs/blob/main/.vscode/README.md)
8
+
9
+ Before writing code, plan the migration first. The migration should be done in granular steps, each step with its own PR.
10
+
11
+ ## Step 1: Add VSCode setting
12
+
13
+ Read https://github.com/peerigon/configs/blob/main/.vscode/README.md for instructions how to add the vscode settings
14
+
15
+ ## Step 2: (Libraries only) Migrate semantic-release
16
+
17
+ Only do this step if the project is a library (i.e. the `package.json` contains a `main` or `exports` field). Read https://github.com/peerigon/configs/blob/main/semantic-release/README.md for instructions how to configure semantic-release.
18
+
19
+ ## Step 3: Migrate prettier
20
+
21
+ Read https://github.com/peerigon/configs/blob/main/prettier/README.md for instructions how to configure prettier. Before finishing the PR, format all files with the new prettier configuration.
22
+
23
+ ## Step 4: Migrate ESLint and TypeScript
24
+
25
+ Read https://github.com/peerigon/configs/blob/main/typescript/README.md for instructions how to configure TypeScript. Run a type check after configuring TypeScript correctly. Read https://github.com/peerigon/configs/blob/main/eslint/README.md for instructions how to configure ESLint. Run the linter after configuring ESLint correctly.
package/ai/rules.mdc ADDED
@@ -0,0 +1,41 @@
1
+ ---
2
+ description: Rules for coding agents to follow
3
+ globs: **/*
4
+ alwaysApply: true
5
+ ---
6
+
7
+ # Coding Styleguide
8
+
9
+ ## Universal Principles
10
+
11
+ - Write idiomatic, self-documenting code with clear, descriptive names
12
+ - Optimize for readability
13
+ - Use names consistently
14
+ - Prefer explicit over implicit
15
+ - Keep code close together that belongs together
16
+
17
+ ## JavaScript & TypeScript
18
+
19
+ See [Coding Styleguide JavaScript & TypeScript](./coding-styleguide-js-ts.mdc)
20
+
21
+ ## HTML & CSS
22
+
23
+ See [Coding Styleguide HTML & CSS](./coding-styleguide-html-css.mdc)
24
+
25
+ ## React
26
+
27
+ See [Coding Styleguide React](./coding-styleguide-react.mdc)
28
+
29
+ ## Shell scripts
30
+
31
+ See [Coding Styleguide Shell Scripts](./coding-styleguide-sh.mdc)
32
+
33
+ ## Development Practices
34
+
35
+ - Breakdown complex tasks into smaller, manageable todos and write them down to a dedicated TODO file
36
+ - Aim for small pull-requests. Each TODO should be a single pull-request. Use stacked PRs.
37
+ - Write unit tests for simple, pure functions
38
+ - Unit test files are colocated with source files (*.test.ts)
39
+ - Write integration or e2e tests for more complex functions/classes/components
40
+ - Run the linter and type checker only once after the implementation is complete and the tests are passing
41
+ - Adjust documentation both in comments and markdown files once you're done
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peerigon/configs",
3
- "version": "7.0.2",
3
+ "version": "7.1.0",
4
4
  "description": "Configs for ESLint, Prettier, TypeScript & friends",
5
5
  "keywords": [
6
6
  "eslint",
@@ -41,6 +41,7 @@
41
41
  },
42
42
  "files": [
43
43
  "dist",
44
+ "ai",
44
45
  "CHANGELOG.md",
45
46
  "README.md"
46
47
  ],
@@ -65,10 +66,10 @@
65
66
  "release": "semantic-release"
66
67
  },
67
68
  "dependencies": {
68
- "@eslint-react/eslint-plugin": "^1.52.3",
69
- "@eslint/compat": "^1.3.1",
69
+ "@eslint-react/eslint-plugin": "^1.52.5",
70
+ "@eslint/compat": "^1.3.2",
70
71
  "@eslint/js": "^9.32.0",
71
- "@ianvs/prettier-plugin-sort-imports": "^4.5.1",
72
+ "@ianvs/prettier-plugin-sort-imports": "^4.6.2",
72
73
  "@prettier/plugin-oxc": "^0.0.4",
73
74
  "@sebbo2002/semantic-release-jsr": "^3.0.1",
74
75
  "@semantic-release/changelog": "^6.0.3",
@@ -90,23 +91,23 @@
90
91
  "prettier-plugin-jsdoc": "^1.3.3",
91
92
  "prettier-plugin-packagejson": "^2.5.19",
92
93
  "prettier-plugin-tailwindcss": "^0.6.14",
93
- "typescript-eslint": "^8.38.0"
94
+ "typescript-eslint": "^8.39.1"
94
95
  },
95
96
  "devDependencies": {
96
97
  "@types/jest": "^30.0.0",
97
- "@types/node": "^24.2.0",
98
+ "@types/node": "^24.2.1",
98
99
  "@types/react": "^19.1.9",
99
100
  "@types/signale": "^1.4.7",
100
- "eslint": "^9.32.0",
101
+ "eslint": "^9.33.0",
101
102
  "husky": "^9.1.7",
102
- "lint-staged": "^16.1.4",
103
+ "lint-staged": "^16.1.5",
103
104
  "npm-run-all2": "^8.0.4",
104
105
  "pin-github-action": "^3.4.0",
105
106
  "prettier": "^3.6.2",
106
107
  "react": "^19.1.1",
107
108
  "rimraf": "^6.0.1",
108
109
  "semantic-release": "^24.2.7",
109
- "typescript": "^5.8.3"
110
+ "typescript": "^5.9.2"
110
111
  },
111
112
  "peerDependencies": {
112
113
  "eslint": "^9.21.0",