Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(eslint): Add ESLint TypeScript linting #5635

Merged
merged 1 commit into from Apr 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions .eslintignore
Expand Up @@ -6,3 +6,9 @@ node6/*
node6-test/*
experimental/
lib/
src/externs.d.ts
src/protocol.d.ts
/index.d.ts
# We ignore this file because it uses ES imports which we don't yet use
# in the Puppeteer src, so it trips up the ESLint-TypeScript parser.
utils/doclint/generate_types/test/test.ts
34 changes: 14 additions & 20 deletions .eslintrc.js
@@ -1,34 +1,18 @@
module.exports = {
"root": true,

"env": {
"node": true,
"es6": true
},

"parserOptions": {
"ecmaVersion": 9
},
"parser": "@typescript-eslint/parser",

"plugins": [
"mocha"
"mocha",
"@typescript-eslint"
],

/**
* ESLint rules
*
* All available rules: http://eslint.org/docs/rules/
*
* Rules take the following form:
* "rule-name", [severity, { opts }]
* Severity: 2 == error, 1 == warning, 0 == off.
*/
"rules": {
/**
* Enforced rules
*/


// syntax preferences
"quotes": [2, "single", {
"avoidEscape": true,
Expand Down Expand Up @@ -115,5 +99,15 @@ module.exports = {

// ensure we don't have any it.only or describe.only in prod
"mocha/no-exclusive-tests": "error"
}
},
"overrides": [
{
// apply TypeScript linting to the TS files in src/
"files": ["src/*.ts"],
"extends": [
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
]
}
]
};
4 changes: 3 additions & 1 deletion package.json
Expand Up @@ -21,7 +21,7 @@
"prepublishOnly": "npm run tsc",
"dev-install": "npm run tsc && node install.js",
"install": "node install.js",
"lint": "([ \"$CI\" = true ] && eslint --quiet -f codeframe . || eslint .) && npm run tsc && npm run doc",
"lint": "([ \"$CI\" = true ] && eslint --ext js --ext ts --quiet -f codeframe . || eslint --ext js --ext ts .) && npm run tsc && npm run doc",
"doc": "node utils/doclint/cli.js",
"tsc": "tsc --version && tsc -p . && cp src/protocol.d.ts lib/ && cp src/externs.d.ts lib/",
"apply-next-version": "node utils/apply_next_version.js",
Expand Down Expand Up @@ -53,6 +53,8 @@
"@types/rimraf": "^2.0.2",
"@types/tar-fs": "^1.16.2",
"@types/ws": "^6.0.1",
"@typescript-eslint/eslint-plugin": "^2.28.0",
"@typescript-eslint/parser": "^2.28.0",
"commonmark": "^0.28.1",
"cross-env": "^5.0.5",
"eslint": "^6.8.0",
Expand Down
6 changes: 3 additions & 3 deletions src/DeviceDescriptors.ts
Expand Up @@ -25,7 +25,7 @@ interface Device {
hasTouch: boolean;
isLandscape: boolean;
};
};
}

const devices: Device[] = [
{
Expand Down Expand Up @@ -888,8 +888,8 @@ type DevicesMap = {

const devicesMap: DevicesMap = {};

for (const device of devices) {
for (const device of devices)
devicesMap[device.name] = device;
}


export = devicesMap;