vasu-playwright-utils 1.22.2 → 1.23.0

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/README.md CHANGED
@@ -13,6 +13,7 @@
13
13
 
14
14
  - [Installation](#installation)
15
15
  - [Usage](#usage)
16
+ - [ESLint](#eslint)
16
17
  - [License](#license)
17
18
 
18
19
  ## Installation
@@ -33,6 +34,53 @@ import { click, fill } from 'vasu-playwright-utils';
33
34
  // Your code here
34
35
  ```
35
36
 
37
+ ## ESLint
38
+
39
+ This library ships a shareable ESLint config for Playwright TypeScript projects. Install the library (it includes the required ESLint plugins), then extend the config in your project and override any rules as needed.
40
+
41
+ ### Using the config
42
+
43
+ 1. Use **ESLint 9 flat config** (`eslint.config.js` at your project root).
44
+
45
+ 2. In your `eslint.config.js`, spread the library config:
46
+
47
+ ```javascript
48
+ const playwrightLibConfig = require('vasu-playwright-utils/eslint');
49
+
50
+ module.exports = [...playwrightLibConfig];
51
+ ```
52
+
53
+ 3. Ensure your project has a `tsconfig.json` at the root (the config uses it for TypeScript parsing).
54
+
55
+ ### Overriding rules
56
+
57
+ Add config objects after the spread to override or relax rules:
58
+
59
+ ```javascript
60
+ const playwrightLibConfig = require('vasu-playwright-utils/eslint');
61
+
62
+ module.exports = [
63
+ ...playwrightLibConfig,
64
+ // Override specific rules
65
+ {
66
+ rules: {
67
+ 'playwright/no-focused-test': 'warn',
68
+ 'playwright/no-wait-for-timeout': 'off',
69
+ 'no-console': 'off',
70
+ },
71
+ },
72
+ // Or override only for certain files
73
+ {
74
+ files: ['tests/**/*.ts'],
75
+ rules: {
76
+ 'playwright/expect-expect': 'error',
77
+ },
78
+ },
79
+ ];
80
+ ```
81
+
82
+ Later entries in the config array override earlier ones, so your overrides take precedence.
83
+
36
84
  ## Issues and Feedback
37
85
 
38
86
  If you encounter any issues or have feedback, please [Raise an Issue](https://github.com/vasu31dev/playwright-ts-lib/issues) on GitHub.
@@ -0,0 +1,158 @@
1
+ /**
2
+ * Shareable ESLint config for Playwright TypeScript projects.
3
+ * Single source of truth: used by this repo (via eslint.config.js) and by consumers (vasu-playwright-utils/eslint).
4
+ *
5
+ * @example
6
+ * // eslint.config.js (in your project)
7
+ * const playwrightLibConfig = require('vasu-playwright-utils/eslint');
8
+ * module.exports = [
9
+ * ...playwrightLibConfig,
10
+ * { rules: { 'playwright/no-focused-test': 'warn' } },
11
+ * ];
12
+ */
13
+
14
+ const typescript = require('@typescript-eslint/eslint-plugin');
15
+ const typescriptParser = require('@typescript-eslint/parser');
16
+ const prettier = require('eslint-plugin-prettier');
17
+ const importPlugin = require('eslint-plugin-import');
18
+ const jsdoc = require('eslint-plugin-jsdoc');
19
+ const playwright = require('eslint-plugin-playwright');
20
+ const js = require('@eslint/js');
21
+
22
+ // Works in this repo and when required from other projects (consumer's cwd)
23
+ const projectRoot = require('process').cwd();
24
+
25
+ module.exports = [
26
+ {
27
+ ignores: [
28
+ 'node_modules/**',
29
+ 'dist/**',
30
+ 'build/**',
31
+ 'coverage/**',
32
+ '.husky/**',
33
+ '**/*.js',
34
+ 'package-lock.json',
35
+ ],
36
+ },
37
+ js.configs.recommended,
38
+ {
39
+ files: ['**/*.ts'],
40
+ languageOptions: {
41
+ parser: typescriptParser,
42
+ parserOptions: {
43
+ project: './tsconfig.json',
44
+ tsconfigRootDir: projectRoot,
45
+ },
46
+ globals: {
47
+ console: 'readonly',
48
+ process: 'readonly',
49
+ Buffer: 'readonly',
50
+ __dirname: 'readonly',
51
+ __filename: 'readonly',
52
+ global: 'readonly',
53
+ module: 'readonly',
54
+ require: 'readonly',
55
+ exports: 'readonly',
56
+ },
57
+ },
58
+ plugins: {
59
+ '@typescript-eslint': typescript,
60
+ prettier,
61
+ import: importPlugin,
62
+ jsdoc,
63
+ playwright,
64
+ },
65
+ settings: { 'import/resolver': { typescript: { alwaysTryTypes: true } } },
66
+ rules: {
67
+ // Prettier Rules
68
+ 'prettier/prettier': 'error',
69
+ 'no-trailing-spaces': 'error',
70
+ 'no-multiple-empty-lines': ['error', { max: 1, maxEOF: 0 }],
71
+ 'eol-last': ['error', 'always'],
72
+
73
+ // TypeScript Rules - Base
74
+ ...typescript.configs['eslint-recommended'].overrides[0].rules,
75
+ ...typescript.configs.recommended.rules,
76
+ '@typescript-eslint/no-unsafe-assignment': 'warn',
77
+ '@typescript-eslint/no-unsafe-member-access': 'warn',
78
+ '@typescript-eslint/no-unsafe-return': 'warn',
79
+ '@typescript-eslint/no-unsafe-call': 'warn',
80
+ '@typescript-eslint/no-floating-promises': 'error',
81
+ '@typescript-eslint/no-unnecessary-type-assertion': 'error',
82
+ '@typescript-eslint/no-explicit-any': 'warn',
83
+ '@typescript-eslint/explicit-module-boundary-types': 'off',
84
+
85
+ // TypeScript Rules - Additional Strict Rules
86
+ '@typescript-eslint/no-unused-vars': [
87
+ 'error',
88
+ { argsIgnorePattern: '^_', varsIgnorePattern: '^_' },
89
+ ],
90
+ '@typescript-eslint/no-unused-expressions': 'error',
91
+ '@typescript-eslint/no-empty-function': 'warn',
92
+ '@typescript-eslint/prefer-nullish-coalescing': 'error',
93
+ '@typescript-eslint/prefer-optional-chain': 'error',
94
+ '@typescript-eslint/prefer-as-const': 'error',
95
+ '@typescript-eslint/no-non-null-assertion': 'warn',
96
+ '@typescript-eslint/no-duplicate-enum-values': 'error',
97
+ '@typescript-eslint/no-inferrable-types': [
98
+ 'error',
99
+ { ignoreParameters: false, ignoreProperties: false },
100
+ ],
101
+
102
+ // Import Rules
103
+ 'import/no-unresolved': 'error',
104
+ 'import/named': 'error',
105
+ 'import/default': 'error',
106
+ 'import/no-absolute-path': 'error',
107
+ 'import/no-self-import': 'error',
108
+ 'import/first': 'error',
109
+ 'import/no-mutable-exports': 'error',
110
+ 'sort-imports': ['error', { ignoreDeclarationSort: true }],
111
+
112
+ // General Rules - Best Practices
113
+ 'require-await': 'off',
114
+ '@typescript-eslint/require-await': 'error',
115
+ '@typescript-eslint/await-thenable': 'error',
116
+ '@typescript-eslint/no-misused-promises': 'error',
117
+ complexity: ['warn', { max: 11 }],
118
+ 'no-console': ['warn', { allow: ['warn', 'error', 'info'] }],
119
+ 'no-debugger': 'error',
120
+ 'no-var': 'error',
121
+ 'prefer-const': 'error',
122
+ 'prefer-template': 'error',
123
+ 'object-shorthand': 'error',
124
+ 'no-lonely-if': 'error',
125
+ 'no-useless-return': 'error',
126
+ 'no-nested-ternary': 'warn',
127
+ eqeqeq: ['error', 'always', { null: 'ignore' }],
128
+ 'no-throw-literal': 'error',
129
+
130
+ // JSDoc Rules
131
+ 'jsdoc/check-alignment': 'off',
132
+ 'jsdoc/check-indentation': 'off',
133
+
134
+ // Playwright recommended rules
135
+ ...playwright.configs['playwright-test'].rules,
136
+
137
+ // Playwright Rules
138
+ 'playwright/missing-playwright-await': 'error',
139
+ 'playwright/no-focused-test': 'error',
140
+ 'playwright/valid-expect': 'error',
141
+ 'playwright/prefer-web-first-assertions': 'error',
142
+ 'playwright/no-useless-await': 'error',
143
+ 'playwright/no-page-pause': 'error',
144
+ 'playwright/no-element-handle': 'error',
145
+ 'playwright/no-eval': 'error',
146
+ 'playwright/prefer-to-be': 'error',
147
+ 'playwright/prefer-to-contain': 'error',
148
+ 'playwright/prefer-to-have-length': 'error',
149
+ 'playwright/no-wait-for-timeout': 'warn',
150
+ 'playwright/no-useless-not': 'warn',
151
+ 'playwright/require-top-level-describe': 'off',
152
+ 'playwright/expect-expect': 'off',
153
+ 'playwright/no-conditional-in-test': 'off',
154
+ 'playwright/no-skipped-test': 'off',
155
+ 'playwright/consistent-spacing-between-blocks': 'off',
156
+ },
157
+ },
158
+ ];
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "vasu-playwright-utils",
3
- "version": "1.22.2",
3
+ "version": "1.23.0",
4
4
  "description": "Playwright Typescript Library with reusable utilities",
5
5
  "main": "./dist/src/vasu-playwright-lib/index.js",
6
6
  "types": "./dist/src/vasu-playwright-lib/index.d.ts",
7
7
  "exports": {
8
8
  ".": "./dist/src/vasu-playwright-lib/index.js",
9
+ "./eslint": "./eslint.config.base.js",
9
10
  "./action-utils": "./dist/src/vasu-playwright-lib/utils/action-utils.js",
10
11
  "./assert-utils": "./dist/src/vasu-playwright-lib/utils/assert-utils.js",
11
12
  "./element-utils": "./dist/src/vasu-playwright-lib/utils/element-utils.js",
@@ -40,29 +41,30 @@
40
41
  },
41
42
  "files": [
42
43
  "dist",
43
- "src"
44
+ "src",
45
+ "eslint.config.base.js"
44
46
  ],
45
47
  "engines": {
46
- "node": ">=18.0.0"
48
+ "node": ">=20.0.0"
47
49
  },
48
50
  "dependencies": {
49
51
  "@eslint/js": "^9.39.2",
50
- "@types/node": "^25.2.3",
51
- "@typescript-eslint/eslint-plugin": "^8.55.0",
52
- "@typescript-eslint/parser": "^8.55.0",
52
+ "@types/node": "^25.3.1",
53
+ "@typescript-eslint/eslint-plugin": "^8.56.1",
54
+ "@typescript-eslint/parser": "^8.56.1",
53
55
  "cross-env": "^10.1.0",
54
- "dotenv": "^17.2.4",
55
- "eslint": "^9.39.2",
56
+ "dotenv": "^17.3.1",
57
+ "eslint": "^9.39.3",
56
58
  "eslint-config-prettier": "^10.1.8",
57
59
  "eslint-import-resolver-typescript": "^4.4.4",
58
60
  "eslint-plugin-import": "^2.32.0",
59
- "eslint-plugin-jsdoc": "^62.5.4",
60
- "eslint-plugin-playwright": "^2.5.1",
61
+ "eslint-plugin-jsdoc": "^62.7.1",
62
+ "eslint-plugin-playwright": "^2.7.1",
61
63
  "eslint-plugin-prettier": "^5.5.5",
62
64
  "husky": "^9.1.7",
63
65
  "lint-staged": "^16.2.7",
64
66
  "prettier": "^3.8.1",
65
- "rimraf": "^6.1.2",
67
+ "rimraf": "^6.1.3",
66
68
  "tslib": "^2.8.1",
67
69
  "typescript": "5.9.3",
68
70
  "winston": "^3.19.0"