@hs-web-team/eslint-config-node 3.1.1 → 3.1.3
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/CLAUDE.md +29 -6
- package/README.md +39 -5
- package/package.json +4 -3
package/CLAUDE.md
CHANGED
|
@@ -4,14 +4,16 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
|
|
|
4
4
|
|
|
5
5
|
## Overview
|
|
6
6
|
|
|
7
|
-
This is an ESLint configuration package (`@hs-web-team/eslint-config-node`) for HubSpot Marketing WebTeam
|
|
7
|
+
This is an ESLint configuration package (`@hs-web-team/eslint-config-node`) for HubSpot Marketing WebTeam projects. It provides shared ESLint rules and Prettier configuration for both backend Node.js projects and browser/React applications.
|
|
8
8
|
|
|
9
9
|
## Key Commands
|
|
10
10
|
|
|
11
11
|
### Linting
|
|
12
|
+
|
|
12
13
|
```bash
|
|
13
14
|
npm run lint
|
|
14
15
|
```
|
|
16
|
+
|
|
15
17
|
Runs ESLint on the codebase with auto-fix enabled. Uses the configuration defined in `index.js`.
|
|
16
18
|
|
|
17
19
|
### Testing in Projects
|
|
@@ -23,8 +25,10 @@ When testing changes to this package in downstream projects, you'll typically:
|
|
|
23
25
|
|
|
24
26
|
## Architecture
|
|
25
27
|
|
|
26
|
-
### Core Configuration
|
|
27
|
-
|
|
28
|
+
### Core Configuration Files
|
|
29
|
+
|
|
30
|
+
#### `index.js` - Node.js Configuration
|
|
31
|
+
- The main ESLint configuration export using ESLint 9's flat config format
|
|
28
32
|
- Uses `@eslint/js`, `typescript-eslint`, and `globals` packages
|
|
29
33
|
- Exports an array of configuration objects (flat config format)
|
|
30
34
|
- Structure:
|
|
@@ -37,6 +41,20 @@ When testing changes to this package in downstream projects, you'll typically:
|
|
|
37
41
|
- Common ignores: `node_modules`, `.serverless`, `.webpack`, `dist`, `eslint.config.js`
|
|
38
42
|
- Key custom rules: `no-console` (allows info/warn/error), `max-len` (120 chars), camelcase disabled
|
|
39
43
|
|
|
44
|
+
#### `browser.js` - Browser/React Configuration
|
|
45
|
+
- Browser and React-focused ESLint configuration using ESLint 9's flat config format
|
|
46
|
+
- Uses `@eslint/js`, `typescript-eslint`, `globals`, and React-specific plugins
|
|
47
|
+
- Includes `eslint-plugin-react`, `eslint-plugin-react-hooks`, and `eslint-plugin-jsx-a11y`
|
|
48
|
+
- Supports both JavaScript/JSX and TypeScript/TSX files
|
|
49
|
+
- Structure:
|
|
50
|
+
1. Global ignores (node_modules, dist, build, .next, coverage)
|
|
51
|
+
2. Base JavaScript/JSX config with browser globals
|
|
52
|
+
3. React plugin configuration
|
|
53
|
+
4. TypeScript config with browser globals
|
|
54
|
+
5. React plugin configuration for TypeScript files
|
|
55
|
+
- Includes browser, ES2021, and Jest globals, plus custom globals ($, jQuery, Invoca)
|
|
56
|
+
- Key custom rules: Similar base rules to Node config, plus React-specific rules
|
|
57
|
+
|
|
40
58
|
### Prettier Integration
|
|
41
59
|
- **`bin/add-prettier-scripts.js`**: Executable script that consuming projects can run to set up Prettier
|
|
42
60
|
- Uses CommonJS (`require`) syntax (different from the main package which is ESM)
|
|
@@ -51,7 +69,9 @@ When testing changes to this package in downstream projects, you'll typically:
|
|
|
51
69
|
### Package Details
|
|
52
70
|
- **Type**: ESM module (`"type": "module"`)
|
|
53
71
|
- **Node requirement**: >= 22
|
|
54
|
-
- **
|
|
72
|
+
- **Exports**:
|
|
73
|
+
- Main export (`.`): `index.js` - Node.js configuration
|
|
74
|
+
- Browser export (`./browser`): `browser.js` - Browser/React configuration
|
|
55
75
|
- **Binary command**: `add-prettier` maps to `bin/add-prettier-scripts.js`
|
|
56
76
|
|
|
57
77
|
### Migration Context
|
|
@@ -61,9 +81,12 @@ This package is currently on v3, which uses ESLint 9's flat config format. The p
|
|
|
61
81
|
|
|
62
82
|
## Important Notes
|
|
63
83
|
|
|
64
|
-
- This package
|
|
84
|
+
- This package supports both **backend Node.js projects** (default export) and **browser/React projects** (`/browser` export)
|
|
65
85
|
- The configuration uses ESLint 9's flat config format (not the legacy `.eslintrc` format)
|
|
66
|
-
- Downstream projects extend this config in their `eslint.config.js` by spreading the imported config
|
|
86
|
+
- Downstream projects extend this config in their `eslint.config.js` by spreading the imported config:
|
|
87
|
+
- Node.js: `...wtConfig`
|
|
88
|
+
- Browser: `...wtBrowserConfig`
|
|
67
89
|
- Mixed module systems: `bin/add-prettier-scripts.js` uses CommonJS (`require`) while the main package is ESM
|
|
68
90
|
- CI runs on Node 22 and 24 (see `.github/workflows/pr.yml`)
|
|
69
91
|
- No automated tests currently (`npm test` will fail with "Error: no test specified")
|
|
92
|
+
- Detailed browser configuration documentation available in `examples/browser-usage.md`
|
package/README.md
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
# Hubspot Marketing WebTeam ESLint
|
|
1
|
+
# Hubspot Marketing WebTeam ESLint Configuration
|
|
2
2
|
|
|
3
|
-
This
|
|
3
|
+
This package provides ESLint rules and configurations for **Hubspot Marketing WebTeam** projects, supporting both Node.js backend and browser/React applications.
|
|
4
4
|
|
|
5
5
|
<!-- index-start -->
|
|
6
6
|
|
|
7
7
|
## Index
|
|
8
8
|
|
|
9
|
-
- [Setup](#setup)
|
|
9
|
+
- [Node.js Setup](#nodejs-setup)
|
|
10
|
+
- [Browser/React Setup](#browserreact-setup)
|
|
10
11
|
- [Where to use it](#where-to-use-it)
|
|
11
12
|
- [Using the Prettier Scripts](#using-the-prettier-scripts)
|
|
12
13
|
<!-- index-end -->
|
|
13
14
|
|
|
14
|
-
## Setup
|
|
15
|
+
## Node.js Setup
|
|
15
16
|
|
|
16
17
|
1. Install as dev dependency
|
|
17
18
|
|
|
@@ -49,9 +50,42 @@ This is a list of ESLint rules that are recommended for use with **Hubspot Marke
|
|
|
49
50
|
];
|
|
50
51
|
```
|
|
51
52
|
|
|
53
|
+
## Browser/React Setup
|
|
54
|
+
|
|
55
|
+
1. Install as dev dependency
|
|
56
|
+
|
|
57
|
+
```sh
|
|
58
|
+
npm i -D @hs-web-team/eslint-config-node@latest
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
2. Add to `eslint.config.js` in project root directory
|
|
62
|
+
|
|
63
|
+
```typescript
|
|
64
|
+
import wtBrowserConfig from '@hs-web-team/eslint-config-node/browser';
|
|
65
|
+
|
|
66
|
+
export default [
|
|
67
|
+
...wtBrowserConfig,
|
|
68
|
+
];
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
3. The browser configuration includes:
|
|
72
|
+
- ESLint recommended rules for JavaScript
|
|
73
|
+
- TypeScript support with typescript-eslint
|
|
74
|
+
- React support with eslint-plugin-react
|
|
75
|
+
- React Hooks rules with eslint-plugin-react-hooks
|
|
76
|
+
- Accessibility rules with eslint-plugin-jsx-a11y
|
|
77
|
+
- Browser globals (window, document, etc.) and custom globals (jQuery, $, Invoca)
|
|
78
|
+
|
|
79
|
+
For detailed browser configuration documentation and migration guides, see [examples/browser-usage.md](./examples/browser-usage.md).
|
|
80
|
+
|
|
52
81
|
## Where to use it
|
|
53
82
|
|
|
54
|
-
This package
|
|
83
|
+
This package provides two configurations:
|
|
84
|
+
|
|
85
|
+
- **Node.js configuration** (default export): For backend Node.js projects
|
|
86
|
+
- **Browser configuration** (`/browser` export): For browser-based projects including React applications
|
|
87
|
+
|
|
88
|
+
Choose the appropriate configuration based on your project type.
|
|
55
89
|
|
|
56
90
|
## Using the Prettier Scripts
|
|
57
91
|
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hs-web-team/eslint-config-node",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.3",
|
|
4
4
|
"description": "HubSpot Marketing WebTeam ESLint rules for Node.js",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": "./index.js",
|
|
9
|
-
"./browser": "./browser.js"
|
|
9
|
+
"./browser": "./browser.js",
|
|
10
|
+
"./.prettierrc.json": "./.prettierrc.json"
|
|
10
11
|
},
|
|
11
12
|
"scripts": {
|
|
12
13
|
"lint": "npx eslint -c ./index.js *.js --fix",
|
|
@@ -41,7 +42,7 @@
|
|
|
41
42
|
"eslint-plugin-jsx-a11y": "^6.10.2",
|
|
42
43
|
"eslint-plugin-react": "^7.37.5",
|
|
43
44
|
"eslint-plugin-react-hooks": "^7.0.1",
|
|
44
|
-
"globals": "^17.
|
|
45
|
+
"globals": "^17.1.0",
|
|
45
46
|
"jiti": "^2.6.1",
|
|
46
47
|
"prettier": "^3.8.1",
|
|
47
48
|
"typescript-eslint": "^8.53.1"
|