@hs-web-team/eslint-config-node 3.0.0-next.9 → 3.1.0-next.1

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 CHANGED
@@ -26,8 +26,13 @@ When testing changes to this package in downstream projects, you'll typically:
26
26
  ### Core Configuration File
27
27
  - **`index.js`**: The main ESLint configuration export using ESLint 9's flat config format
28
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`
29
+ - Exports an array of configuration objects (flat config format)
30
+ - Structure:
31
+ 1. Global ignores object
32
+ 2. `js.configs.recommended` for JavaScript baseline
33
+ 3. JavaScript-specific config for `**/*.{js,mjs,cjs}` files
34
+ 4. Spreads `tseslint.configs.recommended` for TypeScript baseline
35
+ 5. TypeScript-specific config for `**/*.{ts,mts,cts,tsx}` files
31
36
  - Includes Node.js, ES2022, and Jest globals
32
37
  - Common ignores: `node_modules`, `.serverless`, `.webpack`, `dist`, `eslint.config.js`
33
38
  - Key custom rules: `no-console` (allows info/warn/error), `max-len` (120 chars), camelcase disabled
package/README.md CHANGED
@@ -22,21 +22,19 @@ This is a list of ESLint rules that are recommended for use with **Hubspot Marke
22
22
  2. Add to `eslint.config.js` in project root directory
23
23
 
24
24
  ```typescript
25
- import { defineConfig } from 'eslint/config';
26
25
  import wtConfig from '@hs-web-team/eslint-config-node';
27
26
 
28
- export default defineConfig([
27
+ export default [
29
28
  ...wtConfig,
30
- ]);
29
+ ];
31
30
  ```
32
31
 
33
32
  3. Extend the eslint on a project basis by adding rules to `eslint.config.js` e.g.
34
33
 
35
34
  ```typescript
36
- import { defineConfig } from 'eslint/config';
37
35
  import wtConfig from '@hs-web-team/eslint-config-node';
38
36
 
