Skip to content

Commit

Permalink
Switch to eslint and fix linting errors (#225)
Browse files Browse the repository at this point in the history
  • Loading branch information
NilsJPWerner authored Feb 16, 2022
1 parent 74383d0 commit 5e08575
Show file tree
Hide file tree
Showing 21 changed files with 5,307 additions and 65 deletions.
162 changes: 162 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
module.exports = {
env: {
es6: true,
node: true,
},
extends: [
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"prettier",
],
parser: "@typescript-eslint/parser",
parserOptions: {
project: "tsconfig.json",
sourceType: "module",
},
plugins: [
"eslint-plugin-import",
"eslint-plugin-jsdoc",
"eslint-plugin-prefer-arrow",
"@typescript-eslint",
],
rules: {
"@typescript-eslint/adjacent-overload-signatures": "error",
"@typescript-eslint/array-type": [
"error",
{
default: "array",
},
],
"@typescript-eslint/ban-types": [
"error",
{
types: {
Object: {
message: "Avoid using the `Object` type. Did you mean `object`?",
},
Function: {
message:
"Avoid using the `Function` type. Prefer a specific function type, like `() => void`.",
},
Boolean: {
message: "Avoid using the `Boolean` type. Did you mean `boolean`?",
},
Number: {
message: "Avoid using the `Number` type. Did you mean `number`?",
},
String: {
message: "Avoid using the `String` type. Did you mean `string`?",
},
Symbol: {
message: "Avoid using the `Symbol` type. Did you mean `symbol`?",
},
},
},
],
"@typescript-eslint/consistent-type-assertions": "error",
"@typescript-eslint/dot-notation": "error",
"@typescript-eslint/member-delimiter-style": [
"error",
{
multiline: {
delimiter: "semi",
requireLast: true,
},
singleline: {
delimiter: "semi",
requireLast: false,
},
},
],
"@typescript-eslint/naming-convention": "off",
"@typescript-eslint/no-empty-function": "error",
"@typescript-eslint/no-empty-interface": "error",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-misused-new": "error",
"@typescript-eslint/no-namespace": "error",
"@typescript-eslint/no-parameter-properties": "off",
"@typescript-eslint/no-shadow": [
"error",
{
hoist: "all",
},
],
"@typescript-eslint/no-unused-expressions": "error",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/no-var-requires": "error",
"@typescript-eslint/prefer-for-of": "error",
"@typescript-eslint/prefer-function-type": "error",
"@typescript-eslint/prefer-namespace-keyword": "error",
"@typescript-eslint/semi": ["error"],
"@typescript-eslint/triple-slash-reference": [
"error",
{
path: "always",
types: "prefer-import",
lib: "always",
},
],
"@typescript-eslint/unified-signatures": "error",
complexity: "off",
"constructor-super": "error",
"dot-notation": "error",
eqeqeq: ["off", "always"],
"guard-for-in": "error",
"id-denylist": [
"error",
"any",
"Number",
"number",
"String",
"string",
"Boolean",
"boolean",
"Undefined",
"undefined",
],
"id-match": "error",
"import/order": "off",
"jsdoc/check-alignment": "error",
"jsdoc/check-indentation": "error",
"jsdoc/newline-after-description": "error",
"max-classes-per-file": ["error", 1],
"new-parens": "error",
"no-bitwise": "error",
"no-caller": "error",
"no-cond-assign": "error",
"no-console": "off",
"no-debugger": "error",
"no-empty": "error",
"no-empty-function": "error",
"no-eval": "error",
"no-fallthrough": "off",
"no-invalid-this": "off",
"no-new-wrappers": "error",
"no-shadow": "error",
"no-throw-literal": "error",
"no-trailing-spaces": "error",
"no-undef-init": "error",
"no-underscore-dangle": "error",
"no-unsafe-finally": "error",
"no-unused-expressions": "error",
"no-unused-labels": "error",
"no-use-before-define": "off",
"no-var": "error",
"object-shorthand": "error",
"one-var": ["error", "never"],
"prefer-arrow/prefer-arrow-functions": "off",
"prefer-const": "error",
radix: "error",
semi: "error",
"space-before-function-paren": "off",
"spaced-comment": [
"error",
"always",
{
markers: ["/"],
},
],
"use-isnan": "error",
"valid-typeof": "off",
},
};
66 changes: 66 additions & 0 deletions .github/workflows/test_and_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Test autoDocstring
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
unit_tests:
runs-on: "${{ matrix.os }}"
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
node: [16]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: "${{ matrix.node-version }}"
cache: "npm"
- run: npm install
- run: npm run vscode:prepublish
- run: npm run unit_test

integration_tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16
cache: "npm"
- run: npm install
- run: npm run prepare_integration_tests
- uses: GabrielBB/xvfb-action@v1
with:
options: -screen 0 1024x768x24
run: npm run integration_test
publish:
needs:
- unit_tests
- integration_tests
if: startsWith(github.event.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16
cache: "npm"
- run: npm ci
- name: GitHub Release
uses: softprops/action-gh-release@v1
with:
generate_release_notes: true
body: |
# Summary
See [changelog](https://github.com/NilsJPWerner/autoDocstring/blob/master/CHANGELOG.md)
name: ${{ github.ref_name }}
fail_on_unmatched_files: true
- name: Publish to Visual Studio Marketplace
uses: HaaLeo/publish-vscode-extension@v1
with:
pat: ${{ secrets.VS_MARKETPLACE_TOKEN }}
registryUrl: https://marketplace.visualstudio.com
7 changes: 7 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,12 @@
"isDefault": true
}
},
{
"type": "npm",
"script": "lint",
"problemMatcher": ["$eslint-stylish"],
"label": "npm: lint",
"detail": "eslint -c .eslintrc.js --ext .ts src/"
}
]
}
Loading

0 comments on commit 5e08575

Please sign in to comment.