vasu-playwright-utils 1.22.2 → 1.23.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/README.md +48 -0
- package/eslint.config.base.mjs +159 -0
- package/package.json +14 -12
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.mjs` at your project root).
|
|
44
|
+
|
|
45
|
+
2. In your `eslint.config.mjs`, spread the library config:
|
|
46
|
+
|
|
47
|
+
```javascript
|
|
48
|
+
import playwrightLibConfig from 'vasu-playwright-utils/eslint';
|
|
49
|
+
|
|
50
|
+
export default [...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
|
+
import playwrightLibConfig from 'vasu-playwright-utils/eslint';
|
|
61
|
+
|
|
62
|
+
export default [
|
|
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,159 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shareable ESLint config for Playwright TypeScript projects.
|
|
3
|
+
* Single source of truth: used by this repo (via eslint.config.mjs) and by consumers (vasu-playwright-utils/eslint).
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* // eslint.config.mjs (in your project)
|
|
7
|
+
* import playwrightLibConfig from 'vasu-playwright-utils/eslint';
|
|
8
|
+
* export default [
|
|
9
|
+
* ...playwrightLibConfig,
|
|
10
|
+
* { rules: { 'playwright/no-focused-test': 'warn' } },
|
|
11
|
+
* ];
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import typescript from '@typescript-eslint/eslint-plugin';
|
|
15
|
+
import typescriptParser from '@typescript-eslint/parser';
|
|
16
|
+
import prettier from 'eslint-plugin-prettier';
|
|
17
|
+
import importPlugin from 'eslint-plugin-import';
|
|
18
|
+
import jsdoc from 'eslint-plugin-jsdoc';
|
|
19
|
+
import playwright from 'eslint-plugin-playwright';
|
|
20
|
+
import js from '@eslint/js';
|
|
21
|
+
import process from 'node:process';
|
|
22
|
+
|
|
23
|
+
// Works in this repo and when imported from other projects (consumer's cwd)
|
|
24
|
+
const projectRoot = process.cwd();
|
|
25
|
+
|
|
26
|
+
export default [
|
|
27
|
+
{
|
|
28
|
+
ignores: [
|
|
29
|
+
'node_modules/**',
|
|
30
|
+
'dist/**',
|
|
31
|
+
'build/**',
|
|
32
|
+
'coverage/**',
|
|
33
|
+
'.husky/**',
|
|
34
|
+
'**/*.js',
|
|
35
|
+
'package-lock.json',
|
|
36
|
+
],
|
|
37
|
+
},
|
|
38
|
+
js.configs.recommended,
|
|
39
|
+
{
|
|
40
|
+
files: ['**/*.ts'],
|
|
41
|
+
languageOptions: {
|
|
42
|
+
parser: typescriptParser,
|
|
43
|
+
parserOptions: {
|
|
44
|
+
project: './tsconfig.json',
|
|
45
|
+
tsconfigRootDir: projectRoot,
|
|
46
|
+
},
|
|
47
|
+
globals: {
|
|
48
|
+
console: 'readonly',
|
|
49
|
+
process: 'readonly',
|
|
50
|
+
Buffer: 'readonly',
|
|
51
|
+
__dirname: 'readonly',
|
|
52
|
+
__filename: 'readonly',
|
|
53
|
+
global: 'readonly',
|
|
54
|
+
module: 'readonly',
|
|
55
|
+
require: 'readonly',
|
|
56
|
+
exports: 'readonly',
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
plugins: {
|
|
60
|
+
'@typescript-eslint': typescript,
|
|
61
|
+
prettier,
|
|
62
|
+
import: importPlugin,
|
|
63
|
+
jsdoc,
|
|
64
|
+
playwright,
|
|
65
|
+
},
|
|
66
|
+
settings: { 'import/resolver': { typescript: { alwaysTryTypes: true } } },
|
|
67
|
+
rules: {
|
|
68
|
+
// Prettier Rules
|
|
69
|
+
'prettier/prettier': 'error',
|
|
70
|
+
'no-trailing-spaces': 'error',
|
|
71
|
+
'no-multiple-empty-lines': ['error', { max: 1, maxEOF: 0 }],
|
|
72
|
+
'eol-last': ['error', 'always'],
|
|
73
|
+
|
|
74
|
+
// TypeScript Rules - Base
|
|
75
|
+
...typescript.configs['eslint-recommended'].overrides[0].rules,
|
|
76
|
+
...typescript.configs.recommended.rules,
|
|
77
|
+
'@typescript-eslint/no-unsafe-assignment': 'warn',
|
|
78
|
+
'@typescript-eslint/no-unsafe-member-access': 'warn',
|
|
79
|
+
'@typescript-eslint/no-unsafe-return': 'warn',
|
|
80
|
+
'@typescript-eslint/no-unsafe-call': 'warn',
|
|
81
|
+
'@typescript-eslint/no-floating-promises': 'error',
|
|
82
|
+
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
|
|
83
|
+
'@typescript-eslint/no-explicit-any': 'warn',
|
|
84
|
+
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
|
85
|
+
|
|
86
|
+
// TypeScript Rules - Additional Strict Rules
|
|
87
|
+
'@typescript-eslint/no-unused-vars': [
|
|
88
|
+
'error',
|
|
89
|
+
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_' },
|
|
90
|
+
],
|
|
91
|
+
'@typescript-eslint/no-unused-expressions': 'error',
|
|
92
|
+
'@typescript-eslint/no-empty-function': 'warn',
|
|
93
|
+
'@typescript-eslint/prefer-nullish-coalescing': 'error',
|
|
94
|
+
'@typescript-eslint/prefer-optional-chain': 'error',
|
|
95
|
+
'@typescript-eslint/prefer-as-const': 'error',
|
|
96
|
+
'@typescript-eslint/no-non-null-assertion': 'warn',
|
|
97
|
+
'@typescript-eslint/no-duplicate-enum-values': 'error',
|
|
98
|
+
'@typescript-eslint/no-inferrable-types': [
|
|
99
|
+
'error',
|
|
100
|
+
{ ignoreParameters: false, ignoreProperties: false },
|
|
101
|
+
],
|
|
102
|
+
|
|
103
|
+
// Import Rules
|
|
104
|
+
'import/no-unresolved': 'error',
|
|
105
|
+
'import/named': 'error',
|
|
106
|
+
'import/default': 'error',
|
|
107
|
+
'import/no-absolute-path': 'error',
|
|
108
|
+
'import/no-self-import': 'error',
|
|
109
|
+
'import/first': 'error',
|
|
110
|
+
'import/no-mutable-exports': 'error',
|
|
111
|
+
'sort-imports': ['error', { ignoreDeclarationSort: true }],
|
|
112
|
+
|
|
113
|
+
// General Rules - Best Practices
|
|
114
|
+
'require-await': 'off',
|
|
115
|
+
'@typescript-eslint/require-await': 'error',
|
|
116
|
+
'@typescript-eslint/await-thenable': 'error',
|
|
117
|
+
'@typescript-eslint/no-misused-promises': 'error',
|
|
118
|
+
complexity: ['warn', { max: 11 }],
|
|
119
|
+
'no-console': ['warn', { allow: ['warn', 'error', 'info'] }],
|
|
120
|
+
'no-debugger': 'error',
|
|
121
|
+
'no-var': 'error',
|
|
122
|
+
'prefer-const': 'error',
|
|
123
|
+
'prefer-template': 'error',
|
|
124
|
+
'object-shorthand': 'error',
|
|
125
|
+
'no-lonely-if': 'error',
|
|
126
|
+
'no-useless-return': 'error',
|
|
127
|
+
'no-nested-ternary': 'warn',
|
|
128
|
+
eqeqeq: ['error', 'always', { null: 'ignore' }],
|
|
129
|
+
'no-throw-literal': 'error',
|
|
130
|
+
|
|
131
|
+
// JSDoc Rules
|
|
132
|
+
'jsdoc/check-alignment': 'off',
|
|
133
|
+
'jsdoc/check-indentation': 'off',
|
|
134
|
+
|
|
135
|
+
// Playwright recommended rules
|
|
136
|
+
...playwright.configs['playwright-test'].rules,
|
|
137
|
+
|
|
138
|
+
// Playwright Rules
|
|
139
|
+
'playwright/missing-playwright-await': 'error',
|
|
140
|
+
'playwright/no-focused-test': 'error',
|
|
141
|
+
'playwright/valid-expect': 'error',
|
|
142
|
+
'playwright/prefer-web-first-assertions': 'error',
|
|
143
|
+
'playwright/no-useless-await': 'error',
|
|
144
|
+
'playwright/no-page-pause': 'error',
|
|
145
|
+
'playwright/no-element-handle': 'error',
|
|
146
|
+
'playwright/no-eval': 'error',
|
|
147
|
+
'playwright/prefer-to-be': 'error',
|
|
148
|
+
'playwright/prefer-to-contain': 'error',
|
|
149
|
+
'playwright/prefer-to-have-length': 'error',
|
|
150
|
+
'playwright/no-wait-for-timeout': 'warn',
|
|
151
|
+
'playwright/no-useless-not': 'warn',
|
|
152
|
+
'playwright/require-top-level-describe': 'off',
|
|
153
|
+
'playwright/expect-expect': 'off',
|
|
154
|
+
'playwright/no-conditional-in-test': 'off',
|
|
155
|
+
'playwright/no-skipped-test': 'off',
|
|
156
|
+
'playwright/consistent-spacing-between-blocks': 'off',
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
];
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vasu-playwright-utils",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.23.1",
|
|
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.mjs",
|
|
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.mjs"
|
|
44
46
|
],
|
|
45
47
|
"engines": {
|
|
46
|
-
"node": ">=
|
|
48
|
+
"node": ">=20.0.0"
|
|
47
49
|
},
|
|
48
50
|
"dependencies": {
|
|
49
|
-
"@eslint/js": "^9.39.
|
|
50
|
-
"@types/node": "^25.2
|
|
51
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
52
|
-
"@typescript-eslint/parser": "^8.
|
|
51
|
+
"@eslint/js": "^9.39.3",
|
|
52
|
+
"@types/node": "^25.3.2",
|
|
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.
|
|
55
|
-
"eslint": "^9.39.
|
|
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.
|
|
60
|
-
"eslint-plugin-playwright": "^2.
|
|
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.
|
|
67
|
+
"rimraf": "^6.1.3",
|
|
66
68
|
"tslib": "^2.8.1",
|
|
67
69
|
"typescript": "5.9.3",
|
|
68
70
|
"winston": "^3.19.0"
|