Skip to content

Commit

Permalink
chore(eslint): add eslint typescript linting (#5635)
Browse files Browse the repository at this point in the history
This commit adds linting for `*.ts` files and loads up the recommended
list of TS rules from the ESLint TypeScript plugin. We can adjust the
exact rules overtime, but starting with the recommended list seems
sensible.
  • Loading branch information
jackfranklin committed Apr 14, 2020
1 parent 88d843d commit 2529ee6
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 24 deletions.
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;

0 comments on commit 2529ee6

Please sign in to comment.