@hs-web-team/eslint-config-node 3.2.0-next.3 → 3.2.0-next.5
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 +3 -3
- package/cypress.config.ts +120 -0
- package/package.json +5 -15
- /package/{cypress.config.js → cypress.config.cjs} +0 -0
package/CLAUDE.md
CHANGED
|
@@ -83,7 +83,7 @@ When testing changes to this package in downstream projects, you'll typically:
|
|
|
83
83
|
- Documentation: `examples/stylelint-usage.md`
|
|
84
84
|
|
|
85
85
|
### Cypress Configuration
|
|
86
|
-
- **`cypress.config.
|
|
86
|
+
- **`cypress.config.cjs`**: Shared Cypress configuration for E2E testing
|
|
87
87
|
- Uses CommonJS (`require`) syntax
|
|
88
88
|
- Core settings:
|
|
89
89
|
- Disables Chrome web security for cross-origin testing
|
|
@@ -111,7 +111,7 @@ When testing changes to this package in downstream projects, you'll typically:
|
|
|
111
111
|
- Browser export (`./browser`): `browser.js` - Browser/React ESLint configuration
|
|
112
112
|
- Prettier export (`./.prettierrc.json`): `.prettierrc.json` - Prettier configuration
|
|
113
113
|
- Stylelint export (`./.stylelintrc.json`): `.stylelintrc.json` - Stylelint configuration
|
|
114
|
-
- Cypress export (`./cypress.config`): `cypress.config.
|
|
114
|
+
- Cypress export (`./cypress.config`): `cypress.config.cjs` - Cypress configuration
|
|
115
115
|
- **Binary command**: `add-prettier` maps to `bin/add-prettier-scripts.js`
|
|
116
116
|
|
|
117
117
|
### Migration Context
|
|
@@ -135,7 +135,7 @@ This package is currently on v3, which uses ESLint 9's flat config format. The p
|
|
|
135
135
|
- Cypress: Import and spread in `cypress.config.js`
|
|
136
136
|
- Mixed module systems:
|
|
137
137
|
- Main package is ESM (`index.js`, `browser.js`)
|
|
138
|
-
- Utility scripts use CommonJS (`bin/add-prettier-scripts.js`, `cypress.config.
|
|
138
|
+
- Utility scripts use CommonJS (`bin/add-prettier-scripts.js`, `cypress.config.cjs`)
|
|
139
139
|
- CI runs on Node 22 and 24 (see `.github/workflows/pr.yml`)
|
|
140
140
|
- No automated tests currently (`npm test` will fail with "Error: no test specified")
|
|
141
141
|
- Detailed documentation available in `examples/`:
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import yaml from 'js-yaml';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import createBundler from '@bahmutov/cypress-esbuild-preprocessor';
|
|
5
|
+
import { addCucumberPreprocessorPlugin } from '@badeball/cypress-cucumber-preprocessor';
|
|
6
|
+
import { createEsbuildPlugin } from '@badeball/cypress-cucumber-preprocessor/esbuild';
|
|
7
|
+
|
|
8
|
+
const DEV = 'DEV';
|
|
9
|
+
const QA = 'qa';
|
|
10
|
+
const PROD = 'prod';
|
|
11
|
+
const currentEnv = QA;
|
|
12
|
+
|
|
13
|
+
export const envs = {
|
|
14
|
+
currentEnv,
|
|
15
|
+
DEV,
|
|
16
|
+
QA,
|
|
17
|
+
PROD,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @description Recursively climbs up the filepath, until it finds what directory
|
|
22
|
+
* the directory where the hubspot.config.yml file is located.
|
|
23
|
+
*
|
|
24
|
+
* @param {string} currDir - the current working directory path to search from
|
|
25
|
+
* @returns {string} The absolute path of the project's root directory
|
|
26
|
+
*/
|
|
27
|
+
const getRootDir = (currDir: string): string => {
|
|
28
|
+
if (fs.existsSync(path.join(currDir, 'hubspot.config.yml'))) return currDir;
|
|
29
|
+
const parentDir = path.dirname(currDir);
|
|
30
|
+
if (parentDir === currDir) {
|
|
31
|
+
throw new Error('Error: Could not find the hubspot.config.yml file within the projects directories.');
|
|
32
|
+
}
|
|
33
|
+
return getRootDir(parentDir);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @returns {string|null} The `baseUrl` set for the `DEV` portal in `hubspot.config.yml`
|
|
38
|
+
* or `null` if this is not the dev environment or no such property exists.
|
|
39
|
+
*/
|
|
40
|
+
export const getDevBaseUrl = (): string | null => {
|
|
41
|
+
try {
|
|
42
|
+
global.console.log(
|
|
43
|
+
'To test a dev URL, add the `baseUrl` property to your `DEV` portal configuration in `hubspot.config.yml`',
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
const root = getRootDir(__dirname);
|
|
47
|
+
const configPath = path.resolve(root, 'hubspot.config.yml');
|
|
48
|
+
const fileContents = fs.readFileSync(configPath, 'utf8');
|
|
49
|
+
const { portals } = yaml.load(fileContents) as { portals: Array<{ name: string; baseUrl?: string }> };
|
|
50
|
+
const devPortal = portals.find(portal => portal.name === 'DEV');
|
|
51
|
+
return devPortal?.baseUrl || null;
|
|
52
|
+
} catch (error) {
|
|
53
|
+
global.console.error(error);
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* @description Get the baseUrls for different environments from the ci config file for local test execution.
|
|
60
|
+
* @returns {object} baseUrls - The base urls object
|
|
61
|
+
*/
|
|
62
|
+
export const getBaseUrls = (): Record<string, string | null> | null => {
|
|
63
|
+
let fileContents = '';
|
|
64
|
+
let ciConfig: { regression?: { e2eTestEnvironment?: Array<{ name: string; url: string }> } } = {};
|
|
65
|
+
const baseUrls: Record<string, string | null> = {};
|
|
66
|
+
baseUrls[envs.DEV] = getDevBaseUrl();
|
|
67
|
+
|
|
68
|
+
const fileExist = fs.existsSync('.ci/config.yml');
|
|
69
|
+
if (fileExist) {
|
|
70
|
+
fileContents = fs.readFileSync('.ci/config.yml', 'utf8');
|
|
71
|
+
ciConfig = yaml.load(fileContents) as typeof ciConfig;
|
|
72
|
+
if (ciConfig.regression?.e2eTestEnvironment && ciConfig.regression.e2eTestEnvironment.length > 0) {
|
|
73
|
+
try {
|
|
74
|
+
ciConfig.regression.e2eTestEnvironment.forEach(item => {
|
|
75
|
+
baseUrls[item.name] = item.url;
|
|
76
|
+
});
|
|
77
|
+
} catch (error) {
|
|
78
|
+
console.error('Error reading the base urls from the ci config file:', error);
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return baseUrls || null;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
async function setupNodeEvents(
|
|
87
|
+
on: Cypress.PluginEvents,
|
|
88
|
+
config: Cypress.PluginConfigOptions,
|
|
89
|
+
): Promise<Cypress.PluginConfigOptions> {
|
|
90
|
+
await addCucumberPreprocessorPlugin(on, config);
|
|
91
|
+
on(
|
|
92
|
+
'file:preprocessor',
|
|
93
|
+
createBundler({ plugins: [createEsbuildPlugin(config)] }),
|
|
94
|
+
);
|
|
95
|
+
return config;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const e2e: Cypress.EndToEndConfigOptions = {
|
|
99
|
+
specPattern: 'cypress/e2e/*.cy.js',
|
|
100
|
+
setupNodeEvents,
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export const config: Cypress.ConfigOptions = {
|
|
104
|
+
chromeWebSecurity: false,
|
|
105
|
+
defaultCommandTimeout: 20000,
|
|
106
|
+
e2e,
|
|
107
|
+
numTestsKeptInMemory: 0,
|
|
108
|
+
pageLoadTimeout: 20000,
|
|
109
|
+
port: 3500,
|
|
110
|
+
responseTimeout: 20000,
|
|
111
|
+
retries: {
|
|
112
|
+
runMode: 1,
|
|
113
|
+
openMode: 0,
|
|
114
|
+
},
|
|
115
|
+
screenshotOnRunFailure: true,
|
|
116
|
+
trashAssetsBeforeRuns: true,
|
|
117
|
+
video: false,
|
|
118
|
+
viewportHeight: 1080,
|
|
119
|
+
viewportWidth: 1920,
|
|
120
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hs-web-team/eslint-config-node",
|
|
3
|
-
"version": "3.2.0-next.
|
|
3
|
+
"version": "3.2.0-next.5",
|
|
4
4
|
"description": "HubSpot Marketing WebTeam shared configurations for ESLint, Prettier, Stylelint, and Cypress",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -9,8 +9,7 @@
|
|
|
9
9
|
"./browser": "./browser.js",
|
|
10
10
|
"./.prettierrc.json": "./.prettierrc.json",
|
|
11
11
|
"./.stylelintrc.json": "./.stylelintrc.json",
|
|
12
|
-
"./cypress.config
|
|
13
|
-
"./cypress.config.ts": "./cypress.config.ts"
|
|
12
|
+
"./cypress.config": "./cypress.config.cjs"
|
|
14
13
|
},
|
|
15
14
|
"scripts": {
|
|
16
15
|
"lint": "npx eslint -c ./index.js *.js --fix",
|
|
@@ -54,13 +53,13 @@
|
|
|
54
53
|
"globals": "^17.3.0",
|
|
55
54
|
"jiti": "^2.6.1",
|
|
56
55
|
"prettier": "^3.8.1",
|
|
57
|
-
"typescript-eslint": "^8.54.0"
|
|
56
|
+
"typescript-eslint": "^8.54.0",
|
|
57
|
+
"esbuild": "^0.27.2",
|
|
58
|
+
"js-yaml": "^4.1.1"
|
|
58
59
|
},
|
|
59
60
|
"peerDependencies": {
|
|
60
61
|
"@badeball/cypress-cucumber-preprocessor": "^24.0.0",
|
|
61
62
|
"cypress": "^15.0.0",
|
|
62
|
-
"esbuild": "^0.27.2",
|
|
63
|
-
"js-yaml": "^4.1.1",
|
|
64
63
|
"stylelint": "^17.1.1",
|
|
65
64
|
"stylelint-config-standard": "^40.0.0",
|
|
66
65
|
"stylelint-config-standard-scss": "^17.0.0"
|
|
@@ -77,15 +76,6 @@
|
|
|
77
76
|
},
|
|
78
77
|
"cypress": {
|
|
79
78
|
"optional": true
|
|
80
|
-
},
|
|
81
|
-
"@badeball/cypress-cucumber-preprocessor": {
|
|
82
|
-
"optional": true
|
|
83
|
-
},
|
|
84
|
-
"esbuild": {
|
|
85
|
-
"optional": true
|
|
86
|
-
},
|
|
87
|
-
"js-yaml": {
|
|
88
|
-
"optional": true
|
|
89
79
|
}
|
|
90
80
|
}
|
|
91
81
|
}
|
|
File without changes
|