Skip to content

Commit

Permalink
Add eslint-config-atomic, update eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed May 1, 2021
1 parent 26d85ef commit a9cd9dd
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 30 deletions.
24 changes: 4 additions & 20 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,29 +1,13 @@
{
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint",
"prettier"
],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended",
"prettier/@typescript-eslint"
"eslint-config-atomic"
],
"rules": {
"prettier/prettier": "error",
"no-fallthrough": "error",
"no-inner-declarations": "off",
"no-prototype-builtins": "off",
"no-unused-expressions": "warn",
"prefer-const": ["warn", {"destructuring": "all"}],
"@typescript-eslint/no-empty-interface": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/quotes": ["error", "double"],
}
"@typescript-eslint/quotes": ["error", "double"]
},
"ignorePatterns": ["node_modules/", "build/", "lib/", "libzmq/", "tmp/", "zmq/"]
}
9 changes: 3 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,11 @@
"@types/node": ">= 8.0",
"@types/semver": ">= 0",
"@types/weak-napi": "^2.0.0",
"@typescript-eslint/eslint-plugin": "^2.9.0",
"@typescript-eslint/parser": "^2.9.0",
"benchmark": ">= 0",
"chai": ">= 4.1",
"choma": ">= 1.2",
"deasync": "^0.1.16",
"eslint": "^6.7.2",
"eslint-config-prettier": "^6.7.0",
"eslint-config-atomic": "^1.14.2",
"eslint-plugin-prettier": "^3.1.1",
"fs-extra": "^8.1.0",
"gunzip-maybe": "^1.4.1",
Expand Down Expand Up @@ -80,8 +77,8 @@
"prebuild": "ts-node -P ./tsconfig.json ./script/prebuild.ts",
"build.native": "prebuildify --napi --build-from-source --debug",
"build.native.debug": "npm run build.native -- --debug",
"test": "npm run build.js && mocha && npm run format",
"format": "sh script/format.sh",
"test": "npm run build.js && mocha && npm run lint",
"lint": "sh script/lint.sh",
"bench": "node --expose-gc test/bench"
},
"keywords": [
Expand Down
9 changes: 5 additions & 4 deletions script/format.sh → script/lint.sh
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
#!/bin/sh
if [ -z "$CI" ]; then
if command -v clang-format >/dev/null; then
echo "Formatting C++ source files..."
echo "Clang-format..."
clang-format -i -style=file src/*.{cc,h} src/*/*.h
fi

if command -v node_modules/.bin/eslint >/dev/null; then
echo "Formatting TS source files..."
node_modules/.bin/eslint --fix src/**/*.ts test/**/*.ts examples/**/*.ts
echo "Eslint..."
node_modules/.bin/eslint --fix .
fi
else
if command -v node_modules/.bin/eslint >/dev/null; then
node_modules/.bin/eslint src/**/*.ts test/**/*.ts examples/**/*.ts
echo "Eslint..."
node_modules/.bin/eslint --fix .
fi
fi
6 changes: 6 additions & 0 deletions src/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": [
"../.eslintrc",
"eslint-config-atomic/strict",
]
}
15 changes: 15 additions & 0 deletions test/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"extends": "../.eslintrc",
"rules": {
"no-invalid-this": "off",
"no-inner-declarations": "off",
"no-prototype-builtins": "off",
"@typescript-eslint/no-empty-interface": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"no-await-in-loop": "off"
}
}

0 comments on commit a9cd9dd

Please sign in to comment.