Skip to content

Commit

Permalink
refactor: support es6 & fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
yihuineng committed Oct 12, 2023
1 parent ac1e276 commit 8b9d4fa
Show file tree
Hide file tree
Showing 43 changed files with 637 additions and 754 deletions.
1 change: 0 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
**/.*
**/node_modules
**/build
**/test
**/wd/doc
**/logs
**/theme
166 changes: 0 additions & 166 deletions .eslintrc

This file was deleted.

35 changes: 35 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
module.exports = {
root: true,
extends: 'eslint-config-egg/typescript',
globals: {
window: true,
},
rules: {
'jsdoc/check-tag-names': 0,
'valid-jsdoc': 0,
'no-script-url': 0,
'no-multi-spaces': 0,
'default-case': 0,
'no-case-declarations': 0,
'one-var-declaration-per-line': 0,
'no-restricted-syntax': 0,
'jsdoc/require-param': 0,
'jsdoc/check-param-names': 0,
'jsdoc/require-param-description': 0,
'jsdoc/require-returns-description': 0,
'arrow-parens': 0,
'prefer-promise-reject-errors': 0,
'no-control-regex': 0,
'no-use-before-define': 0,
'array-callback-return': 0,
'no-bitwise': 0,
'no-self-compare': 0,
'@typescript-eslint/no-var-requires': 0,
'@typescript-eslint/ban-ts-ignore': 0,
'@typescript-eslint/no-use-before-define': 0,
'@typescript-eslint/no-this-alias': 0,
'one-var': 0,
'no-sparse-arrays': 0,
'no-useless-concat': 0,
},
};
16 changes: 8 additions & 8 deletions lib/helper/assert.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'use strict';


const { assert } = require('chai');

Expand All @@ -13,7 +13,7 @@ module.exports = wd => {
* @summary Support: Web(WebView)
* @param {string} text content.
* @type assert
* @returns {Promise.<boolean>}
* @return {Promise.<boolean>}
*/
wd.addElementPromiseChainMethod('hasText', function(...texts) {
return this.text().then(shouldContains(...texts));
Expand All @@ -25,7 +25,7 @@ module.exports = wd => {
* @summary Support: Web(WebView)
* @param {string} text content.
* @type assert
* @returns {Promise.<boolean>}
* @return {Promise.<boolean>}
*/
wd.addPromiseChainMethod('hasElementByCss', function(cssSelector) {
return this.elementByCssIfExists(cssSelector).then(d => {
Expand All @@ -41,13 +41,13 @@ module.exports = wd => {
* @summary Support: Web(WebView)
* @param {string} title - title of the web page.
* @type assert
* @returns {Promise.<boolean>}
* @return {Promise.<boolean>}
*/
wd.addPromiseChainMethod('assertTitle', function(title) {
return this.title().then(realTitle => {
assert(
title === realTitle,
`expect title to be '${title}' but got ${realTitle}`
`expect title to be '${title}' but got ${realTitle}`,
);
});
});
Expand All @@ -59,15 +59,15 @@ module.exports = wd => {
* @param {string} attribute - attribute's name.
* @param {string} value - expected value.
* @type assert
* @returns {Promise.<boolean>}
* @return {Promise.<boolean>}
*/
wd.addPromiseChainMethod('assertAttribute', function(attribute, value) {
return this.execute(
`return window.__macaca_current_element.getAttribute('${attribute}')`
`return window.__macaca_current_element.getAttribute('${attribute}')`,
).then(realValue => {
assert(
value === realValue,
`expect attribute ${attribute} to be '${value}' but got '${realValue}'`
`expect attribute ${attribute} to be '${value}' but got '${realValue}'`,
);
});
});
Expand Down
8 changes: 4 additions & 4 deletions lib/helper/coverage.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'use strict';


const fs = require('fs');
const path = require('path');
Expand All @@ -13,7 +13,7 @@ program
const xlogger = require('xlogger');

const logger = xlogger.Logger({
closeFile: true
closeFile: true,
});

const cwd = process.cwd();
Expand All @@ -24,9 +24,9 @@ module.exports = wd => {
* @function coverage
* @summary Support: Web(WebView)
* @type utility
* @returns {Promise.<boolean>}
* @return {Promise.<boolean>}
*/
wd.addPromiseChainMethod('coverage', function(context) {
wd.addPromiseChainMethod('coverage', function() {
const tempDir = path.join(cwd, 'coverage', '.temp');
_.mkdir(tempDir);
return this.execute('return window.__coverage__')
Expand Down
Loading

0 comments on commit 8b9d4fa

Please sign in to comment.