Skip to content

Commit dba0214

Browse files
chore: update eslint, add lint fixes
1 parent b130f1d commit dba0214

28 files changed

+396
-411
lines changed

.eslintignore

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
node_modules
1+
.coverage
2+
.nyc_output
3+
.yarn-cache
24
dist
5+
node_modules
36
out
4-
coverage
5-
update.package.ts

.eslintrc

+92-26
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"extends": ["plugin:@typescript-eslint/recommended"],
33
"parser": "@typescript-eslint/parser",
4-
"plugins": ["import", "@typescript-eslint", "mocha", "prettier"],
4+
"plugins": ["@typescript-eslint", "import", "mocha", "prettier"],
55
"parserOptions": {
66
"ecmaVersion": 8
77
},
@@ -49,13 +49,19 @@
4949
"rules": {
5050
"@typescript-eslint/no-var-requires": "off"
5151
}
52+
},
53+
{
54+
"files": ["**/*.ts"],
55+
"rules": {
56+
"@typescript-eslint/explicit-module-boundary-types": "off",
57+
"@typescript-eslint/no-explicit-any": "off"
58+
}
5259
}
5360
],
5461
"rules": {
5562
"array-bracket-newline": ["error", "consistent"],
5663
"block-spacing": ["error", "always"],
5764
"brace-style": ["error", "1tbs"],
58-
"camelcase": ["error", { "properties": "always" }],
5965
"comma-dangle": [
6066
"error",
6167
{
@@ -66,32 +72,50 @@
6672
"functions": "always-multiline"
6773
}
6874
],
69-
"comma-spacing": ["error", { "before": false, "after": true }],
70-
"curly": ["error", "all"],
71-
"eqeqeq": ["error", "always"],
72-
"eol-last": ["error", "always"],
73-
"lines-around-comment": [
75+
"comma-spacing": [
7476
"error",
7577
{
76-
"beforeBlockComment": true
78+
"before": false,
79+
"after": true
7780
}
7881
],
82+
"curly": ["error", "all"],
83+
"eqeqeq": ["error", "always"],
84+
"eol-last": ["error", "always"],
7985
"lines-between-class-members": [
8086
"error",
8187
"always",
8288
{
8389
"exceptAfterSingleLine": true
8490
}
8591
],
86-
"max-statements-per-line": ["error", { "max": 1 }],
92+
"max-statements-per-line": [
93+
"error",
94+
{
95+
"max": 1
96+
}
97+
],
8798
"multiline-ternary": ["error", "always-multiline"],
88-
"new-cap": ["error", { "newIsCap": true, "capIsNew": true, "properties": true }],
99+
"new-cap": [
100+
"error",
101+
{
102+
"newIsCap": true,
103+
"capIsNew": true,
104+
"properties": true
105+
}
106+
],
89107
"new-parens": ["error"],
90-
"newline-per-chained-call": ["error"],
91108
"no-array-constructor": ["error"],
92109
"no-console": ["off"],
93-
"no-dupe-args": "off", // doesn't play nice with decorators in constructors
94-
"no-else-return": ["error", { "allowElseIf": false }],
110+
"no-dupe-args": "off",
111+
// doesn't play nice with decorators in constructors
112+
"no-else-return": [
113+
"error",
114+
{
115+
"allowElseIf": false
116+
}
117+
],
118+
"no-inferrable-types": "off",
95119
"no-invalid-this": ["error"],
96120
"no-magic-numbers": [
97121
"error",
@@ -115,45 +139,87 @@
115139
"no-new-func": ["error"],
116140
"no-lonely-if": ["error"],
117141
"no-multi-assign": ["error"],
118-
"no-redeclare": "off", // doesn't play nice with decorators in constructors
142+
"no-redeclare": "off",
143+
// doesn't play nice with decorators in constructors
119144
"no-unneeded-ternary": ["error"],
120145
"no-var": ["error"],
121146
"no-whitespace-before-property": ["error"],
122-
"object-curly-newline": ["error", { "multiline": true, "consistent": true }],
147+
"object-curly-newline": [
148+
"error",
149+
{
150+
"multiline": true,
151+
"consistent": true
152+
}
153+
],
123154
"one-var-declaration-per-line": ["error", "initializations"],
124155
"prefer-const": "error",
125156
"prefer-rest-params": "error",
126157
"prefer-spread": "error",
127-
"quotes": ["error", "single", { "avoidEscape": true, "allowTemplateLiterals": true }],
158+
"quotes": [
159+
"error",
160+
"single",
161+
{
162+
"avoidEscape": true,
163+
"allowTemplateLiterals": true
164+
}
165+
],
128166
"rest-spread-spacing": ["error", "never"],
129167
"semi": ["error", "never"],
130168
"space-in-parens": ["error", "never"],
131169
"spaced-comment": ["error", "always"],
132-
133170
"import/order": [
134171
"error",
135172
{
136173
"alphabetize": {
137174
"order": "asc",
138175
"caseInsensitive": false
139176
},
140-
"groups": ["builtin", "external", "internal", "parent", "sibling", "index"],
177+
"groups": ["builtin", "external", "internal", "parent", "index", "sibling", "object"],
178+
"pathGroups": [
179+
{
180+
"pattern": "@dandi/**",
181+
"group": "builtin",
182+
"position": "before"
183+
},
184+
{
185+
"pattern": "@dandi-contrib/**",
186+
"group": "builtin",
187+
"position": "after"
188+
}
189+
],
141190
"newlines-between": "always-and-inside-groups"
142191
}
143192
],
144-
145193
"@typescript-eslint/ban-types": ["off"],
146-
"@typescript-eslint/class-name-casing": ["error"],
147-
"@typescript-eslint/explicit-function-return-type": ["error", { "allowExpressions": true }],
148-
"@typescript-eslint/generic-type-naming": ["error", "^T(?:[A-Z][a-zA-Z]+)*$"],
194+
"@typescript-eslint/explicit-function-return-type": [
195+
"error",
196+
{
197+
"allowExpressions": true
198+
}
199+
],
149200
"@typescript-eslint/indent": ["off"],
150-
"@typescript-eslint/member-delimiter-style": ["error", { "multiline": { "delimiter": "none" } }],
151-
"@typescript-eslint/no-inferrable-types": ["error", { "ignoreParameters": true, "ignoreProperties": true }],
152-
"@typescript-eslint/no-explicit-any": ["off"],
201+
"@typescript-eslint/member-delimiter-style": [
202+
"error",
203+
{
204+
"multiline": {
205+
"delimiter": "none"
206+
}
207+
}
208+
],
209+
"@typescript-eslint/naming-convention": [
210+
"error",
211+
{ "selector": "typeParameter", "format": ["PascalCase"], "prefix": ["T"] }
212+
],
213+
"@typescript-eslint/no-extra-semi": ["off"],
153214
"@typescript-eslint/no-unused-vars": ["error"],
154215
"@typescript-eslint/no-use-before-define": [
155216
"error",
156-
{ "functions": false, "classes": false, "variables": true, "enums": true }
217+
{
218+
"functions": false,
219+
"classes": false,
220+
"variables": true,
221+
"enums": true
222+
}
157223
],
158224
"@typescript-eslint/semi": ["error", "never"]
159225
}

.prettierignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
*.pug
77
*.tf
88
node_modules
9-
out
9+
out/*
1010
yarn.lock

_examples/simple-express-rest-api/src/server.application.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,14 @@ import { ModelBuilderModule } from '@dandi/model-builder'
1010
import { MvcHalModule } from '@dandi/mvc-hal'
1111
import { MvcViewModule } from '@dandi/mvc-view'
1212

13+
import { CustomErrorHandler } from './custom-error-handler'
1314
import { ExampleController } from './example/example.controller'
1415
import { HyperviewController } from './hyperview/hyperview.controller'
1516
import { ListController } from './lists/list.controller'
1617
import { Db } from './shared/db'
1718
import { TaskController } from './tasks/task.controller'
1819
import { ViewController } from './view/view.controller'
1920

20-
import { CustomErrorHandler } from './custom-error-handler'
21-
2221
const DEFAULT_SERVER_PORT = 8085
2322

2423
export const server = new DandiApplication({

builder/src/builder-version.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export const VERSION = require('../package.json').version
1+
export { version as VERSION } from '../package.json'

builder/src/local-token.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { InjectionOptions, InjectionToken, OpinionatedToken, SymbolToken } from '@dandi/core'
22

3-
const PACKAGE_NAME = require('../package').name
3+
import { name as PACKAGE_NAME } from '../package.json'
44

55
export function localSymbolTokenFor<T>(target: string): InjectionToken<T> {
66
return SymbolToken.forLocal<T>(PACKAGE_NAME, target)

builder/tsconfig.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
{
2-
"extends": "../tsconfig.json"
2+
"extends": "../tsconfig.json",
3+
"compilerOptions": {
4+
"resolveJsonModule": true
5+
}
36
}

package.json

+8-8
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@
3838
"@types/mocha": "^5.2.7",
3939
"@types/node": "^12.12.24",
4040
"@types/sinon-chai": "^3.2.3",
41-
"@typescript-eslint/eslint-plugin": "^2.19.2",
42-
"@typescript-eslint/parser": "^2.19.2",
41+
"@typescript-eslint/eslint-plugin": "^3.6.1",
42+
"@typescript-eslint/parser": "^3.6.1",
4343
"chai": "^4.2.0",
4444
"chai-as-promised": "^7.1.1",
4545
"colors": "^1.4.0",
4646
"coveralls": "^3.0.9",
47-
"eslint": "^6.7.2",
48-
"eslint-plugin-import": "^2.18.2",
49-
"eslint-plugin-mocha": "^6.2.2",
47+
"eslint": "^7.4.0",
48+
"eslint-plugin-import": "^2.22.0",
49+
"eslint-plugin-mocha": "^7.0.1",
5050
"eslint-plugin-prettier": "^3.1.4",
5151
"lodash": "^4.17.15",
5252
"longjohn": "^0.2.12",
@@ -56,12 +56,12 @@
5656
"prettier": "^2.0.5",
5757
"rimraf": "^3.0.0",
5858
"rxjs": "^6.4.0",
59-
"sinon": "^8.0.2",
60-
"sinon-chai": "^3.4.0",
59+
"sinon": "^9.0.2",
60+
"sinon-chai": "^3.5.0",
6161
"ts-custom-error-shim": "^1.0.2",
6262
"ts-node": "^8.10.2",
6363
"tsconfig-paths": "^3.9.0",
64-
"typescript": "^3.9.6",
64+
"typescript": "^3.9.7",
6565
"uuid": "^7.0.3"
6666
}
6767
}

packages/dandi-contrib/config-aws-ssm/src/ssm.client.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { AwsSsmClient } from './ssm.client.factory'
66
export class SsmClient {
77
constructor(@Inject(AwsSsmClient) private ssm: AwsSsmClient) {}
88

9-
public async getParameter(name: string, encrypted: boolean = false): Promise<string> {
9+
public async getParameter(name: string, encrypted = false): Promise<string> {
1010
const result = await this.ssm
1111
.getParameter({
1212
Name: name,

packages/dandi-contrib/mvc-auth-firebase/src/firebase.authorization.service.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ import { AuthorizationService, AuthorizedUser } from '@dandi/mvc'
44
import * as admin from 'firebase-admin'
55
import { DateTime } from 'luxon'
66

7+
import { FirebaseServiceAccount } from './firebase.service.account'
8+
79
import App = admin.app.App
810
import Auth = admin.auth.Auth
911
import UserRecord = admin.auth.UserRecord
1012

11-
import { FirebaseServiceAccount } from './firebase.service.account'
12-
1313
const MILLIS_FACTOR = 1000
1414

1515
@Injectable(AuthorizationService('Bearer'))

packages/dandi-contrib/mvc-auth-firebase/src/firebase.service.account.ts

-3
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,14 @@ export class FirebaseServiceAccount extends ModelBase implements admin.ServiceAc
2323
// Note: cannot use @dandi/model's source mapping because the snake_case properties
2424
// need to be accessible to Firebase
2525

26-
// eslint-disable-next-line camelcase,@typescript-eslint/camelcase
2726
private get project_id(): string {
2827
return this.projectId
2928
}
3029

31-
// eslint-disable-next-line camelcase,@typescript-eslint/camelcase
3230
private get client_email(): string {
3331
return this.clientEmail
3432
}
3533

36-
// eslint-disable-next-line camelcase,@typescript-eslint/camelcase
3734
private get private_key(): string {
3835
return this.privateKey
3936
}

packages/dandi-contrib/sentry-http-pipeline/src/sentry-error-handler.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import { SentryClient } from '@dandi-contrib/sentry'
12
import { Inject, Injectable } from '@dandi/core'
23
import { HttpPipelineErrorResult, HttpPipelineErrorResultHandler } from '@dandi/http-pipeline'
3-
import { SentryClient } from '@dandi-contrib/sentry'
44

55
@Injectable(HttpPipelineErrorResultHandler)
66
export class SentryErrorHandler implements HttpPipelineErrorResultHandler {

packages/dandi-contrib/sentry/src/sentry-client.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export class SentryClient {
1010
init(config)
1111
}
1212

13-
public configureScope(fn: (scope: Scope) => void) {
13+
public configureScope(fn: (scope: Scope) => void): void {
1414
configureScope(fn)
1515
}
1616

packages/dandi-contrib/sentry/src/sentry-on-config.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import { Severity } from '@sentry/types'
21
import { OnConfig, Provider } from '@dandi/core'
2+
import { Severity } from '@sentry/types'
3+
34
import { SentryClient } from './sentry-client'
45

56
function sentryOnConfigFactory(client: SentryClient) {

packages/dandi-contrib/sentry/src/sentry.module.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import { ConfigClientStatic } from '@dandi/config'
22
import { ModuleBuilder, Registerable } from '@dandi/core'
33

44
import { localToken } from './local-token'
5-
import { SentryOnConfig } from './sentry-on-config'
65
import { SentryClient } from './sentry-client'
76
import { SentryConfig } from './sentry-config'
7+
import { SentryOnConfig } from './sentry-on-config'
88

99
export class SentryModuleBuilder extends ModuleBuilder<SentryModuleBuilder> {
1010
constructor(...entries: Registerable[]) {

packages/dandi/cache/src/memory.cache.ts

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Injectable } from '@dandi/core'
22
import { Duration } from 'luxon'
33

44
import { Cache, CacheProvider, CacheProviderType } from './cache.provider'
5+
56
import Timer = NodeJS.Timer
67

78
@Injectable(CacheProvider(CacheProviderType.localMemory))

packages/dandi/common/src/app-error.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { CUSTOM_INSPECTOR } from './custom-inspector'
44
export const BASE_SPACER = ' '
55

66
export class AppError extends Error {
7-
public static stack(err: Error, level: number = 1): string {
7+
public static stack(err: Error, level = 1): string {
88
return err instanceof AppError ? err.getStack(level) : AppError.indent(err.stack, level)
99
}
1010

@@ -37,7 +37,7 @@ export class AppError extends Error {
3737
super(AppError.indent(message, 0))
3838
}
3939

40-
public getStack(level: number = 1): string {
40+
public getStack(level = 1): string {
4141
const spacer = AppError.getIndent(level)
4242
let stack = AppError.indent(this.stack.replace(/^Error:/, `${this.constructor.name}:`), level)
4343
if (this.innerError) {

packages/dandi/common/src/metadata.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export type MetadataAccessor<TMeta> = <T>(target: any) => TMeta
88
* @param target
99
* @param allowSuper controls whether existing metadata can be retrieved from a super class
1010
*/
11-
export function getMetadata<T>(key: symbol, init: () => T, target: any, allowSuper: boolean = false): T {
11+
export function getMetadata<T>(key: symbol, init: () => T, target: any, allowSuper = false): T {
1212
let meta: T = allowSuper || target.hasOwnProperty(key) ? Reflect.get(target, key) : undefined
1313
if (!meta) {
1414
meta = init ? init() : ({} as T)

0 commit comments

Comments
 (0)