Skip to content

Commit ab62af7

Browse files
committed
add eslint settings
1 parent 184ee92 commit ab62af7

File tree

3 files changed

+53
-1
lines changed

3 files changed

+53
-1
lines changed

.eslintrc.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
module.exports = {
2+
extends: [
3+
// https://eslint.org/docs/rules/
4+
"eslint:recommended",
5+
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/src/configs/recommended.json
6+
"plugin:@typescript-eslint/recommended",
7+
// https://prettier.io/docs/en/eslint.html
8+
"plugin:prettier/recommended",
9+
],
10+
// https://reactjs.org/docs/hooks-rules.html
11+
plugins: [],
12+
parser: "@typescript-eslint/parser",
13+
parserOptions: {
14+
project: "./tsconfig.json",
15+
},
16+
settings: {},
17+
rules: {
18+
"no-undef": "off", // useless in TypeScript
19+
"no-constant-condition": ["warn", { checkLoops: false }],
20+
"no-useless-escape": "warn",
21+
"no-console": "warn",
22+
23+
"@typescript-eslint/no-unused-vars": ["warn", { argsIgnorePattern: "^_|^intl$" }],
24+
"@typescript-eslint/array-type": ["error", "generic"],
25+
"@typescript-eslint/camelcase": "warn",
26+
"@typescript-eslint/class-name-casing": "warn", // to allow the initial underscore
27+
"@typescript-eslint/no-non-null-assertion": "warn", // NOTE: pay attention to it because it may cause unexpected behavior
28+
"@typescript-eslint/prefer-for-of": "warn",
29+
"@typescript-eslint/prefer-includes": "warn",
30+
"@typescript-eslint/prefer-string-starts-ends-with": "warn",
31+
"@typescript-eslint/no-use-before-define": "warn",
32+
33+
"@typescript-eslint/indent": "off",
34+
"@typescript-eslint/no-explicit-any": "off",
35+
"@typescript-eslint/explicit-function-return-type": "off",
36+
"@typescript-eslint/explicit-member-accessibility": "off",
37+
"@typescript-eslint/no-object-literal-type-assertion": "off",
38+
"@typescript-eslint/no-empty-interface": "off",
39+
"@typescript-eslint/no-parameter-properties": "off",
40+
"@typescript-eslint/no-var-requires": "off", // not a part of ECMA-262
41+
"@typescript-eslint/prefer-interface": "off",
42+
43+
"prettier/prettier": "warn",
44+
},
45+
};

package.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
"prepublishOnly": "TEST_DIST=true npm run test",
1010
"test": "TS_NODE_FILES=true mocha 'test/**/*.test.ts'",
1111
"test:cover": "TS_NODE_FILES=true npx nyc mocha 'test/**/*.test.ts'",
12+
"lint": "eslint --ext .ts src test",
13+
"lint:fix": "eslint --fix --ext .ts src test && npm run format",
1214
"format": "prettier --write 'src/**/*.ts' 'test/**/*.ts'",
1315
"profile:encode": "rm -f isolate-*.log ; node --prof --require ts-node/register -e 'require(\"./benchmark/profile-encode\")' && node --prof-process --preprocess -j isolate-*.log | npx flamebearer",
1416
"profile:decode": "rm -f isolate-*.log ; node --prof --require ts-node/register -e 'require(\"./benchmark/profile-decode\")' && node --prof-process --preprocess -j isolate-*.log | npx flamebearer",
@@ -32,6 +34,11 @@
3234
"devDependencies": {
3335
"@types/mocha": "^5.2.6",
3436
"@types/node": "^11.13.8",
37+
"@typescript-eslint/eslint-plugin": "^1.7.0",
38+
"@typescript-eslint/parser": "^1.7.0",
39+
"eslint": "^5.16.0",
40+
"eslint-config-prettier": "^4.2.0",
41+
"eslint-plugin-prettier": "^3.0.1",
3542
"ieee754": "^1.1.13",
3643
"mocha": "^6.1.4",
3744
"msgpack-lite": "^0.1.26",

test/msgpack-test-suite.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ describe("msgpack-test-suite", () => {
9191
const SPECS = {
9292
FLOAT64_POSITIVE_INF: Number.POSITIVE_INFINITY,
9393
FLOAT64_NEGATIVE_INF: Number.NEGATIVE_INFINITY,
94-
FLOAT64_NaN: Number.NaN,
94+
FLOAT64_NAN: Number.NaN,
9595
STR16: "x".repeat(0x100),
9696
STR32: "x".repeat(0x10000),
9797
BIN16: new Uint8Array(0x100).fill(0xff),

0 commit comments

Comments
 (0)