Skip to content

Commit

Permalink
Add eslint to enforce no-prototype-builtins
Browse files Browse the repository at this point in the history
The way to prevent issues like #58 is not obvious, and I would expect
not all programmers to have memorised the contents of
`Object.prototype`, so I think it would be prudent to check for such
issues automatically.

The no-prototype-builtins rule is enforced automatically by the set of
rules enabled in `.eslintrc.json` by

    "extends": "eslint:recommended"

It's a great sign that all the other enabled rules also pass without
modifications!

I've added the eslint invocation to `package.json`'s `posttest` field.
This should make the check minimally intrusive while developing, as it
will only run when the functional tests (via `jest`) pass first.
  • Loading branch information
anko authored and mattphillips committed Jan 25, 2022
1 parent b281292 commit 98d05ee
Show file tree
Hide file tree
Showing 3 changed files with 548 additions and 3 deletions.
15 changes: 15 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"env": {
"browser": true,
"es2021": true,
"node": true,
"jest": true
},
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": 12,
"sourceType": "module"
},
"rules": {
}
}
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"test": "jest",
"test:coverage": "yarn test -- --coverage",
"test:report": "cat ./coverage/lcov.info | ./node_modules/.bin/coveralls",
"test:watch": "yarn test -- --watch"
"test:watch": "yarn test -- --watch",
"posttest": "eslint src/"
},
"author": "Matt Phillips",
"license": "MIT",
Expand All @@ -30,6 +31,7 @@
"babel-preset-es2015": "^6.18.0",
"babel-preset-stage-0": "^6.16.0",
"coveralls": "^3.0.0",
"eslint": "^7.10.0",
"jest": "^23.6.0"
},
"babel": {
Expand Down
Loading

0 comments on commit 98d05ee

Please sign in to comment.