Skip to content

Commit

Permalink
chore: update eslint to v9 with flat config
Browse files Browse the repository at this point in the history
  • Loading branch information
wkillerud committed Apr 15, 2024
1 parent 2a34ae6 commit 0ef6a5d
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 31 deletions.
12 changes: 0 additions & 12 deletions .eslintrc

This file was deleted.

2 changes: 1 addition & 1 deletion .prettierrc
Expand Up @@ -4,7 +4,7 @@
"tabWidth": 4,
"overrides": [
{
"files": [".prettierrc", "*.json", "*.yml", ".travis.yml", ".eslintrc"],
"files": [".prettierrc", "*.json", "*.yml", ".travis.yml"],
"options": {
"tabWidth": 2
}
Expand Down
20 changes: 20 additions & 0 deletions eslint.config.js
@@ -0,0 +1,20 @@
import prettierConfig from 'eslint-config-prettier';
import prettierPlugin from 'eslint-plugin-prettier';
import globals from 'globals';
import js from '@eslint/js';

export default [
js.configs.recommended,
prettierConfig,
{
plugins: {
prettier: prettierPlugin,
},
languageOptions: {
globals: {
...globals.browser,
global: true,
},
},
},
];
3 changes: 1 addition & 2 deletions package.json
Expand Up @@ -46,10 +46,9 @@
"@rollup/plugin-commonjs": "25.0.7",
"@rollup/plugin-node-resolve": "15.2.3",
"eslint": "9.0.0",
"eslint-config-airbnb-base": "15.0.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-import": "2.29.1",
"eslint-plugin-prettier": "5.1.3",
"globals": "15.0.0",
"prettier": "3.2.5",
"rollup": "4.14.3",
"tap": "15.2.3"
Expand Down
2 changes: 1 addition & 1 deletion test/Event.test.js
Expand Up @@ -2,7 +2,7 @@ import tap from 'tap';
import Event from '../src/Event.js';
import { toKey } from '../src/utils.js';

tap.test('toKey() - should return key format', t => {
tap.test('toKey() - should return key format', (t) => {
const channel = 'foo';
const topic = 'bar';
const event = new Event(channel, topic, 'payload');
Expand Down
21 changes: 10 additions & 11 deletions test/MessageBus.test.js
Expand Up @@ -5,37 +5,36 @@ let bus;

tap.beforeEach(() => {
// Need to clear the global between tests for a clean slate
// eslint-disable-next-line no-undef
globalThis['@podium'] = null;
bus = new MessageBus();
});

tap.test('subscribe() - should be a function', t => {
tap.test('subscribe() - should be a function', (t) => {
t.ok(typeof bus.subscribe === 'function');
t.end();
});

tap.test('publish() - should be a function', t => {
tap.test('publish() - should be a function', (t) => {
t.ok(typeof bus.publish === 'function');
t.end();
});

tap.test('publish() - should invoke subscribed listener', t => {
tap.test('publish() - should invoke subscribed listener', (t) => {
const payload = { a: 'b' };
bus.subscribe('foo', 'bar', event => {
bus.subscribe('foo', 'bar', (event) => {
t.equal(event.payload, payload);
t.end();
});
bus.publish('foo', 'bar', payload);
});

tap.test('unsubscribe() - should remove subscribed listener', t => {
tap.test('unsubscribe() - should remove subscribed listener', (t) => {
const channel = 'channel';
const topic = 'topic';

let cbCount = 0;

const callback = event => {
const callback = (event) => {
t.equal(event.channel, channel);
t.equal(event.topic, topic);
cbCount += 1;
Expand All @@ -61,12 +60,12 @@ tap.test('unsubscribe() - should remove subscribed listener', t => {
t.end();
});

tap.test('peek() - should initially be undefined', t => {
tap.test('peek() - should initially be undefined', (t) => {
t.ok(bus.peek('channel', 'topic') === undefined);
t.end();
});

tap.test('peek() - should return latest event', t => {
tap.test('peek() - should return latest event', (t) => {
const channel = 'channel';
const topic = 'topic';

Expand All @@ -78,12 +77,12 @@ tap.test('peek() - should return latest event', t => {
t.end();
});

tap.test('log() - should initially be empty', t => {
tap.test('log() - should initially be empty', (t) => {
t.same(bus.log('channel', 'topic'), []);
t.end();
});

tap.test('log() - should retrieve earlier events, newest first', t => {
tap.test('log() - should retrieve earlier events, newest first', (t) => {
const channel = 'channel';
const topic = 'topic';

Expand Down
6 changes: 3 additions & 3 deletions test/Sink.test.js
Expand Up @@ -7,17 +7,17 @@ tap.beforeEach(() => {
sink = new Sink();
});

tap.test('log() - should be a function', t => {
tap.test('log() - should be a function', (t) => {
t.ok(typeof sink.log === 'function');
t.end();
});

tap.test('log() - should initially return an empty array', t => {
tap.test('log() - should initially return an empty array', (t) => {
t.same(sink.log('foo', 'bar'), []);
t.end();
});

tap.test('push() - should be a function', t => {
tap.test('push() - should be a function', (t) => {
t.ok(typeof sink.push === 'function');
t.end();
});
2 changes: 1 addition & 1 deletion test/utils.test.js
@@ -1,7 +1,7 @@
import tap from 'tap';
import { toKey } from '../src/utils.js';

tap.test('toKey() - should return key format', t => {
tap.test('toKey() - should return key format', (t) => {
const channel = 'foo';
const topic = 'bar';
t.ok(toKey(channel, topic) === `${channel}:${topic}`);
Expand Down

0 comments on commit 0ef6a5d

Please sign in to comment.