Skip to content

Commit b29b1d0

Browse files
committed
Add stylistic
1 parent fd0f940 commit b29b1d0

File tree

9 files changed

+144
-95
lines changed

9 files changed

+144
-95
lines changed

babel.config.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
'use strict';
2+
13
module.exports = {
2-
presets: [
3-
['@babel/preset-env', {
4-
forceAllTransforms: true,
5-
useBuiltIns: 'usage',
6-
corejs: 3,
7-
}],
8-
],
9-
}
4+
presets: [
5+
['@babel/preset-env', {
6+
forceAllTransforms: true,
7+
useBuiltIns: 'usage',
8+
corejs: 3,
9+
}],
10+
],
11+
};

eslint.config.js renamed to eslint.config.mjs

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
'use strict';
1+
import globals from 'globals';
2+
import eslintJS from '@eslint/js';
3+
import stylistic from '@stylistic/eslint-plugin';
24

3-
const globals = require('globals');
4-
const eslintJS = require('@eslint/js');
5-
6-
module.exports = [
5+
export default [
76
eslintJS.configs.recommended,
7+
stylistic.configs.recommended,
88
{
99
languageOptions: {
1010
sourceType: 'commonjs',
@@ -14,7 +14,6 @@ module.exports = [
1414
}
1515
},
1616
rules: {
17-
'indent': ['error', 4],
1817
'no-shadow': ['error'],
1918
'no-var': ['error'],
2019
'no-unused-vars': ['error', {
@@ -26,11 +25,28 @@ module.exports = [
2625
reportUsedIgnorePattern: false,
2726
}],
2827
'operator-linebreak': ['error', 'after'],
29-
'quote-props': ['error', 'consistent-as-needed'],
30-
'quotes': ['error', 'single'],
31-
'semi': ['error', 'always'],
32-
'space-before-function-paren': ['error', 'never'],
33-
'strict': ['error', 'safe']
28+
'strict': ['error', 'safe'],
29+
30+
// stylistic rules
31+
'@stylistic/arrow-parens': 0,
32+
'@stylistic/brace-style': ['error', '1tbs', { allowSingleLine: true }],
33+
'@stylistic/comma-dangle': 0,
34+
'@stylistic/generator-star-spacing': ['error', { before: true, after: true }],
35+
'@stylistic/indent': ['error', 4, { SwitchCase: 0 }],
36+
'@stylistic/indent-binary-ops': ['error', 4],
37+
'@stylistic/max-statements-per-line': 0,
38+
'@stylistic/no-multi-spaces': ['error', { ignoreEOLComments: true }],
39+
'@stylistic/operator-linebreak': ['error', 'after'],
40+
'@stylistic/quote-props': ['error', 'consistent-as-needed'],
41+
'@stylistic/quotes': ['error', 'single'],
42+
'@stylistic/semi': ['error', 'always'],
43+
'@stylistic/space-before-function-paren': ['error', {
44+
anonymous: 'never',
45+
named: 'never',
46+
asyncArrow: 'always',
47+
catch: 'always'
48+
}],
49+
'@stylistic/spaced-comment': 0,
3450
},
3551
},
3652
{

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"@babel/core": "^7.29.0",
2424
"@babel/preset-env": "^7.29.0",
2525
"@eslint/js": "^9.39.3",
26+
"@stylistic/eslint-plugin": "^5.9.0",
2627
"chai": "^6.2.2",
2728
"chai-subset": "^1.6.0",
2829
"compression-webpack-plugin": "^11.1.0",

src/channel.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,9 @@ module.exports = class IrcChannel {
191191
const updateUserList = (event) => {
192192
if (this.irc_client.caseCompare(event.channel, this.name)) {
193193
this.irc_client.removeListener('userlist', updateUserList);
194-
if (typeof cb === 'function') { cb(this); }
194+
if (typeof cb === 'function') {
195+
cb(this);
196+
}
195197
}
196198
};
197199

src/commands/handlers/registration.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,8 @@ const handlers = {
261261
const cap = capabilities[i];
262262
if (
263263
want.indexOf(cap) > -1 &&
264-
request_caps.indexOf(cap) === -1 &&
265-
!handler.network.cap.isEnabled(cap)
264+
request_caps.indexOf(cap) === -1 &&
265+
!handler.network.cap.isEnabled(cap)
266266
) {
267267
handler.network.cap.requested.push(cap);
268268
request_caps.push(cap);

test/transports/net.test.mjs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1327,10 +1327,10 @@ describe('src/transports/net.js', function() {
13271327
it('should decode latin1 data correctly', function() {
13281328
assertDecoded('latin1', [
13291329
// "PRIVMSG #chan :H" (ASCII)
1330-
0x50,0x52,0x49,0x56,0x4D,0x53,0x47,0x20,0x23,0x63,0x68,0x61,0x6E,0x20,0x3A,0x48,
1330+
0x50, 0x52, 0x49, 0x56, 0x4D, 0x53, 0x47, 0x20, 0x23, 0x63, 0x68, 0x61, 0x6E, 0x20, 0x3A, 0x48,
13311331
0xE9, // é
1332-
0x6C,0x6C,0x6F,0x20, // llo SP
1333-
0x57,0xF6,0x72,0x6C,0x64, // Wörld
1332+
0x6C, 0x6C, 0x6F, 0x20, // llo SP
1333+
0x57, 0xF6, 0x72, 0x6C, 0x64, // Wörld
13341334
0x0D, 0x0A,
13351335
], 'H\u00E9llo W\u00F6rld');
13361336
});
@@ -1339,9 +1339,9 @@ describe('src/transports/net.js', function() {
13391339
it('should decode win1251 (Cyrillic) data correctly', function() {
13401340
assertDecoded('win1251', [
13411341
// "PRIVMSG #chan :" (ASCII)
1342-
0x50,0x52,0x49,0x56,0x4D,0x53,0x47,0x20,0x23,0x63,0x68,0x61,0x6E,0x20,0x3A,
1343-
0xCF,0xF0,0xE8,0xE2,0xE5,0xF2,0x20, // Привет SP
1344-
0xEC,0xE8,0xF0, // мир
1342+
0x50, 0x52, 0x49, 0x56, 0x4D, 0x53, 0x47, 0x20, 0x23, 0x63, 0x68, 0x61, 0x6E, 0x20, 0x3A,
1343+
0xCF, 0xF0, 0xE8, 0xE2, 0xE5, 0xF2, 0x20, // Привет SP
1344+
0xEC, 0xE8, 0xF0, // мир
13451345
0x0D, 0x0A,
13461346
], '\u041F\u0440\u0438\u0432\u0435\u0442 \u043C\u0438\u0440');
13471347
});
@@ -1350,12 +1350,12 @@ describe('src/transports/net.js', function() {
13501350
it('should decode shiftjis (Japanese) data correctly', function() {
13511351
assertDecoded('shiftjis', [
13521352
// "PRIVMSG #chan :" (ASCII)
1353-
0x50,0x52,0x49,0x56,0x4D,0x53,0x47,0x20,0x23,0x63,0x68,0x61,0x6E,0x20,0x3A,
1354-
0x82,0xB1, // こ
1355-
0x82,0xF1, // ん
1356-
0x82,0xC9, // に
1357-
0x82,0xBF, // ち
1358-
0x82,0xCD, // は
1353+
0x50, 0x52, 0x49, 0x56, 0x4D, 0x53, 0x47, 0x20, 0x23, 0x63, 0x68, 0x61, 0x6E, 0x20, 0x3A,
1354+
0x82, 0xB1, // こ
1355+
0x82, 0xF1, // ん
1356+
0x82, 0xC9, // に
1357+
0x82, 0xBF, // ち
1358+
0x82, 0xCD, // は
13591359
0x0D, 0x0A,
13601360
], '\u3053\u3093\u306B\u3061\u306F');
13611361
});
@@ -1364,9 +1364,9 @@ describe('src/transports/net.js', function() {
13641364
it('should decode gbk (Simplified Chinese) data correctly', function() {
13651365
assertDecoded('gbk', [
13661366
// "PRIVMSG #chan :" (ASCII)
1367-
0x50,0x52,0x49,0x56,0x4D,0x53,0x47,0x20,0x23,0x63,0x68,0x61,0x6E,0x20,0x3A,
1368-
0xC4,0xE3, // 你
1369-
0xBA,0xC3, // 好
1367+
0x50, 0x52, 0x49, 0x56, 0x4D, 0x53, 0x47, 0x20, 0x23, 0x63, 0x68, 0x61, 0x6E, 0x20, 0x3A,
1368+
0xC4, 0xE3, // 你
1369+
0xBA, 0xC3, // 好
13701370
0x0D, 0x0A,
13711371
], '\u4F60\u597D');
13721372
});
@@ -1375,9 +1375,9 @@ describe('src/transports/net.js', function() {
13751375
it('should decode iso-8859-7 (Greek) data correctly', function() {
13761376
assertDecoded('iso-8859-7', [
13771377
// "PRIVMSG #chan :" (ASCII)
1378-
0x50,0x52,0x49,0x56,0x4D,0x53,0x47,0x20,0x23,0x63,0x68,0x61,0x6E,0x20,0x3A,
1379-
0xC3,0xE5,0xE9,0xE1,0x20, // Γεια SP
1380-
0xF3,0xEF,0xF5, // σου
1378+
0x50, 0x52, 0x49, 0x56, 0x4D, 0x53, 0x47, 0x20, 0x23, 0x63, 0x68, 0x61, 0x6E, 0x20, 0x3A,
1379+
0xC3, 0xE5, 0xE9, 0xE1, 0x20, // Γεια SP
1380+
0xF3, 0xEF, 0xF5, // σου
13811381
0x0D, 0x0A,
13821382
], '\u0393\u03B5\u03B9\u03B1 \u03C3\u03BF\u03C5');
13831383
});

test/transports/websocket.test.mjs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ chaiUse(sinonChai);
1313

1414
function createMockWebSocket() {
1515
return {
16-
send: sinon.stub(),
17-
close: sinon.stub(),
18-
onopen: null,
19-
onclose: null,
16+
send: sinon.stub(),
17+
close: sinon.stub(),
18+
onopen: null,
19+
onclose: null,
2020
onmessage: null,
21-
onerror: null,
21+
onerror: null,
2222
};
2323
}
2424

@@ -28,8 +28,8 @@ describe('src/transports/websocket.js', function() {
2828
let WebSocketStub;
2929

3030
beforeEach(function() {
31-
sandbox = sinon.createSandbox();
32-
mockWs = createMockWebSocket();
31+
sandbox = sinon.createSandbox();
32+
mockWs = createMockWebSocket();
3333
// The stub acts as the constructor - every `new WebSocket(...)` returns
3434
// the same mockWs so tests can inspect calls on it directly.
3535
WebSocketStub = sinon.stub().returns(mockWs);
@@ -656,10 +656,10 @@ describe('src/transports/websocket.js', function() {
656656
it('should null out all event handler properties on the socket', function() {
657657
const conn = new Connection({});
658658
const ws = createMockWebSocket();
659-
ws.onopen = () => {};
660-
ws.onclose = () => {};
659+
ws.onopen = () => {};
660+
ws.onclose = () => {};
661661
ws.onmessage = () => {};
662-
ws.onerror = () => {};
662+
ws.onerror = () => {};
663663
conn.socket = ws;
664664
conn.connected = false;
665665
conn.disposeSocket();

webpack.config.js

Lines changed: 45 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,53 @@
1-
// webpack v4
1+
'use strict';
2+
23
const path = require('path');
34
const CompressionPlugin = require('compression-webpack-plugin');
45

5-
const shouldCompress = /\.(js|css|html|svg)(\.map)?$/
6+
const shouldCompress = /\.(js|css|html|svg)(\.map)?$/;
67

78
module.exports = {
8-
mode: 'production',
9-
entry: './dist/browser/src',
10-
output: {
11-
path: path.join(path.resolve(__dirname), 'dist', 'browser', 'static'),
12-
filename: 'browser.js',
13-
library: 'irc-framework',
14-
libraryTarget: 'umd',
15-
umdNamedDefine: true
16-
},
17-
module: {
18-
rules: [ ]
19-
},
20-
resolve: {
21-
fallback: {
22-
// Fallback modules for node internals when building with webpack5
23-
'stream': require.resolve('stream-browserify'),
24-
'buffer': require.resolve('buffer/'),
25-
'util': require.resolve('util/'),
9+
mode: 'production',
10+
entry: './dist/browser/src',
11+
output: {
12+
path: path.join(path.resolve(__dirname), 'dist', 'browser', 'static'),
13+
filename: 'browser.js',
14+
library: 'irc-framework',
15+
libraryTarget: 'umd',
16+
umdNamedDefine: true
17+
},
18+
module: {
19+
rules: []
20+
},
21+
resolve: {
22+
fallback: {
23+
// Fallback modules for node internals when building with webpack5
24+
stream: require.resolve('stream-browserify'),
25+
buffer: require.resolve('buffer/'),
26+
util: require.resolve('util/'),
27+
},
2628
},
27-
},
28-
plugins: [
29-
new CompressionPlugin({
30-
filename: "[path][base].gz",
31-
algorithm: "gzip",
32-
test: shouldCompress,
33-
}),
34-
new CompressionPlugin({
35-
filename: "[path][base].br",
36-
algorithm: 'brotliCompress',
37-
test: shouldCompress,
38-
}),
39-
],
40-
optimization: {
41-
minimize: true
42-
},
43-
devtool: 'source-map',
44-
performance: {
45-
assetFilter: assetFilename =>
46-
!assetFilename.match(/\.map(\.(gz|br))?$/),
29+
plugins: [
30+
new CompressionPlugin({
31+
filename: '[path][base].gz',
32+
algorithm: 'gzip',
33+
test: shouldCompress,
34+
}),
35+
new CompressionPlugin({
36+
filename: '[path][base].br',
37+
algorithm: 'brotliCompress',
38+
test: shouldCompress,
39+
}),
40+
],
41+
optimization: {
42+
minimize: true
43+
},
44+
devtool: 'source-map',
45+
performance: {
46+
assetFilter: assetFilename =>
47+
!assetFilename.match(/\.map(\.(gz|br))?$/),
4748

48-
// Prevent warnings about entrypoint and asset size
49-
maxEntrypointSize: 343040, // 335KiB
50-
maxAssetSize: 343040, // 335KiB
51-
},
49+
// Prevent warnings about entrypoint and asset size
50+
maxEntrypointSize: 343040, // 335KiB
51+
maxAssetSize: 343040, // 335KiB
52+
},
5253
};

yarn.lock

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,7 @@
805805
resolved "https://registry.yarnpkg.com/@discoveryjs/json-ext/-/json-ext-0.6.3.tgz#f13c7c205915eb91ae54c557f5e92bddd8be0e83"
806806
integrity sha512-4B4OijXeVNOPZlYA2oEwWOTkzyltLao+xbotHQeqN++Rv27Y6s818+n2Qkp8q+Fxhn0t/5lA5X1Mxktud8eayQ==
807807

808-
"@eslint-community/eslint-utils@^4.8.0":
808+
"@eslint-community/eslint-utils@^4.8.0", "@eslint-community/eslint-utils@^4.9.1":
809809
version "4.9.1"
810810
resolved "https://registry.yarnpkg.com/@eslint-community/eslint-utils/-/eslint-utils-4.9.1.tgz#4e90af67bc51ddee6cdef5284edf572ec376b595"
811811
integrity sha512-phrYmNiYppR7znFEdqgfWHXR6NCkZEK7hwWDHZUjit/2/U0r6XvkDl0SYnoM51Hq7FhCGdLDT6zxCCOY1hexsQ==
@@ -1019,6 +1019,18 @@
10191019
"@sinonjs/commons" "^3.0.1"
10201020
type-detect "^4.1.0"
10211021

1022+
"@stylistic/eslint-plugin@^5.9.0":
1023+
version "5.9.0"
1024+
resolved "https://registry.yarnpkg.com/@stylistic/eslint-plugin/-/eslint-plugin-5.9.0.tgz#b7d23ac17dd8a1868eb7ac142f3ba6d627516e2a"
1025+
integrity sha512-FqqSkvDMYJReydrMhlugc71M76yLLQWNfmGq+SIlLa7N3kHp8Qq8i2PyWrVNAfjOyOIY+xv9XaaYwvVW7vroMA==
1026+
dependencies:
1027+
"@eslint-community/eslint-utils" "^4.9.1"
1028+
"@typescript-eslint/types" "^8.56.0"
1029+
eslint-visitor-keys "^4.2.1"
1030+
espree "^10.4.0"
1031+
estraverse "^5.3.0"
1032+
picomatch "^4.0.3"
1033+
10221034
"@types/color-name@^1.1.1":
10231035
version "1.1.1"
10241036
resolved "https://registry.yarnpkg.com/@types/color-name/-/color-name-1.1.1.tgz#1c1261bbeaa10a8055bbc5d8ab84b7b2afc846a0"
@@ -1055,6 +1067,11 @@
10551067
resolved "https://registry.yarnpkg.com/@types/node/-/node-15.12.4.tgz#e1cf817d70a1e118e81922c4ff6683ce9d422e26"
10561068
integrity sha512-zrNj1+yqYF4WskCMOHwN+w9iuD12+dGm0rQ35HLl9/Ouuq52cEtd0CH9qMgrdNmi5ejC1/V7vKEXYubB+65DkA==
10571069

1070+
"@typescript-eslint/types@^8.56.0":
1071+
version "8.56.1"
1072+
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-8.56.1.tgz#975e5942bf54895291337c91b9191f6eb0632ab9"
1073+
integrity sha512-dbMkdIUkIkchgGDIv7KLUpa0Mda4IYjo4IAMJUZ+3xNoUXxMsk9YtKpTHSChRS85o+H9ftm51gsK1dZReY9CVw==
1074+
10581075
"@webassemblyjs/ast@1.14.1", "@webassemblyjs/ast@^1.14.1":
10591076
version "1.14.1"
10601077
resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.14.1.tgz#a9f6a07f2b03c95c8d38c4536a1fdfb521ff55b6"
@@ -2028,6 +2045,11 @@ estraverse@^5.1.0, estraverse@^5.2.0:
20282045
resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-5.2.0.tgz#307df42547e6cc7324d3cf03c155d5cdb8c53880"
20292046
integrity sha512-BxbNGGNm0RyRYvUdHpIwv9IWzeM9XClbOxwoATuFdOE7ZE6wHL+HQ5T8hoPM+zHvmKzzsEqhgy0GrQ5X13afiQ==
20302047

2048+
estraverse@^5.3.0:
2049+
version "5.3.0"
2050+
resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-5.3.0.tgz#2eea5290702f26ab8fe5370370ff86c965d21123"
2051+
integrity sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==
2052+
20312053
esutils@^2.0.2:
20322054
version "2.0.3"
20332055
resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.3.tgz#74d2eb4de0b8da1293711910d50775b9b710ef64"
@@ -3300,6 +3322,11 @@ picomatch@^2.0.4, picomatch@^2.2.1, picomatch@^2.3.1:
33003322
resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42"
33013323
integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==
33023324

3325+
picomatch@^4.0.3:
3326+
version "4.0.3"
3327+
resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-4.0.3.tgz#796c76136d1eead715db1e7bad785dedd695a042"
3328+
integrity sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==
3329+
33033330
pidtree@^0.3.0:
33043331
version "0.3.1"
33053332
resolved "https://registry.yarnpkg.com/pidtree/-/pidtree-0.3.1.tgz#ef09ac2cc0533df1f3250ccf2c4d366b0d12114a"

0 commit comments

Comments
 (0)