@hs-web-team/eslint-config-node 3.0.0-next.6 → 3.0.0-next.7
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/.github/workflows/main.yml +2 -2
- package/.github/workflows/pr.yml +2 -2
- package/.github/workflows/release.yml +2 -2
- package/CLAUDE.md +64 -0
- package/index.js +56 -40
- package/package.json +1 -1
|
@@ -15,9 +15,9 @@ jobs:
|
|
|
15
15
|
|
|
16
16
|
name: Node ${{ matrix.node }} lint
|
|
17
17
|
steps:
|
|
18
|
-
- uses: actions/checkout@
|
|
18
|
+
- uses: actions/checkout@v5
|
|
19
19
|
- name: Run unit tests
|
|
20
|
-
uses: actions/setup-node@
|
|
20
|
+
uses: actions/setup-node@v6
|
|
21
21
|
with:
|
|
22
22
|
node-version: ${{ matrix.node }}
|
|
23
23
|
- run: npm install
|
package/.github/workflows/pr.yml
CHANGED
|
@@ -15,9 +15,9 @@ jobs:
|
|
|
15
15
|
|
|
16
16
|
name: Node ${{ matrix.node }} sample
|
|
17
17
|
steps:
|
|
18
|
-
- uses: actions/checkout@
|
|
18
|
+
- uses: actions/checkout@v5
|
|
19
19
|
- name: Run unit tests
|
|
20
|
-
uses: actions/setup-node@
|
|
20
|
+
uses: actions/setup-node@v6
|
|
21
21
|
with:
|
|
22
22
|
node-version: ${{ matrix.node }}
|
|
23
23
|
- run: npm install
|
|
@@ -7,8 +7,8 @@ jobs:
|
|
|
7
7
|
runs-on: ubuntu-latest
|
|
8
8
|
steps:
|
|
9
9
|
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
|
|
10
|
-
- uses: actions/checkout@
|
|
11
|
-
- uses: actions/setup-node@
|
|
10
|
+
- uses: actions/checkout@v5
|
|
11
|
+
- uses: actions/setup-node@v6
|
|
12
12
|
with:
|
|
13
13
|
node-version: 24
|
|
14
14
|
registry-url: 'https://registry.npmjs.org'
|
package/CLAUDE.md
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
This is an ESLint configuration package (`@hs-web-team/eslint-config-node`) for HubSpot Marketing WebTeam Node.js projects. It provides shared ESLint rules and Prettier configuration for backend Node.js projects.
|
|
8
|
+
|
|
9
|
+
## Key Commands
|
|
10
|
+
|
|
11
|
+
### Linting
|
|
12
|
+
```bash
|
|
13
|
+
npm run lint
|
|
14
|
+
```
|
|
15
|
+
Runs ESLint on the codebase with auto-fix enabled. Uses the configuration defined in `index.js`.
|
|
16
|
+
|
|
17
|
+
### Testing in Projects
|
|
18
|
+
When testing changes to this package in downstream projects, you'll typically:
|
|
19
|
+
1. Make changes to the ESLint config in `index.js`
|
|
20
|
+
2. Run `npm link` in this repository
|
|
21
|
+
3. Run `npm link @hs-web-team/eslint-config-node` in the consuming project
|
|
22
|
+
4. Test the linting behavior in the consuming project
|
|
23
|
+
|
|
24
|
+
## Architecture
|
|
25
|
+
|
|
26
|
+
### Core Configuration File
|
|
27
|
+
- **`index.js`**: The main ESLint configuration export using ESLint 9's flat config format
|
|
28
|
+
- Uses `@eslint/js`, `typescript-eslint`, and `globals` packages
|
|
29
|
+
- Exports two separate configurations: one for JavaScript files (`**/*.{js,mjs,cjs}`) and one for TypeScript files (`**/*.{ts,mts,cts,tsx}`)
|
|
30
|
+
- JavaScript config uses `js/recommended`, TypeScript config uses `tseslint.configs.recommended`
|
|
31
|
+
- Includes Node.js, ES2022, and Jest globals
|
|
32
|
+
- Common ignores: `node_modules`, `.serverless`, `.webpack`, `dist`, `eslint.config.js`
|
|
33
|
+
- Key custom rules: `no-console` (allows info/warn/error), `max-len` (120 chars), camelcase disabled
|
|
34
|
+
|
|
35
|
+
### Prettier Integration
|
|
36
|
+
- **`bin/add-prettier-scripts.js`**: Executable script that consuming projects can run to set up Prettier
|
|
37
|
+
- Uses CommonJS (`require`) syntax (different from the main package which is ESM)
|
|
38
|
+
- Adds `prettier:check` and `prettier:write` scripts to package.json
|
|
39
|
+
- Creates `.prettierrc.js` file that imports from this package's `.prettierrc.json`
|
|
40
|
+
- Creates `.prettierignore` file with sensible defaults (npm-shrinkwrap.json, package-lock.json, .eslintrc, *.html)
|
|
41
|
+
- **`.prettierrc.json`**: Shared Prettier configuration
|
|
42
|
+
- 120 char width, single quotes, 2-space tabs, trailing commas
|
|
43
|
+
- Arrow parens: avoid, LF line endings, single attribute per line
|
|
44
|
+
- Override for YAML files: uses double quotes instead of single
|
|
45
|
+
|
|
46
|
+
### Package Details
|
|
47
|
+
- **Type**: ESM module (`"type": "module"`)
|
|
48
|
+
- **Node requirement**: >= 22
|
|
49
|
+
- **Main export**: `index.js`
|
|
50
|
+
- **Binary command**: `add-prettier` maps to `bin/add-prettier-scripts.js`
|
|
51
|
+
|
|
52
|
+
### Migration Context
|
|
53
|
+
This package is currently on v3, which uses ESLint 9's flat config format. The project has migrated from:
|
|
54
|
+
- v1 → v2: See `docs/MIGRATION-V2.md`
|
|
55
|
+
- v2 → v3: See `docs/MIGRATION-V3.md` (ESLint 9 flat config migration requiring Node.js 22+)
|
|
56
|
+
|
|
57
|
+
## Important Notes
|
|
58
|
+
|
|
59
|
+
- This package is for **backend Node.js projects only**, not browser environments
|
|
60
|
+
- The configuration uses ESLint 9's flat config format (not the legacy `.eslintrc` format)
|
|
61
|
+
- Downstream projects extend this config in their `eslint.config.js` by spreading the imported config using `...wtConfig`
|
|
62
|
+
- Mixed module systems: `bin/add-prettier-scripts.js` uses CommonJS (`require`) while the main package is ESM
|
|
63
|
+
- CI runs on Node 22 and 24 (see `.github/workflows/pr.yml`)
|
|
64
|
+
- No automated tests currently (`npm test` will fail with "Error: no test specified")
|
package/index.js
CHANGED
|
@@ -3,54 +3,70 @@ import globals from 'globals';
|
|
|
3
3
|
import tseslint from 'typescript-eslint';
|
|
4
4
|
import { defineConfig } from 'eslint/config';
|
|
5
5
|
|
|
6
|
+
// Base rules for all JavaScript files
|
|
7
|
+
const baseRules = {
|
|
8
|
+
'no-console': [
|
|
9
|
+
'error',
|
|
10
|
+
{
|
|
11
|
+
allow: ['info', 'warn', 'error'],
|
|
12
|
+
},
|
|
13
|
+
],
|
|
14
|
+
camelcase: 'off',
|
|
15
|
+
'comma-dangle': ['warn', 'always-multiline'],
|
|
16
|
+
'arrow-parens': 0,
|
|
17
|
+
'no-plusplus': 0,
|
|
18
|
+
'no-underscore-dangle': 0,
|
|
19
|
+
'no-confusing-arrow': 0,
|
|
20
|
+
'import/no-unresolved': 0,
|
|
21
|
+
'import/prefer-default-export': 0,
|
|
22
|
+
'no-trailing-spaces': ['error', { skipBlankLines: true }],
|
|
23
|
+
'no-unused-expressions': ['warn', { allowTernary: true }],
|
|
24
|
+
'max-len': [
|
|
25
|
+
2,
|
|
26
|
+
{
|
|
27
|
+
code: 120,
|
|
28
|
+
ignoreStrings: true,
|
|
29
|
+
ignoreTemplateLiterals: true,
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
'operator-linebreak': 0,
|
|
33
|
+
'implicit-arrow-linebreaks': 0,
|
|
34
|
+
'implicit-arrow-linebreak': 0,
|
|
35
|
+
'object-curly-newline': 0,
|
|
36
|
+
'newline-per-chained-call': 0,
|
|
37
|
+
indent: 0,
|
|
38
|
+
'function-paren-newline': 0,
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
// Common ignore patterns
|
|
42
|
+
const commonIgnores = [
|
|
43
|
+
'**/node_modules/**',
|
|
44
|
+
'**/.serverless/**',
|
|
45
|
+
'**/.webpack/**',
|
|
46
|
+
'**/dist/**',
|
|
47
|
+
'eslint.config.js',
|
|
48
|
+
];
|
|
49
|
+
|
|
6
50
|
export default defineConfig([
|
|
51
|
+
// Base config for all JavaScript files
|
|
7
52
|
{
|
|
8
|
-
files: ['**/*.{js,mjs,cjs
|
|
53
|
+
files: ['**/*.{js,mjs,cjs}'],
|
|
9
54
|
plugins: { js },
|
|
10
55
|
extends: ['js/recommended'],
|
|
11
56
|
languageOptions: {
|
|
12
57
|
globals: {...globals.node, ...globals.es2022, ...globals.jest},
|
|
13
58
|
},
|
|
14
|
-
ignores:
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
59
|
+
ignores: commonIgnores,
|
|
60
|
+
rules: baseRules,
|
|
61
|
+
},
|
|
62
|
+
// TypeScript config that extends the base config
|
|
63
|
+
{
|
|
64
|
+
files: ['**/*.{ts,mts,cts,tsx}'],
|
|
65
|
+
...tseslint.configs.recommended,
|
|
66
|
+
// You can add or override rules specific to TypeScript here
|
|
21
67
|
rules: {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
{
|
|
25
|
-
allow: ['info', 'warn', 'error'],
|
|
26
|
-
},
|
|
27
|
-
],
|
|
28
|
-
camelcase: 'off',
|
|
29
|
-
'comma-dangle': ['warn', 'always-multiline'],
|
|
30
|
-
'arrow-parens': 0,
|
|
31
|
-
'no-plusplus': 0,
|
|
32
|
-
'no-underscore-dangle': 0,
|
|
33
|
-
'no-confusing-arrow': 0,
|
|
34
|
-
'import/no-unresolved': 0,
|
|
35
|
-
'import/prefer-default-export': 0,
|
|
36
|
-
'no-trailing-spaces': ['error', { skipBlankLines: true }],
|
|
37
|
-
'no-unused-expressions': ['warn', { allowTernary: true }],
|
|
38
|
-
'max-len': [
|
|
39
|
-
2,
|
|
40
|
-
{
|
|
41
|
-
code: 120,
|
|
42
|
-
ignoreStrings: true,
|
|
43
|
-
ignoreTemplateLiterals: true,
|
|
44
|
-
},
|
|
45
|
-
],
|
|
46
|
-
'operator-linebreak': 0,
|
|
47
|
-
'implicit-arrow-linebreaks': 0,
|
|
48
|
-
'implicit-arrow-linebreak': 0,
|
|
49
|
-
'object-curly-newline': 0,
|
|
50
|
-
'newline-per-chained-call': 0,
|
|
51
|
-
indent: 0,
|
|
52
|
-
'function-paren-newline': 0,
|
|
68
|
+
...baseRules,
|
|
69
|
+
// Add any TypeScript-specific rules here
|
|
53
70
|
},
|
|
54
71
|
},
|
|
55
|
-
tseslint.configs.recommended,
|
|
56
72
|
]);
|