Below is the contents of my package.json
file:
{
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^5.13.0",
"@typescript-eslint/parser": "^5.13.0",
"airbnb": "^0.0.2",
"cypress": "^9.5.1",
"cypress-cucumber-preprocessor": "^4.3.1",
"eslint": "^8.10.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-plugin-airbnb": "^0.0.1-security",
"eslint-plugin-chai-friendly": "^0.7.2",
"eslint-plugin-cypress": "^2.12.1",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-react": "^7.29.3",
"eslint-plugin-react-hooks": "^4.3.0",
"typescript": "^4.6.2"
},
"cypress-cucumber-preprocessor": {
"nonGlobalStepDefinitions": true
}
}
Following is the configuration in my .eslintrc.js
file:
module.exports = {
env: {
browser: true,
es2021: true,
},
extends: [
'airbnb',
'plugin:react/recommended',
'plugin:chai-friendly/recommended',
'plugin:cypress/recommended'
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 'latest',
sourceType: 'module',
},
plugins: [
'react',
'@typescript-eslint/eslint-plugin',
'cypress',
'chai-friendly'
],
rules: {
'cypress/require-data-selectors': 'warn'
},
};
Encountering an error in VScode while saving a TypeScript file, as shown below:
[Error - 9:40:31 AM] Request textDocument/codeAction failed.
Message: Request textDocument/codeAction failed with message: Failed to load plugin '@typescript-eslint/eslint-plugin' declared in '.eslintrc.js': Cannot find module '/home/alex/_code/cypress/node_modules/tsutils/node_modules/tslib/tslib.js'
Code: -32603
(node:990) UnhandledPromiseRejectionWarning: Error: Failed to load plugin '@typescript-eslint/eslint-plugin' declared in '.eslintrc.js': Cannot find module '/home/alex/_code/cypress/node_modules/tsutils/node_modules/tslib/tslib.js'
at createEsmNotFoundErr (internal/modules/cjs/loader.js:907:15)
at finalizeEsmResolution (internal/modules/cjs/loader.js:900:15)
at resolveExports (internal/modules/cjs/loader.js:432:14)
at Function.Module._findPath (internal/modules/cjs/loader.js:472:31)
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:867:27)
at Function.Module._load (internal/modules/cjs/loader.js:725:27)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (/home/alex/_code/cypress/node_modules/tsutils/index.js:3:17)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
(node:990) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 281)