@hs-web-team/eslint-config-node 3.0.0 → 3.1.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.
@@ -2,17 +2,23 @@ name: Publish Package to npmjs
2
2
  on:
3
3
  release:
4
4
  types: [created]
5
+
6
+ permissions:
7
+ id-token: write # Required for OIDC
8
+ contents: read
9
+
5
10
  jobs:
6
11
  build:
7
12
  runs-on: ubuntu-latest
8
13
  steps:
9
14
  # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
10
- - uses: actions/checkout@v5
15
+ - uses: actions/checkout@v6
11
16
  - uses: actions/setup-node@v6
12
17
  with:
13
18
  node-version: 24
14
19
  registry-url: 'https://registry.npmjs.org'
15
- - run: npm install
20
+ - run: npm ci
21
+ - run: npm run build --if-present
16
22
  - name: Publish to npm
17
23
  run: |
18
24
  VERSION=$(node -p "require('./package.json').version")
@@ -26,5 +32,3 @@ jobs:
26
32
  echo "Publishing stable version $VERSION"
27
33
  npm publish
28
34
  fi
29
- env:
30
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
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
+ ];
@@ -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/package.json CHANGED
@@ -1,9 +1,13 @@
1
1
  {
2
2
  "name": "@hs-web-team/eslint-config-node",
3
- "version": "3.0.0",
3
+ "version": "3.1.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"
@@ -32,11 +36,14 @@
32
36
  "@eslint/js": "^9.39.1",
33
37
  "@typescript-eslint/eslint-plugin": "^8.46.3",
34
38
  "@typescript-eslint/parser": "^8.46.3",
35
- "eslint": "^9.39.1",
39
+ "eslint": "^9.39.2",
36
40
  "eslint-formatter-checkstyle": "^9.0.1",
37
- "globals": "^16.5.0",
41
+ "eslint-plugin-jsx-a11y": "^6.10.2",
42
+ "eslint-plugin-react": "^7.37.5",
43
+ "eslint-plugin-react-hooks": "^7.0.1",
44
+ "globals": "^17.0.0",
38
45
  "jiti": "^2.6.1",
39
- "prettier": "^3.7.3",
40
- "typescript-eslint": "^8.48.0"
46
+ "prettier": "^3.8.1",
47
+ "typescript-eslint": "^8.53.1"
41
48
  }
42
49
  }