chore: add prettier
As a pre-commit hook, `.js` files will be run thru `eslint --fix` and rewritten using `prettier`.
Added `eslint-config-prettier` to disable rules incompatible with `prettier`.
ADD
.gitattributes
+* text=auto eol=lf

MODIFY
package.json
package.json
"build:loose": "run-s -c build:distfiles build:types || true",
"build:types": "tsc -b",
"clean": "run-s clean:artifacts clean:packages clean:monorepo",
+ "clean:artifacts": "run-s clean:distfiles clean:types && npx rimraf \"packages/*/build\"",
"clean:distfiles": "npx rimraf \"packages/*/build/**/*.js\"",
"clean:monorepo": "npx rimraf node_modules package-lock.json",
"clean:packages": "lerna clean -y && npx rimraf \"packages/*/package-lock.json\"",
"clean:types": "tsc -b --clean",
- "clean:artifacts": "run-s clean:distfiles clean:types && npx rimraf \"packages/*/build\"",
"dev": "run-p dev:*",
"dev:distfiles": "lerna run --parallel --prefix --concurrency=8 dev",
"dev:types": "tsc -b --watch",
"precommit-lint"
],
"lint-staged": {
- "*.js": "eslint --fix"
+ "*.js": [
+ "eslint --fix",
+ "prettier --write"
+ ]
+ },
+ "prettier": {
+ "bracketSpacing": false,
+ "singleQuote": true
},
"dependencies": {
"@appium/base-driver": "file:packages/base-driver",
"@appium/base-plugin": "file:packages/base-plugin",
"@appium/doctor": "file:packages/doctor",
"@appium/eslint-config-appium": "file:packages/eslint-config-appium",
+ "@appium/execute-driver-plugin": "file:packages/execute-driver-plugin",
"@appium/fake-driver": "file:packages/fake-driver",
"@appium/fake-plugin": "file:packages/fake-plugin",
"@appium/gulp-plugins": "file:packages/gulp-plugins",
"@appium/test-support": "file:packages/test-support",
"@appium/types": "file:packages/types",
"@appium/universal-xml-plugin": "file:packages/universal-xml-plugin",
- "@appium/execute-driver-plugin": "file:packages/execute-driver-plugin",
"appium": "file:packages/appium"
},
"devDependencies": {
"chai-as-promised": "7.1.1",
"chai-webdriverio-async": "2.6.0",
"eslint": "7.32.0",
+ "eslint-config-prettier": "8.5.0",
"eslint-find-rules": "4.1.0",
"eslint-plugin-import": "2.26.0",
"eslint-plugin-mocha": "9.0.0",
"mocha": "9.2.2",
"npm-run-all": "4.1.5",
"pre-commit": "1.2.2",
+ "prettier": "2.6.2",
"rewiremock": "3.14.3",
"rimraf": "3.0.2",
"serve-static": "1.15.0",

MODIFY
packages/eslint-config-appium/index.js
packages/eslint-config-appium/index.js
@@ -6,22 +6,18 @@ module.exports = {
sourceType: 'module',
ecmaFeatures: {
impliedStrict: true,
- experimentalObjectRestSpread: true
- }
+ experimentalObjectRestSpread: true,
+ },
},
env: {
node: true,
mocha: true,
es6: true,
},
- plugins: [
- 'import',
- 'mocha',
- 'promise'
- ],
+ plugins: ['import', 'mocha', 'promise'],
globals: {
chai: true,
- should: true
+ should: true,
},
rules: {
'no-console': 2,
@@ -29,10 +25,17 @@ module.exports = {
radix: [2, 'always'],
'dot-notation': 2,
eqeqeq: [2, 'smart'],
- 'brace-style': [2, '1tbs', {
+ 'brace-style': [
+ 2,
+ '1tbs',
+ {
allowSingleLine: true,
- }],
- indent: [2, 2, {
+ },
+ ],
+ indent: [
+ 2,
+ 2,
+ {
VariableDeclarator: {
var: 2,
let: 2,
@@ -45,7 +48,8 @@ module.exports = {
MemberExpression: 'off',
ObjectExpression: 'first',
SwitchCase: 1,
- }],
+ },
+ ],
'comma-dangle': 0,
'no-empty': 0,
'object-shorthand': 2,
@@ -69,31 +73,44 @@ module.exports = {
// enforce spacing
'arrow-spacing': 2,
'keyword-spacing': 2,
- 'comma-spacing': [2, {
+ 'comma-spacing': [
+ 2,
+ {
before: false,
- after: true
- }],
+ after: true,
+ },
+ ],
'array-bracket-spacing': 2,
'no-trailing-spaces': 2,
'no-whitespace-before-property': 2,
'space-in-parens': [2, 'never'],
'space-before-blocks': [2, 'always'],
'space-before-function-paren': [2, 'always'],
- 'space-unary-ops': [2, {
+ 'space-unary-ops': [
+ 2,
+ {
words: true,
nonwords: false,
- }],
+ },
+ ],
'space-infix-ops': 2,
- 'key-spacing': [2, {
+ 'key-spacing': [
+ 2,
+ {
mode: 'strict',
beforeColon: false,
afterColon: true,
- }],
+ },
+ ],
'no-multi-spaces': 2,
- quotes: [2, 'single', {
+ quotes: [
+ 2,
+ 'single',
+ {
avoidEscape: true,
allowTemplateLiterals: true,
- }],
+ },
+ ],
'no-buffer-constructor': 1,
'require-atomic-updates': 0,
'no-prototype-builtins': 1,
@@ -110,7 +127,5 @@ module.exports = {
}
]
},
- extends: [
- 'eslint:recommended',
- ],
+ extends: ['eslint:recommended', 'prettier'],
};

MODIFY
packages/eslint-config-appium/package.json
packages/eslint-config-appium/package.json
"appium",
"es2015"
],
+ "homepage": "https://appium.io",
+ "bugs": {
+ "url": "https://github.com/appium/appium/issues"
+ },
"repository": {
"type": "git",
"url": "https://github.com/appium/appium.git",
"directory": "packages/eslint-config-appium"
},
- "bugs": {
- "url": "https://github.com/appium/appium/issues"
- },
"license": "Apache-2.0",
"author": "https://github.com/appium",
"main": "index.js",
"@babel/core": "7.17.9",
"@babel/eslint-parser": "7.17.0",
"eslint": "7.32.0",
+ "eslint-config-prettier": "8.5.0",
"eslint-plugin-import": "2.26.0",
"eslint-plugin-mocha": "9.0.0",
"eslint-plugin-promise": "6.0.0"
},
- "publishConfig": {
- "access": "public"
- },
- "homepage": "https://appium.io",
"engines": {
"node": ">=12",
"npm": ">=6"
},
+ "publishConfig": {
+ "access": "public"
+ },
"gitHead": "722ae145fb40bf17b0168ea8b025763f120ad574"
}

chore: add prettier

As a pre-commit hook, `.js` files will be run thru `eslint --fix` and rewritten using `prettier`.
Added `eslint-config-prettier` to disable rules incompatible with `prettier`.