mirror of
https://github.com/IT4Change/boilerplate-e2e-cypress-cucumber.git
synced 2025-12-12 20:55:48 +00:00
add linting
This commit is contained in:
parent
8982c206de
commit
b4c161fd82
1
.eslintignore
Normal file
1
.eslintignore
Normal file
@ -0,0 +1 @@
|
|||||||
|
node_modules/
|
||||||
158
.eslintrc.cjs
Normal file
158
.eslintrc.cjs
Normal file
@ -0,0 +1,158 @@
|
|||||||
|
// eslint-disable-next-line import/no-commonjs
|
||||||
|
module.exports = {
|
||||||
|
env: {
|
||||||
|
browser: true,
|
||||||
|
es2021: true,
|
||||||
|
},
|
||||||
|
extends: [
|
||||||
|
'standard',
|
||||||
|
'eslint:recommended',
|
||||||
|
'plugin:@eslint-community/eslint-comments/recommended',
|
||||||
|
'plugin:@typescript-eslint/recommended',
|
||||||
|
'plugin:import/recommended',
|
||||||
|
'plugin:import/typescript',
|
||||||
|
'plugin:security/recommended-legacy',
|
||||||
|
],
|
||||||
|
parserOptions: {
|
||||||
|
ecmaVersion: 'latest',
|
||||||
|
parser: '@typescript-eslint/parser',
|
||||||
|
sourceType: 'module',
|
||||||
|
},
|
||||||
|
plugins: ['cypress', '@typescript-eslint', 'import'],
|
||||||
|
settings: {
|
||||||
|
'import/resolver': {
|
||||||
|
typescript: true,
|
||||||
|
node: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
'no-console': 'error',
|
||||||
|
'no-debugger': 'error',
|
||||||
|
camelcase: 'error',
|
||||||
|
indent: ['error', 2],
|
||||||
|
'linebreak-style': ['error', 'unix'],
|
||||||
|
semi: ['error', 'never'],
|
||||||
|
// Optional eslint-comments rule
|
||||||
|
'@eslint-community/eslint-comments/no-unused-disable': 'error',
|
||||||
|
'@eslint-community/eslint-comments/disable-enable-pair': ['error', { allowWholeFile: true }],
|
||||||
|
// import
|
||||||
|
'import/export': 'error',
|
||||||
|
'import/no-deprecated': 'error',
|
||||||
|
'import/no-empty-named-blocks': 'error',
|
||||||
|
'import/no-extraneous-dependencies': 'error',
|
||||||
|
'import/no-mutable-exports': 'error',
|
||||||
|
'import/no-unused-modules': 'error',
|
||||||
|
'import/no-named-as-default': 'error',
|
||||||
|
'import/no-named-as-default-member': 'error',
|
||||||
|
'import/no-amd': 'error',
|
||||||
|
'import/no-commonjs': 'error',
|
||||||
|
'import/no-import-module-exports': 'error',
|
||||||
|
'import/no-nodejs-modules': 'off',
|
||||||
|
'import/unambiguous': 'off',
|
||||||
|
'import/default': 'error',
|
||||||
|
'import/named': 'error',
|
||||||
|
'import/namespace': 'error',
|
||||||
|
'import/no-absolute-path': 'error',
|
||||||
|
'import/no-cycle': 'error',
|
||||||
|
'import/no-dynamic-require': 'error',
|
||||||
|
'import/no-internal-modules': 'off',
|
||||||
|
'import/no-relative-packages': 'error',
|
||||||
|
'import/no-relative-parent-imports': [
|
||||||
|
'error',
|
||||||
|
{ ignore: ['#[src,root,components,pages,assets,layouts,stores,plugins,context,types]/*'] },
|
||||||
|
],
|
||||||
|
'import/no-self-import': 'error',
|
||||||
|
'import/no-unresolved': 'error',
|
||||||
|
'import/no-useless-path-segments': 'error',
|
||||||
|
'import/no-webpack-loader-syntax': 'error',
|
||||||
|
'import/consistent-type-specifier-style': 'error',
|
||||||
|
'import/exports-last': 'off',
|
||||||
|
'import/extensions': [
|
||||||
|
'error',
|
||||||
|
'never',
|
||||||
|
{
|
||||||
|
json: 'always',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
'import/first': 'error',
|
||||||
|
'import/group-exports': 'off',
|
||||||
|
'import/newline-after-import': 'error',
|
||||||
|
'import/no-anonymous-default-export': 'off', // todo - consider to enable again
|
||||||
|
'import/no-default-export': 'off', // incompatible with vite & vike
|
||||||
|
'import/no-duplicates': 'error',
|
||||||
|
'import/no-named-default': 'error',
|
||||||
|
'import/no-namespace': 'error',
|
||||||
|
'import/no-unassigned-import': 'error',
|
||||||
|
'import/order': [
|
||||||
|
'error',
|
||||||
|
{
|
||||||
|
groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index', 'object', 'type'],
|
||||||
|
'newlines-between': 'always',
|
||||||
|
alphabetize: {
|
||||||
|
order: 'asc', // sort in ascending order. Options: ["ignore", "asc", "desc"]
|
||||||
|
caseInsensitive: true, // ignore case. Options: [true, false]
|
||||||
|
},
|
||||||
|
distinctGroup: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
'import/prefer-default-export': 'off',
|
||||||
|
// promise
|
||||||
|
'promise/catch-or-return': 'error',
|
||||||
|
'promise/no-return-wrap': 'error',
|
||||||
|
'promise/param-names': 'error',
|
||||||
|
'promise/always-return': 'error',
|
||||||
|
'promise/no-native': 'off',
|
||||||
|
'promise/no-nesting': 'warn',
|
||||||
|
'promise/no-promise-in-callback': 'warn',
|
||||||
|
'promise/no-callback-in-promise': 'warn',
|
||||||
|
'promise/avoid-new': 'warn',
|
||||||
|
'promise/no-new-statics': 'error',
|
||||||
|
'promise/no-return-in-finally': 'warn',
|
||||||
|
'promise/valid-params': 'warn',
|
||||||
|
'promise/prefer-await-to-callbacks': 'error',
|
||||||
|
'promise/no-multiple-resolved': 'error',
|
||||||
|
},
|
||||||
|
overrides: [
|
||||||
|
{
|
||||||
|
files: ['*.ts', '*.tsx'],
|
||||||
|
parser: '@typescript-eslint/parser',
|
||||||
|
parserOptions: {
|
||||||
|
tsconfigRootDir: __dirname,
|
||||||
|
project: ['./tsconfig.json', '**/tsconfig.json'],
|
||||||
|
ecmaVersion: 'latest',
|
||||||
|
parser: '@typescript-eslint/parser',
|
||||||
|
sourceType: 'module',
|
||||||
|
},
|
||||||
|
plugins: ['@typescript-eslint'],
|
||||||
|
extends: [
|
||||||
|
'plugin:@typescript-eslint/recommended',
|
||||||
|
'plugin:@typescript-eslint/recommended-requiring-type-checking',
|
||||||
|
'plugin:@typescript-eslint/strict',
|
||||||
|
],
|
||||||
|
rules: {
|
||||||
|
// allow explicitly defined dangling promises
|
||||||
|
'@typescript-eslint/no-floating-promises': ['error', { ignoreVoid: true }],
|
||||||
|
'no-void': ['error', { allowAsStatement: true }],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
files: ['!*.json'],
|
||||||
|
plugins: ['prettier'],
|
||||||
|
extends: ['plugin:prettier/recommended'],
|
||||||
|
rules: {
|
||||||
|
'prettier/prettier': 'error',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
files: ['*.json'],
|
||||||
|
plugins: ['json'],
|
||||||
|
extends: ['plugin:json/recommended-with-comments'],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
files: ['*.yaml', '*.yml'],
|
||||||
|
parser: 'yaml-eslint-parser',
|
||||||
|
plugins: ['yml'],
|
||||||
|
extends: ['plugin:yml/prettier'],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
14
.prettierrc.json
Normal file
14
.prettierrc.json
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"printWidth": 100,
|
||||||
|
"tabWidth": 2,
|
||||||
|
"useTabs": false,
|
||||||
|
"semi": false,
|
||||||
|
"singleQuote": true,
|
||||||
|
"quoteProps": "as-needed",
|
||||||
|
"jsxSingleQuote": true,
|
||||||
|
"trailingComma": "all",
|
||||||
|
"bracketSpacing": true,
|
||||||
|
"bracketSameLine": false,
|
||||||
|
"arrowParens": "always",
|
||||||
|
"endOfLine": "auto"
|
||||||
|
}
|
||||||
@ -1,6 +1,6 @@
|
|||||||
import { defineConfig } from 'cypress'
|
|
||||||
import { addCucumberPreprocessorPlugin } from '@badeball/cypress-cucumber-preprocessor'
|
import { addCucumberPreprocessorPlugin } from '@badeball/cypress-cucumber-preprocessor'
|
||||||
import webpack from '@cypress/webpack-preprocessor'
|
import webpack from '@cypress/webpack-preprocessor'
|
||||||
|
import { defineConfig } from 'cypress'
|
||||||
|
|
||||||
const setupNodeEvents = async (on: Cypress.PluginEvents, config: Cypress.PluginConfigOptions) => {
|
const setupNodeEvents = async (on: Cypress.PluginEvents, config: Cypress.PluginConfigOptions) => {
|
||||||
await addCucumberPreprocessorPlugin(on, config, {
|
await addCucumberPreprocessorPlugin(on, config, {
|
||||||
@ -39,7 +39,7 @@ const setupNodeEvents = async (on: Cypress.PluginEvents, config: Cypress.PluginC
|
|||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
return config;
|
return config
|
||||||
}
|
}
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
@ -48,8 +48,8 @@ export default defineConfig({
|
|||||||
baseUrl: 'https://the-internet.herokuapp.com/',
|
baseUrl: 'https://the-internet.herokuapp.com/',
|
||||||
specPattern: 'cypress/e2e/features/*.feature',
|
specPattern: 'cypress/e2e/features/*.feature',
|
||||||
supportFile: false,
|
supportFile: false,
|
||||||
retries: 0,
|
retries: 0,
|
||||||
video: false,
|
video: false,
|
||||||
setupNodeEvents,
|
setupNodeEvents,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
@ -1,16 +1,13 @@
|
|||||||
import {
|
import { Given, When, Then } from '@badeball/cypress-cucumber-preprocessor'
|
||||||
Given,
|
|
||||||
When,
|
import { loginPage } from '../../pages/LoginPage'
|
||||||
Then,
|
import { welcomePage } from '../../pages/WelcomePage'
|
||||||
} from '@badeball/cypress-cucumber-preprocessor'
|
|
||||||
import {loginPage} from '../../pages/LoginPage'
|
|
||||||
import {welcomePage} from '../../pages/WelcomePage'
|
|
||||||
|
|
||||||
Given('The web browser is at the login page', () => {
|
Given('The web browser is at the login page', () => {
|
||||||
cy.visit('/login')
|
cy.visit('/login')
|
||||||
})
|
})
|
||||||
|
|
||||||
When('I submit the credentials {string} {string}', (username:string, password: string) => {
|
When('I submit the credentials {string} {string}', (username: string, password: string) => {
|
||||||
loginPage.submitLogin(username, password)
|
loginPage.submitLogin(username, password)
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -18,4 +15,4 @@ Then('I am on the welcome page', () => {
|
|||||||
cy.get(welcomePage.successMessage).should('be.visible')
|
cy.get(welcomePage.successMessage).should('be.visible')
|
||||||
cy.get(welcomePage.WelcomeHeader).should('be.visible')
|
cy.get(welcomePage.WelcomeHeader).should('be.visible')
|
||||||
cy.get(welcomePage.logoutBtn).should('be.visible')
|
cy.get(welcomePage.logoutBtn).should('be.visible')
|
||||||
})
|
})
|
||||||
|
|||||||
@ -1,13 +1,13 @@
|
|||||||
class LoginPage {
|
class LoginPage {
|
||||||
usernameInput: string = '#username'
|
usernameInput: string = '#username'
|
||||||
passwordInput:string = '#password'
|
passwordInput: string = '#password'
|
||||||
submitBtn: string = 'button[type=submit]'
|
submitBtn: string = 'button[type=submit]'
|
||||||
|
|
||||||
submitLogin(username: string, password: string){
|
submitLogin(username: string, password: string) {
|
||||||
cy.get(this.usernameInput).type(username)
|
cy.get(this.usernameInput).type(username)
|
||||||
cy.get(this.passwordInput).type(password)
|
cy.get(this.passwordInput).type(password)
|
||||||
cy.get(this.submitBtn).click()
|
cy.get(this.submitBtn).click()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const loginPage = new LoginPage()
|
export const loginPage = new LoginPage()
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
class WelcomePage {
|
class WelcomePage {
|
||||||
successMessage: string = '.flash.success'
|
successMessage: string = '.flash.success'
|
||||||
WelcomeHeader:string = '.subheader'
|
WelcomeHeader: string = '.subheader'
|
||||||
logoutBtn: string = 'a[href="/logout"]'
|
logoutBtn: string = 'a[href="/logout"]'
|
||||||
}
|
}
|
||||||
|
|
||||||
export const welcomePage = new WelcomePage()
|
export const welcomePage = new WelcomePage()
|
||||||
|
|||||||
2630
package-lock.json
generated
2630
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
20
package.json
20
package.json
@ -25,16 +25,34 @@
|
|||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"cypress:open": "cypress open --e2e --browser electron",
|
"cypress:open": "cypress open --e2e --browser electron",
|
||||||
"cypress:run": "cypress run"
|
"cypress:run": "cypress run --e2e --browser electron",
|
||||||
|
"test:lint:eslint": "eslint --ext .ts,.tsx,.js,.jsx,.cjs,.json,.yml,.yaml --max-warnings 0 ."
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@badeball/cypress-cucumber-preprocessor": "^20.0.1",
|
"@badeball/cypress-cucumber-preprocessor": "^20.0.1",
|
||||||
"@cypress/webpack-preprocessor": "^6.0.1",
|
"@cypress/webpack-preprocessor": "^6.0.1",
|
||||||
|
"@eslint-community/eslint-plugin-eslint-comments": "^4.1.0",
|
||||||
|
"@typescript-eslint/eslint-plugin": "^7.0.1",
|
||||||
|
"@typescript-eslint/parser": "^7.0.1",
|
||||||
"cypress": "^13.6.4",
|
"cypress": "^13.6.4",
|
||||||
|
"eslint": "^8.56.0",
|
||||||
|
"eslint-config-prettier": "^9.1.0",
|
||||||
|
"eslint-config-standard": "^17.1.0",
|
||||||
|
"eslint-import-resolver-typescript": "^3.6.1",
|
||||||
|
"eslint-plugin-cypress": "^2.15.1",
|
||||||
|
"eslint-plugin-import": "^2.29.1",
|
||||||
|
"eslint-plugin-json": "^3.1.0",
|
||||||
|
"eslint-plugin-prettier": "^5.1.3",
|
||||||
|
"eslint-plugin-security": "^2.1.1",
|
||||||
|
"eslint-plugin-yml": "^1.12.2",
|
||||||
"multiple-cucumber-html-reporter": "^3.6.2",
|
"multiple-cucumber-html-reporter": "^3.6.2",
|
||||||
|
"prettier": "^3.2.5",
|
||||||
"ts-loader": "^9.5.1",
|
"ts-loader": "^9.5.1",
|
||||||
"typescript": "^5.3.3"
|
"typescript": "^5.3.3"
|
||||||
},
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "^20.2.0"
|
||||||
|
},
|
||||||
"cypress-cucumber-preprocessor": {
|
"cypress-cucumber-preprocessor": {
|
||||||
"nonGlobalStepDefinitions": true,
|
"nonGlobalStepDefinitions": true,
|
||||||
"stepDefinitions": "cypress/e2e/step_definitions/**/*.{js,ts}",
|
"stepDefinitions": "cypress/e2e/step_definitions/**/*.{js,ts}",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user