-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #168 from swim-io/sdk/eslint
Add eslint-config package
- Loading branch information
Showing
16 changed files
with
930 additions
and
238 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: "Verify eslint-config build" | ||
on: | ||
pull_request: | ||
paths: | ||
- "packages/eslint-config/**.ts" | ||
- "packages/eslint-config/**.json" | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
verify: | ||
runs-on: ubuntu-latest | ||
|
||
defaults: | ||
run: | ||
working-directory: ./packages/eslint-config | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: 16 | ||
cache: "yarn" | ||
- name: Install dependencies | ||
run: yarn install --immutable | ||
- name: Check format | ||
run: yarn format:check | ||
- name: Check lint | ||
run: yarn lint --max-warnings=0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ module.exports = { | |
2, | ||
"always", | ||
[ | ||
"eslint-config", | ||
"pool-deployment", | ||
"pool-math", | ||
"pool-playground", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"extends": ["@swim-io/eslint-config/js-only"], | ||
"env": { | ||
"node": true | ||
}, | ||
"rules": { | ||
"functional/immutable-data": "off", | ||
"import/no-commonjs": "off", | ||
"import/unambiguous": "off" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
build/ | ||
types/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# ESLint config | ||
|
||
Shared default ESLint configuration for Swim TS projects. | ||
|
||
## Installation | ||
|
||
Install the package: | ||
|
||
```sh | ||
npm install --save-dev @swim-io/eslint-config | ||
``` | ||
|
||
Install the required peer dependencies: | ||
|
||
```sh | ||
npm install --save-dev eslint eslint-config-prettier eslint-plugin-functional eslint-plugin-import eslint-plugin-jest eslint-plugin-prettier | ||
``` | ||
|
||
For TS projects also install these optional dependencies: | ||
|
||
```sh | ||
npm install --save-dev @typescript-eslint/eslint-plugin @typescript-eslint/parser eslint-plugin-deprecation | ||
``` | ||
|
||
## Usage | ||
|
||
In TS projects extend from the default config in your ESLint configuration file: | ||
|
||
```json | ||
{ | ||
"extends": ["@swim-io"] | ||
} | ||
``` | ||
|
||
In JS projects extend from the JS-only config: | ||
|
||
```json | ||
{ | ||
"extends": ["@swim-io/eslint-config/js-only"] | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
module.exports = { | ||
plugins: ["@typescript-eslint", "deprecation"], | ||
extends: [ | ||
"@swim-io/eslint-config/js-only", | ||
"plugin:@typescript-eslint/recommended", | ||
"plugin:@typescript-eslint/recommended-requiring-type-checking", | ||
"plugin:import/typescript", | ||
], | ||
parser: "@typescript-eslint/parser", | ||
parserOptions: { | ||
project: "./tsconfig.json", | ||
}, | ||
rules: { | ||
// @typescript-eslint | ||
"@typescript-eslint/consistent-type-imports": "error", | ||
"@typescript-eslint/explicit-module-boundary-types": "off", | ||
"@typescript-eslint/member-ordering": "error", | ||
"@typescript-eslint/no-empty-function": "off", | ||
"@typescript-eslint/no-explicit-any": "off", | ||
"@typescript-eslint/no-floating-promises": "error", | ||
"@typescript-eslint/no-unnecessary-condition": "error", | ||
"@typescript-eslint/no-unnecessary-type-assertion": "error", | ||
"@typescript-eslint/no-unsafe-call": "off", | ||
"@typescript-eslint/no-unsafe-return": "off", | ||
"@typescript-eslint/no-shadow": "error", | ||
"@typescript-eslint/prefer-readonly-parameter-types": "off", | ||
|
||
// deprecation | ||
"deprecation/deprecation": "warn", | ||
}, | ||
overrides: [ | ||
{ | ||
files: ["**/*.test.ts"], | ||
env: { | ||
node: true, | ||
}, | ||
rules: { | ||
"@typescript-eslint/no-unsafe-argument": "off", | ||
"@typescript-eslint/no-unsafe-call": "off", | ||
"@typescript-eslint/no-unsafe-member-access": "off", | ||
"@typescript-eslint/no-unsafe-return": "off", | ||
}, | ||
}, | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
module.exports = { | ||
root: true, | ||
plugins: ["functional", "import", "jest", "prettier"], | ||
extends: [ | ||
"eslint:recommended", | ||
"prettier", | ||
"plugin:prettier/recommended", | ||
"plugin:import/recommended", | ||
"plugin:functional/external-recommended", | ||
"plugin:functional/no-mutations", | ||
"plugin:jest/recommended", | ||
], | ||
env: { | ||
"jest/globals": true, | ||
}, | ||
rules: { | ||
// Vanilla ESLint | ||
"no-console": ["warn", { allow: ["error", "info", "table", "warn"] }], | ||
"no-undef": "error", | ||
"sort-imports": ["error", { ignoreDeclarationSort: true }], | ||
|
||
// functional | ||
"functional/immutable-data": ["error", { ignorePattern: "this" }], | ||
"functional/no-let": "off", | ||
"functional/prefer-readonly-type": ["error", { ignoreClass: "fieldsOnly" }], | ||
|
||
// import | ||
"import/extensions": ["error", "always", { ts: "never", tsx: "never" }], | ||
"import/first": "error", | ||
"import/newline-after-import": "error", | ||
"import/no-absolute-path": "error", | ||
"import/no-amd": "error", | ||
"import/no-commonjs": "error", | ||
"import/no-cycle": "error", | ||
"import/no-deprecated": "error", | ||
"import/no-dynamic-require": "error", | ||
"import/no-mutable-exports": "error", | ||
"import/no-self-import": "error", | ||
"import/no-unused-modules": "error", | ||
"import/no-useless-path-segments": "error", | ||
"import/order": [ | ||
"error", | ||
{ alphabetize: { order: "asc" }, "newlines-between": "always" }, | ||
], | ||
"import/unambiguous": "error", | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
{ | ||
"name": "@swim-io/eslint-config", | ||
"version": "0.2.0", | ||
"description": "Shared default ESLint configuration for Swim TS projects.", | ||
"main": "index.js", | ||
"files": [ | ||
"*.js", | ||
"*.md" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/swim-io/swim/tree/master/packages/eslint-config" | ||
}, | ||
"publishConfig": { | ||
"access": "public", | ||
"registry": "https://registry.npmjs.org" | ||
}, | ||
"scripts": { | ||
"format": "prettier --write \"*.js\"", | ||
"format:check": "prettier --check index.js", | ||
"lint": "eslint \"./*.js\"", | ||
"lint:fix": "eslint --fix \"./*.js\"", | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"verify": "yarn format:check && yarn lint", | ||
"prepare": "yarn verify" | ||
}, | ||
"peerDependencies": { | ||
"eslint": ">= 8.19", | ||
"eslint-config-prettier": "^8.5", | ||
"eslint-plugin-functional": "^4.2", | ||
"eslint-plugin-import": "^2.26", | ||
"eslint-plugin-jest": "^26.5", | ||
"eslint-plugin-prettier": "^4.2" | ||
}, | ||
"optionalDependencies": { | ||
"@typescript-eslint/eslint-plugin": "^5.30", | ||
"@typescript-eslint/parser": "^5.30", | ||
"eslint-plugin-deprecation": "^1.3" | ||
}, | ||
"devDependencies": { | ||
"eslint": "^8.19.0", | ||
"eslint-config-prettier": "^8.5", | ||
"eslint-plugin-deprecation": "^1.3.2", | ||
"eslint-plugin-functional": "^4.2.1", | ||
"eslint-plugin-import": "^2.26.0", | ||
"eslint-plugin-jest": "^26.5.3", | ||
"eslint-plugin-prettier": "^4.2.1", | ||
"jest": "^28.1.2", | ||
"prettier": "^2.7.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,81 +1,3 @@ | ||
{ | ||
"root": true, | ||
"plugins": [ | ||
"@typescript-eslint", | ||
"deprecation", | ||
"functional", | ||
"import", | ||
"jest", | ||
"prettier" | ||
], | ||
"extends": [ | ||
"eslint:recommended", | ||
"plugin:@typescript-eslint/recommended", | ||
"plugin:@typescript-eslint/recommended-requiring-type-checking", | ||
"prettier", | ||
"plugin:prettier/recommended", | ||
"plugin:import/recommended", | ||
"plugin:import/typescript", | ||
"plugin:functional/external-recommended", | ||
"plugin:functional/no-mutations", | ||
"plugin:jest/recommended" | ||
], | ||
"parser": "@typescript-eslint/parser", | ||
"parserOptions": { | ||
"project": "./tsconfig.json" | ||
}, | ||
"env": { | ||
"jest/globals": true | ||
}, | ||
"rules": { | ||
"no-console": ["warn", { "allow": ["error", "info", "table", "warn"] }], | ||
"no-undef": "error", | ||
"sort-imports": ["error", { "ignoreDeclarationSort": true }], | ||
"@typescript-eslint/consistent-type-imports": "error", | ||
"@typescript-eslint/explicit-module-boundary-types": "off", | ||
"@typescript-eslint/member-ordering": "error", | ||
"@typescript-eslint/no-empty-function": "off", | ||
"@typescript-eslint/no-explicit-any": "off", | ||
"@typescript-eslint/no-floating-promises": "error", | ||
"@typescript-eslint/no-unnecessary-condition": "error", | ||
"@typescript-eslint/no-unnecessary-type-assertion": "error", | ||
"@typescript-eslint/no-shadow": "error", | ||
"@typescript-eslint/prefer-readonly-parameter-types": "off", | ||
// "deprecation/deprecation": "warn", | ||
"functional/immutable-data": ["error", { "ignorePattern": "this" }], | ||
"functional/no-let": "off", | ||
"functional/prefer-readonly-type": [ | ||
"error", | ||
{ "ignoreClass": "fieldsOnly" } | ||
], | ||
"import/extensions": ["error", "always", { "ts": "never", "tsx": "never" }], | ||
"import/first": "error", | ||
"import/newline-after-import": "error", | ||
"import/no-absolute-path": "error", | ||
"import/no-amd": "error", | ||
"import/no-commonjs": "error", | ||
"import/no-cycle": "error", | ||
"import/no-deprecated": "error", | ||
"import/no-dynamic-require": "error", | ||
"import/no-mutable-exports": "error", | ||
"import/no-self-import": "error", | ||
"import/no-unused-modules": "error", | ||
"import/no-useless-path-segments": "error", | ||
"import/order": [ | ||
"error", | ||
{ "alphabetize": { "order": "asc" }, "newlines-between": "always" } | ||
], | ||
"import/unambiguous": "error" | ||
}, | ||
"overrides": [ | ||
{ | ||
"files": ["**/*.test.ts"], | ||
"rules": { | ||
"@typescript-eslint/no-unsafe-argument": "off", | ||
"@typescript-eslint/no-unsafe-call": "off", | ||
"@typescript-eslint/no-unsafe-member-access": "off", | ||
"@typescript-eslint/no-unsafe-return": "off" | ||
} | ||
} | ||
] | ||
"extends": ["@swim-io"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.