mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
chore(eslint): add eslint typescript linting (#5635)
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.
This commit is contained in:
parent
88d843d4f0
commit
2529ee6508
@ -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
.eslintrc.js
34
.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,
|
||||
@ -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',
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
|
@ -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",
|
||||
@ -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",
|
||||
|
@ -25,7 +25,7 @@ interface Device {
|
||||
hasTouch: boolean;
|
||||
isLandscape: boolean;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
const devices: Device[] = [
|
||||
{
|
||||
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user