diff --git a/.eslintrc b/.eslintrc index 545f729c..af3583bb 100644 --- a/.eslintrc +++ b/.eslintrc @@ -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/"] } diff --git a/package.json b/package.json index ff883f7e..bec6daac 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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": [ diff --git a/script/format.sh b/script/lint.sh old mode 100755 new mode 100644 similarity index 54% rename from script/format.sh rename to script/lint.sh index 0b747cdc..dc9d967d --- a/script/format.sh +++ b/script/lint.sh @@ -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 diff --git a/src/.eslintrc b/src/.eslintrc new file mode 100644 index 00000000..71f8af6e --- /dev/null +++ b/src/.eslintrc @@ -0,0 +1,6 @@ +{ + "extends": [ + "../.eslintrc", + "eslint-config-atomic/strict", + ] +} diff --git a/test/.eslintrc b/test/.eslintrc new file mode 100644 index 00000000..ecf8e77f --- /dev/null +++ b/test/.eslintrc @@ -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" + } +}