Skip to content

Commit 8f0f4d4

Browse files
chore: restore some eslint rules (#2011)
* feat: add github action to test a ts project and build it * chore: restore no unused vars rule, except for fn params * chore: restore import order and run lint-fix * chore: remove unused rule * chore: restore prefer-destructuring rule and run lint-fix * chore: remove unused rules * chore: remove ts test * chore: restore import order for should
1 parent 1720b64 commit 8f0f4d4

25 files changed

+50
-56
lines changed

.eslintrc.js

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,28 +22,23 @@ module.exports = {
2222
rules: {
2323
'global-require': 'off',
2424
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
25-
'no-unused-vars': 'off',
25+
'no-unused-vars': ['error', { args: 'none' }],
2626
'no-underscore-dangle': 'off',
2727
'no-param-reassign': 'off',
2828
'no-restricted-syntax': 'off',
29-
camelcase: 'off',
3029
'default-case': 'off',
3130
'consistent-return': 'off',
32-
'import/order': 'off',
3331
'max-classes-per-file': 'off',
3432
'no-plusplus': 'off',
35-
'guard-for-in': 'off',
3633
'no-bitwise': 'off',
3734
'class-methods-use-this': 'off',
3835
'no-continue': 'off',
39-
'prefer-destructuring': 'off',
40-
'no-use-before-define': 'off',
4136
// Typescript rules
42-
'@typescript-eslint/interface-name-prefix': 'off',
43-
'@typescript-eslint/explicit-function-return-type': 'off',
44-
'@typescript-eslint/explicit-module-boundary-types': 'off',
4537
'@typescript-eslint/no-explicit-any': 'off',
46-
'@typescript-eslint/no-unused-vars': 'off',
38+
'@typescript-eslint/no-unused-vars': [
39+
'error',
40+
{ args: 'none' }
41+
],
4742
'@typescript-eslint/naming-convention': 'off',
4843
'@typescript-eslint/dot-notation': 'off',
4944
'@typescript-eslint/no-use-before-define': 'off',

src/bin/mqtt.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import publish from './pub'
1313
import subscribe from './sub'
1414

1515
// eslint-disable-next-line @typescript-eslint/no-var-requires
16-
const version = require('../../package.json').version
16+
const { version } = require('../../package.json')
1717

1818
const helpMe = help({
1919
dir: path.join(__dirname, '../../', 'help'),

src/bin/pub.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import help from 'help-me'
88

99
import minimist, { type ParsedArgs } from 'minimist'
1010
import split2 from 'split2'
11-
import { connect } from '../mqtt'
1211
import { type IClientOptions, type IClientPublishOptions } from 'src/lib/client'
1312
import { pipeline } from 'stream'
13+
import { connect } from '../mqtt'
1414

1515
const helpMe = help({
1616
dir: path.join(__dirname, '../../', 'help'),

src/bin/sub.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import path from 'path'
44
import fs from 'fs'
55
import minimist from 'minimist'
66
import help from 'help-me'
7-
import { connect } from '../mqtt'
87
import { type IClientOptions } from 'src/lib/client'
8+
import { connect } from '../mqtt'
99

1010
const helpMe = help({
1111
dir: path.join(__dirname, '../../', 'help'),

src/lib/client.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/**
22
* Module dependencies
33
*/
4-
import TopicAliasRecv from './topic-alias-recv'
54
import mqttPacket, {
65
type IAuthPacket,
76
IConnackPacket,
@@ -15,17 +14,18 @@ import mqttPacket, {
1514
type ISubackPacket,
1615
type IConnectPacket,
1716
} from 'mqtt-packet'
18-
import DefaultMessageIdProvider, {
19-
type IMessageIdProvider,
20-
} from './default-message-id-provider'
2117
import { type DuplexOptions, Writable } from 'readable-stream'
2218
import clone from 'rfdc/default'
23-
import * as validations from './validations'
2419
import _debug from 'debug'
25-
import Store, { type IStore } from './store'
26-
import handlePacket from './handlers'
2720
import type { ClientOptions } from 'ws'
2821
import { type ClientRequestArgs } from 'http'
22+
import * as validations from './validations'
23+
import Store, { type IStore } from './store'
24+
import handlePacket from './handlers'
25+
import DefaultMessageIdProvider, {
26+
type IMessageIdProvider,
27+
} from './default-message-id-provider'
28+
import TopicAliasRecv from './topic-alias-recv'
2929
import {
3030
type DoneCallback,
3131
type ErrorWithReasonCode,
@@ -1157,7 +1157,7 @@ export default class MqttClient extends TypedEventEmitter<MqttClientEventCallbac
11571157
}
11581158
opts = { ...defaultOpts, ...opts } as IClientSubscribeOptions
11591159

1160-
const properties = opts.properties
1160+
const { properties } = opts
11611161

11621162
const subs: ISubscriptionRequest[] = []
11631163

src/lib/connect/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ function parseAuthOptions(opts: IClientOptions) {
2828
if (opts.auth) {
2929
matches = opts.auth.match(/^(.+):(.+)$/)
3030
if (matches) {
31-
opts.username = matches[1]
32-
opts.password = matches[2]
31+
const [, username, password] = matches
32+
opts.username = username
33+
opts.password = password
3334
} else {
3435
opts.username = opts.auth
3536
}

src/lib/connect/socks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ import { Duplex } from 'stream'
33
import { SocksClient, type SocksProxy } from 'socks'
44
import * as dns from 'dns'
55
import { type SocksProxyType } from 'socks/typings/common/constants'
6-
import { type IStream } from '../shared'
76
import { promisify } from 'util'
87
import { type Socket } from 'net'
98
import assert from 'assert'
9+
import { type IStream } from '../shared'
1010

1111
const debug = _debug('mqttjs:socks')
1212

src/lib/connect/tcp.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import { type StreamBuilder } from '../shared'
2-
31
import net from 'net'
42
import _debug from 'debug'
3+
import { type StreamBuilder } from '../shared'
54
import openSocks from './socks'
65

76
const debug = _debug('mqttjs:tcp')

src/lib/connect/ws.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { type StreamBuilder } from '../shared'
21
import { Buffer } from 'buffer'
32
import Ws, { type ClientOptions } from 'ws'
43
import _debug from 'debug'
54
import { type DuplexOptions, Transform } from 'readable-stream'
5+
import { type StreamBuilder } from '../shared'
66
import isBrowser from '../is-browser'
77
import { type IClientOptions } from '../client'
88
import type MqttClient from '../client'

src/lib/connect/wx.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import { type StreamBuilder } from '../shared'
2-
31
import { Buffer } from 'buffer'
42
import { Transform } from 'readable-stream'
3+
import { type StreamBuilder } from '../shared'
54
import { type IClientOptions } from '../client'
65
import type MqttClient from '../client'
76
import { BufferedDuplex } from '../BufferedDuplex'

0 commit comments

Comments
 (0)