Replies: 4 comments 8 replies
-
I had better success with
|
Beta Was this translation helpful? Give feedback.
-
@autovaton @joebiker I just released a version this morning that hopefully should have better support for flat config + ESM. If you could give it another try, that would be great! |
Beta Was this translation helpful? Give feedback.
-
Hi, I have a similar problem with the plugin (version 1.6.2) - when I run the export default [ Any ideas why? |
Beta Was this translation helpful? Give feedback.
-
Here is the .eslintrc.js config that worked for me after much trial and
error if this is helpful.
```js
module.exports = {
env: {
commonjs: true,
node: true
},
extends: [
"eslint:all",
"eslint:recommended",
"plugin:playwright/recommended",
],
parser: ***@***.***/parser",
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
},
plugins: [
***@***.***",
"playwright",
],
overrides: [
{
files: ['*.ts', '*.tsx'], // Your TypeScript files extension
// As mentioned in the comments, you should extend TypeScript plugins
here,
// instead of extending them outside the overrides
// If you don't want to extend any rules, you don't need an extends
attribute.
extends: [
***@***.***/recommended',
***@***.***/eslint-recommended',
***@***.***/recommended-requiring-type-checking',
],
parser: ***@***.***/parser",
parserOptions: {
project: ['./tsconfig.json'], // Specify it only for TypeScript
files
},
},
],
rules: {
// **********************
// Javascript: Errors
// **********************
indent: ["error", 2, { "SwitchCase": 1 }],
semi: ["error", "always"],
"prefer-promise-reject-errors": ["error", { allowEmptyReject: true }],
// **********************
// Javascript: Ignores
// **********************
"max-classes-per-file": "off",
"max-lines": "off", //max lines per file
"max-lines-per-function": "off",
"max-statements": "off", //max statements per function
"sort-imports": "off",
"no-magic-numbers": "off",
"func-style": "off",
"multiline-comment-style": "off",
"capitalized-comments": "off",
"one-var": "off",
"sort-vars": "off",
"sort-keys": "off",
"no-ternary": "off",
"no-use-before-define": "off",
"init-declarations": "off",
"no-useless-constructor": "off",
"no-empty-function": "off",
"max-params": "off",
"no-plusplus": "off",
"line-comment-position": "off",
"no-inline-comments": "off",
"id-length": "off",
// **********************
// Javascript: Warnings
// **********************
"prefer-const": 'warn', // ts provides better types with const
"require-await": "warn",
"no-warning-comments": "warn",
"no-console": "warn",
"no-unmodified-loop-condition": "warn",
// **********************
// Typescript: Errors
// **********************
***@***.***/no-useless-constructor": "error",
***@***.***/no-empty-function": ["error", { "allow":
["constructors"] }],
***@***.***/unbound-method": ["error", { ignoreStatic: true }],
// **********************
// Typecript: Warnings
// **********************
***@***.***/no-unused-vars": "warn",
// **********************
// Playwright: Allows
// **********************
"playwright/no-conditional-in-test": "off",
// **********************
// Playwright: Errors
// **********************
"playwright/expect-expect": [
"error",
{
"additionalAssertFunctionNames": [
"singleItemExists",
"itemExists",
"singleItemIsVisible",
"itemWithTextExists",
"hasFormWithName",
"locatorItemsStartWithText",
"nLocatorItemsStartWithText"
]
}
],
"playwright/missing-playwright-await": ["error",],
"playwright/prefer-lowercase-title": ["error",],
"playwright/require-top-level-describe": ["error",],
"playwright/valid-expect": ["error",],
"playwright/valid-title": ["error",],
// **********************
// Playwright: Warnings
// **********************
"playwright/no-useless-await": ["warn",],
"playwright/no-focused-test": ["warn",],
"playwright/no-skipped-test": ["warn",],
"playwright/no-raw-locators": [
"warn",
{
"allowed": ["iframe", "[aria-busy='false']"]
}
],
"playwright/no-useless-not": ["warn",],
"playwright/prefer-to-contain": ["warn",],
"playwright/prefer-to-have-count": ["warn",],
"playwright/prefer-to-have-length": ["warn",],
"playwright/prefer-web-first-assertions": ["warn",],
"playwright/prefer-to-be": ["warn",],
"playwright/prefer-strict-equal": ["warn",]
}
};
```
|
Beta Was this translation helpful? Give feedback.
-
I installed eslint-plugin-playwright and it installed to the node_modules directory underneath my playwright project. I created an eslint.config.js file with the following structure:
import playwright from 'eslint-plugin-playwright';
export default [
playwright.configs['flat/recommended'],
{
rules: {
"playwright/expect-expect": [
"error"
],
},
},
];
I tried to run npx eslint and I got the error "Cannot use import statement outside a module". I added "type" : "module" to the package.json of my playwright directory, and now I am getting this error:
"The requested module 'eslint-plugin-playwright' does not provide an export named 'playwright'."
I am not sure what to do at this point, but thte README instructions do not seem to work as presented.
Any help would be appreciated. Thanks!
Beta Was this translation helpful? Give feedback.
All reactions