39
- export default defineConfig([
37
+ export default [
40
38
  // Add project-specific ignores here
41
39
  {
42
40
  ignores: ['dist/**'],
@@ -48,7 +46,7 @@ This is a list of ESLint rules that are recommended for use with **Hubspot Marke
48
46
  },
49
47
  },
50
48
  ...wtConfig, // This will include the shared rules from @hs-web-team/eslint-config-node
51
- ]);
49
+ ];
52
50
  ```
53
51
 
54
52
  ## Where to use it
package/browser.js ADDED
@@ -0,0 +1,159 @@
1
+ import js from '@eslint/js';
2
+ import globals from 'globals';
3
+ import tseslint from 'typescript-eslint';
4
+ import reactPlugin from 'eslint-plugin-react';
5
+ import reactHooksPlugin from 'eslint-plugin-react-hooks';
6
+ import jsxA11yPlugin from 'eslint-plugin-jsx-a11y';
7
+
8
+ // Base rules adapted from the browser config
9
+ const baseRules = {
10
+ 'comma-dangle': 'warn',
11
+ 'no-param-reassign': ['warn', { props: false }],
12
+ 'arrow-parens': 0,
13
+ 'no-plusplus': 0,
14
+ 'no-console': ['error', { allow: ['warn', 'error'] }],
15
+ 'no-confusing-arrow': 0,
16
+ 'no-trailing-spaces': ['error', { skipBlankLines: true }],
17
+ 'no-unused-expressions': ['warn', { allowTernary: true }],
18
+ 'max-len': [
19
+ 2,
20
+ {
21
+ code: 120,
22
+ ignoreStrings: true,
23
+ ignoreTemplateLiterals: true
24
+ }
25
+ ],
26
+ 'operator-linebreak': 0,
27
+ 'implicit-arrow-linebreak': 0,
28
+ indent: 0,
29
+ 'object-curly-newline': 0,
30
+ 'function-paren-newline': 0,
31
+ 'nonblock-statement-body-position': 0
32
+ };
33
+
34
+ // React-specific rules
35
+ const reactRules = {
36
+ 'react/prefer-stateless-function': 'off',
37
+ 'react/no-array-index-key': 0,
38
+ 'react/destructuring-assignment': 0,
39
+ 'react/require-default-props': 0,
40
+ 'react/self-closing-comp': [
41
+ 2,
42
+ {
43
+ component: true,
44
+ html: false
45
+ }
46
+ ],
47
+ 'react/forbid-prop-types': 0
48
+ };
49
+
50
+ // Common ignore patterns
51
+ const commonIgnores = [
52
+ '**/node_modules/**',
53
+ '**/dist/**',
54
+ '**/build/**',
55
+ '**/.next/**',
56
+ '**/coverage/**',
57
+ 'eslint.config.js'
58
+ ];
59
+
60
+ export default [
61
+ // Global ignores
62
+ {
63
+ ignores: commonIgnores
64
+ },
65
+ // Base config for all JavaScript files
66
+ js.configs.recommended,
67
+ {
68
+ files: ['**/*.{js,mjs,cjs,jsx}'],
69
+ languageOptions: {
70
+ ecmaVersion: 2021,
71
+ sourceType: 'module',
72
+ globals: {
73
+ ...globals.browser,
74
+ ...globals.es2021,
75
+ ...globals.jest,
76
+ // Custom browser globals from original config
77
+ $: true,
78
+ jQuery: true,
79
+ Invoca: true
80
+ },
81
+ parserOptions: {
82
+ ecmaFeatures: {
83
+ jsx: true
84
+ }
85
+ }
86
+ },
87
+ rules: {
88
+ ...baseRules
89
+ }
90
+ },
91
+ // React configuration
92
+ {
93
+ files: ['**/*.{js,mjs,cjs,jsx}'],
94
+ plugins: {
95
+ react: reactPlugin,
96
+ 'react-hooks': reactHooksPlugin,
97
+ 'jsx-a11y': jsxA11yPlugin
98
+ },
99
+ settings: {
100
+ react: {
101
+ version: 'detect'
102
+ }
103
+ },
104
+ rules: {
105
+ ...reactPlugin.configs.recommended.rules,
106
+ ...reactHooksPlugin.configs.recommended.rules,
107
+ ...jsxA11yPlugin.configs.recommended.rules,
108
+ ...reactRules
109
+ }
110
+ },
111
+ // TypeScript config
112
+ ...tseslint.configs.recommended.map(config => ({
113
+ ...config,
114
+ files: ['**/*.{ts,mts,cts,tsx}']
115
+ })),
116
+ {
117
+ files: ['**/*.{ts,mts,cts,tsx}'],
118
+ languageOptions: {
119
+ ecmaVersion: 2021,
120
+ sourceType: 'module',
121
+ globals: {
122
+ ...globals.browser,
123
+ ...globals.es2021,
124
+ ...globals.jest,
125
+ $: true,
126
+ jQuery: true,
127
+ Invoca: true
128
+ },
129
+ parserOptions: {
130
+ ecmaFeatures: {
131
+ jsx: true
132
+ }
133
+ }
134
+ },
135
+ rules: {
136
+ ...baseRules
137
+ }
138
+ },
139
+ // React configuration for TypeScript files
140
+ {
141
+ files: ['**/*.{ts,tsx}'],
142
+ plugins: {
143
+ react: reactPlugin,
144
+ 'react-hooks': reactHooksPlugin,
145
+ 'jsx-a11y': jsxA11yPlugin
146
+ },
147
+ settings: {
148
+ react: {
149
+ version: 'detect'
150
+ }
151
+ },
152
+ rules: {
153
+ ...reactPlugin.configs.recommended.rules,
154
+ ...reactHooksPlugin.configs.recommended.rules,
155
+ ...jsxA11yPlugin.configs.recommended.rules,
156
+ ...reactRules
157
+ }
158
+ }
159
+ ];
@@ -7,9 +7,9 @@
7
7
  > This migration requires Node.js v22 or higher and a **manual migration** from `.eslintrc` to `eslint.config.mjs`.
8
8
 
9
9
  - [ ] Upgrade to Node.js v22 or higher
10
- - [ ] Upgrade ESLint to v9: `npm install eslint@^9 --save-dev`
11
- - [ ] Update the package: `npm install @hs-web-team/eslint-config-node@latest`
10
+ - [ ] Update the package: `npm install -D @hs-web-team/eslint-config-node@latest`
12
11
  - [ ] **Remove** `@hs-web-team/eslint-config-ts` from dependencies (no longer needed - TypeScript support is now included)
12
+ - [ ] Remove the `--ext .js,.ts` flag from the ESLint command in your project's package.json
13
13
  - [ ] Manually create `eslint.config.mjs` (see [Manual Migration Guide](#manual-migration-guide) below)
14
14
  - [ ] Delete `.eslintrc` file
15
15
  - [ ] Run `npm run lint` to check for any errors
@@ -0,0 +1,76 @@
1
+ # Browser Configuration Usage
2
+
3
+ This package now provides a browser configuration in addition to the Node.js configuration.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install --save-dev @hs-web-team/eslint-config-node
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ Create an `eslint.config.js` file in your browser/React project:
14
+
15
+ ```javascript
16
+ import wtBrowserConfig from '@hs-web-team/eslint-config-node/browser';
17
+
18
+ export default [
19
+ ...wtBrowserConfig,
20
+ // Add your custom overrides here
21
+ {
22
+ rules: {
23
+ // Custom rules
24
+ },
25
+ },
26
+ ];
27
+ ```
28
+
29
+ ## What's Included
30
+
31
+ The browser configuration includes:
32
+
33
+ - **ESLint recommended rules** for JavaScript
34
+ - **TypeScript support** with typescript-eslint
35
+ - **React support** with eslint-plugin-react
36
+ - **React Hooks** rules with eslint-plugin-react-hooks
37
+ - **Accessibility** rules with eslint-plugin-jsx-a11y
38
+ - **Browser globals** (window, document, localStorage, etc.)
39
+ - **Jest environment** for testing
40
+ - **Custom globals**: jQuery, $, Invoca
41
+
42
+ ## Rules Adapted from Original Browser Config
43
+
44
+ The configuration adapts rules from `@hs-web-team/eslint-config-browser`:
45
+
46
+ - **Code Style**: 120 character line length, single quotes, trailing commas
47
+ - **Console**: Allows `console.warn` and `console.error`
48
+ - **React**: Flexible React component patterns
49
+ - **Formatting**: Relaxed indentation and linebreak rules (use Prettier for formatting)
50
+
51
+ ## Migrating from Legacy Browser Config
52
+
53
+ If you're migrating from `@hs-web-team/eslint-config-browser` (ESLint 8):
54
+
55
+ 1. Update your `eslint.config.js` to use flat config format
56
+ 2. Replace `extends: '@hs-web-team/eslint-config-browser'` with the import shown above
57
+ 3. Ensure you're using Node.js >= 22
58
+ 4. Review and adapt any custom rules in your project
59
+
60
+ ## File Patterns
61
+
62
+ The configuration applies to:
63
+
64
+ - JavaScript: `**/*.{js,mjs,cjs,jsx}`
65
+ - TypeScript: `**/*.{ts,mts,cts,tsx}`
66
+
67
+ ## Ignored Directories
68
+
69
+ The following directories are automatically ignored:
70
+
71
+ - `node_modules`
72
+ - `dist`
73
+ - `build`
74
+ - `.next`
75
+ - `coverage`
76
+ - `eslint.config.js`
package/index.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import js from '@eslint/js';
2
2
  import globals from 'globals';
3
3
  import tseslint from 'typescript-eslint';
4
- import { defineConfig } from 'eslint/config';
5
4
 
6
5
  // Base rules for all JavaScript files
7
6
  const baseRules = {
@@ -47,26 +46,30 @@ const commonIgnores = [
47
46
  'eslint.config.js',
48
47
  ];
49
48
 
50
- export default defineConfig([
49
+ export default [
50
+ // Global ignores
51
+ {
52
+ ignores: commonIgnores,
53
+ },
51
54
  // Base config for all JavaScript files
55
+ js.configs.recommended,
52
56
  {
53
57
  files: ['**/*.{js,mjs,cjs}'],
54
- plugins: { js },
55
- extends: ['js/recommended'],
56
58
  languageOptions: {
57
59
  globals: {...globals.node, ...globals.es2022, ...globals.jest},
58
60
  },
59
- ignores: commonIgnores,
60
61
  rules: baseRules,
61
62
  },
62
- // TypeScript config that extends the base config
63
+ // TypeScript config - restrict to TypeScript files only
64
+ ...tseslint.configs.recommended.map(config => ({
65
+ ...config,
66
+ files: ['**/*.{ts,mts,cts,tsx}'],
67
+ })),
63
68
  {
64
69
  files: ['**/*.{ts,mts,cts,tsx}'],
65
- ...tseslint.configs.recommended,
66
- // You can add or override rules specific to TypeScript here
67
- rules: {
68
- ...baseRules,
69
- // Add any TypeScript-specific rules here
70
+ languageOptions: {
71
+ globals: {...globals.node, ...globals.es2022, ...globals.jest},
70
72
  },
73
+ rules: baseRules,
71
74
  },
72
- ]);
75
+ ];
package/package.json CHANGED
@@ -1,9 +1,13 @@
1
1
  {
2
2
  "name": "@hs-web-team/eslint-config-node",
3
- "version": "3.0.0-next.9",
3
+ "version": "3.1.0-next.1",
4
4
  "description": "HubSpot Marketing WebTeam ESLint rules for Node.js",
5
5
  "main": "index.js",
6
6
  "type": "module",
7
+ "exports": {
8
+ ".": "./index.js",
9
+ "./browser": "./browser.js"
10
+ },
7
11
  "scripts": {
8
12
  "lint": "npx eslint -c ./index.js *.js --fix",
9
13
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -28,14 +32,18 @@
28
32
  },
29
33
  "homepage": "https://github.com/HubSpotWebTeam/wt-eslint-node#readme",
30
34
  "dependencies": {
31
- "@eslint/eslintrc": "^3.3.1",
35
+ "@eslint/eslintrc": "^3.3.3",
32
36
  "@eslint/js": "^9.39.1",
33
37
  "@typescript-eslint/eslint-plugin": "^8.46.3",
34
38
  "@typescript-eslint/parser": "^8.46.3",
39
+ "eslint": "^9.39.1",
35
40
  "eslint-formatter-checkstyle": "^9.0.1",
41
+ "eslint-plugin-jsx-a11y": "^6.10.2",
42
+ "eslint-plugin-react": "^7.37.5",
43
+ "eslint-plugin-react-hooks": "^7.0.1",
36
44
  "globals": "^16.5.0",
37
45
  "jiti": "^2.6.1",
38
- "prettier": "^3.6.2",
39
- "typescript-eslint": "^8.46.3"
46
+ "prettier": "^3.7.4",
47
+ "typescript-eslint": "^8.48.1"
40
48
  }
41
49
  }