Skip to content

Commit 7c27a91

Browse files
committed
Update eslint config and tests
1 parent 2d1f6a5 commit 7c27a91

File tree

17 files changed

+1856
-327
lines changed

17 files changed

+1856
-327
lines changed

eslint.config.js

Lines changed: 62 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,64 @@
1-
module.exports = {
2-
root: true,
3-
extends: [
4-
'eslint:recommended',
5-
'standard'
6-
],
7-
parserOptions: {
8-
sourceType: 'script',
1+
'use strict';
2+
3+
const globals = require('globals');
4+
const eslintJS = require('@eslint/js');
5+
6+
module.exports = [
7+
eslintJS.configs.recommended,
8+
{
9+
languageOptions: {
10+
sourceType: 'commonjs',
11+
globals: {
12+
...globals.browser,
13+
...globals.node,
14+
}
15+
},
16+
rules: {
17+
'indent': ['error', 4],
18+
'no-shadow': ['error'],
19+
'no-var': ['error'],
20+
'no-unused-vars': ['error', {
21+
vars: 'all',
22+
args: 'none',
23+
caughtErrors: 'none',
24+
ignoreRestSiblings: false,
25+
ignoreUsingDeclarations: false,
26+
reportUsedIgnorePattern: false,
27+
}],
28+
'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']
34+
},
935
},
10-
env: {
11-
'browser': true,
12-
'node': true,
36+
{
37+
files: ['test/**/*.mjs'],
38+
languageOptions: {
39+
sourceType: 'module',
40+
globals: {
41+
afterEach: 'readonly',
42+
beforeEach: 'readonly',
43+
describe: 'readonly',
44+
it: 'readonly',
45+
},
46+
},
47+
rules: {
48+
'no-unused-expressions': 0,
49+
'comma-dangle': ['error', {
50+
arrays: 'always-multiline',
51+
objects: 'always-multiline',
52+
imports: 'never',
53+
exports: 'never',
54+
functions: 'ignore',
55+
}],
56+
},
1357
},
14-
'rules': {
15-
'camelcase': 0,
16-
'comma-dangle': 0,
17-
'indent': ['error', 4],
18-
'new-cap': 0,
19-
'no-shadow': ['error'],
20-
'no-var': ['error'],
21-
'operator-linebreak': ['error', 'after'],
22-
'semi': ['error', 'always'],
23-
'space-before-function-paren': ['error', 'never'],
24-
'standard/no-callback-literal': 0,
25-
'n/no-callback-literal': 0,
26-
"object-shorthand": 0,
27-
}
28-
};
58+
{
59+
files: ['examples/**/*.js'],
60+
rules: {
61+
strict: 0,
62+
},
63+
},
64+
];

src/commands/handlers/misc.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -364,9 +364,9 @@ function standardReply(command, handler) {
364364
handler.emit('standard reply', {
365365
type: command.command,
366366
command: cmd,
367-
code,
368-
context,
369-
description,
367+
code: code,
368+
context: context,
369+
description: description,
370370
tags: command.tags,
371371
});
372372
}

src/commands/numerics.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
'use strict';
22

3-
/* eslint-disable quote-props */
43
module.exports = {
54
'001': 'RPL_WELCOME',
65
'002': 'RPL_YOURHOST',

src/ircmessage.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
const MessageTags = require('./messagetags');
24

35
module.exports = class IrcMessage {

src/linebreak.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
const GraphemeSplitter = require('grapheme-splitter');
24
const { encode: encodeUTF8 } = require('isomorphic-textencoder');
35

test/casefolding.mjs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
'use strict';
2-
/* globals describe, it */
3-
const chai = require('chai');
4-
const IrcClient = require('../src/client');
5-
const expect = chai.expect;
1+
import { expect, use as chaiUse } from 'chai';
2+
import chaiSubset from 'chai-subset';
63

7-
chai.use(require('chai-subset'));
4+
import IrcClient from '../src/client.js';
5+
6+
chaiUse(chaiSubset);
87

98
describe('src/client.js', function() {
109
describe('caseLower', function() {
@@ -69,7 +68,6 @@ describe('src/client.js', function() {
6968
});
7069
});
7170

72-
/* eslint-disable no-unused-expressions */
7371
describe('caseCompare', function() {
7472
it('CASEMAPPING=rfc1459', function() {
7573
const client = new IrcClient();

test/commands/handlers/misc.test.mjs

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
1-
'use strict';
1+
import { expect, use as chaiUse } from 'chai';
2+
import sinonChai from 'sinon-chai';
23

3-
/* globals describe, it */
4-
/* eslint-disable no-unused-expressions */
5-
const chai = require('chai');
6-
const expect = chai.expect;
7-
const mocks = require('../../mocks');
8-
const sinonChai = require('sinon-chai');
9-
const misc = require('../../../src/commands/handlers/misc');
10-
const IrcCommand = require('../../../src/commands/command');
4+
import * as mocks from '../../mocks.mjs';
115

12-
chai.use(sinonChai);
6+
import misc from '../../../src/commands/handlers/misc.js';
7+
import IrcCommand from '../../../src/commands/command.js';
8+
9+
chaiUse(sinonChai);
1310

1411
describe('src/commands/handlers/misc.js', function() {
1512
describe('PING handler', function() {
@@ -18,7 +15,7 @@ describe('src/commands/handlers/misc.js', function() {
1815
params: ['example.com'],
1916
tags: {
2017
time: '2021-06-29T16:42:00Z',
21-
}
18+
},
2219
});
2320
mock.handlers.PING(cmd, mock.spies);
2421

@@ -33,8 +30,8 @@ describe('src/commands/handlers/misc.js', function() {
3330
message: undefined,
3431
time: 1624984920000,
3532
tags: {
36-
time: '2021-06-29T16:42:00Z'
37-
}
33+
time: '2021-06-29T16:42:00Z',
34+
},
3835
});
3936
});
4037
});
@@ -46,7 +43,7 @@ describe('src/commands/handlers/misc.js', function() {
4643
params: ['one.example.com', 'two.example.com'],
4744
tags: {
4845
time: '2011-10-10T14:48:00Z',
49-
}
46+
},
5047
});
5148
mock.handlers.PONG(cmd, mock.spies);
5249
expect(mock.spies.network.addServerTimeOffset).to.have.been.calledOnce;
@@ -55,8 +52,8 @@ describe('src/commands/handlers/misc.js', function() {
5552
message: 'two.example.com',
5653
time: 1318258080000,
5754
tags: {
58-
time: '2011-10-10T14:48:00Z'
59-
}
55+
time: '2011-10-10T14:48:00Z',
56+
},
6057
});
6158
});
6259
});

test/helper.test.mjs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
'use strict';
1+
import { expect, use as chaiUse } from 'chai';
2+
import chaiSubset from 'chai-subset';
23

3-
/* globals describe, it */
4-
const chai = require('chai');
5-
const Helper = require('../src/helpers');
6-
const expect = chai.expect;
4+
import Helper from '../src/helpers.js';
75

8-
chai.use(require('chai-subset'));
6+
chaiUse(chaiSubset);
97

108
describe('src/irclineparser.js', function() {
119
describe('mask parsing', function() {

0 commit comments

Comments
 (0)