Skip to content

Commit 2b61857

Browse files
committed
chore: lint
1 parent 8feb041 commit 2b61857

15 files changed

Lines changed: 75 additions & 116 deletions

‎.github/workflows/nodejs.yml‎

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,34 @@ jobs:
1010
strategy:
1111
matrix:
1212
node-version:
13-
- 16.x
14-
- 18.x
15-
- 19.x
13+
- 22.x
14+
- 24.x
15+
- 25.x
1616
steps:
17-
- uses: actions/checkout@v3
17+
- uses: actions/checkout@v5
18+
- uses: oven-sh/setup-bun@v2
19+
with:
20+
bun-version: latest
1821
- name: Use Node.js ${{ matrix.node-version }}
19-
uses: actions/setup-node@v3
22+
uses: actions/setup-node@v6
2023
with:
2124
node-version: ${{ matrix.node-version }}
2225
- name: Install
23-
run: npm i
26+
run: bun i --no-save
2427
- name: Install Redrun, Lerna
25-
run: npm i redrun -g
28+
run: bun i redrun -g --no-save
2629
- name: Lint
2730
run: redrun fix:lint
2831
- name: Commit fixes
2932
uses: EndBug/add-and-commit@v9
33+
continue-on-error: true
3034
with:
3135
message: "chore: ${{ env.NAME }}: actions: lint ☘️ "
3236
- name: Coverage
3337
run: redrun coverage report
3438
- name: Coveralls
35-
uses: coverallsapp/github-action@master
39+
uses: coverallsapp/github-action@v2
40+
continue-on-error: true
3641
with:
3742
github-token: ${{ secrets.GITHUB_TOKEN }}
3843
- name: typos-action

‎.madrun.js‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,8 @@ module.exports = {
1111
'watch:coverage': () => run('watch', 'redrun coverage'),
1212
'coverage': () => 'c8 npm test',
1313
'report': () => 'c8 report --reporter=text-lcov | coveralls',
14-
'lint:css': () => 'stylelint css/*.css',
15-
'lint:js': () => 'putout lib .madrun.js webpack.config.js',
16-
'lint': () => run('lint:*'),
17-
'fix:lint': async () => await run(['lint:js', 'lint:css'], '--fix'),
14+
'lint': () => 'putout .',
15+
'fix:lint': async () => await run('lint', '--fix'),
1816
'test': () => `tape 'lib/**/*.spec.js'`,
1917
'test:update': () => 'UPDATE_FIXTURE=1 redrun test',
2018
};
21-

‎.npmignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ yarn-error.log
1010
madrun.js
1111

1212
coverage
13+
*.config.*

‎.stylelintrc‎

Lines changed: 0 additions & 14 deletions
This file was deleted.

‎lib/get-class-name.js‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
'use strict';
22

33
module.exports = ({autoSize, isTitle}) => {
4-
const classNames = [
5-
'modal-main',
6-
];
4+
const classNames = ['modal-main'];
75

86
if (autoSize)
97
classNames.push('modal-autosize');
@@ -13,4 +11,3 @@ module.exports = ({autoSize, isTitle}) => {
1311

1412
return classNames.join(' ');
1513
};
16-

‎lib/get-class-name.spec.js‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,3 @@ test('get-class-name: autoSize, isTitle', (t) => {
4949
t.equal(result, expected);
5050
t.end();
5151
});
52-

‎lib/modal.js‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,18 @@ module.exports.open = (inner, options = {}) => {
5353
const isImage = isArray(inner);
5454
const isTitle = helpers.title && title || isImage;
5555

56-
const className = getClassName({autoSize, isTitle});
56+
const className = getClassName({
57+
autoSize,
58+
isTitle,
59+
});
5760

5861
const el = createElement('div', {
5962
innerHTML,
6063
className,
6164
dataName: 'modal-main',
6265
});
6366

64-
addAllEvents('main', onMainClick(onOverlayClick), [
65-
'click',
66-
'contextmenu',
67-
]);
67+
addAllEvents('main', onMainClick(onOverlayClick), ['click', 'contextmenu']);
6868

6969
query('close').addEventListener('click', close);
7070

@@ -125,4 +125,3 @@ function check(inner) {
125125
if (!inner)
126126
throw Error('inner should be DOM-element!');
127127
}
128-

‎lib/modal.spec.js‎

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
'use strict';
22

3-
const tryCatch = require('try-catch');
3+
require('css-modules-require-hook/preset');
4+
5+
const {tryCatch} = require('try-catch');
46

5-
const stub = require('@cloudcmd/stub');
67
const mockRequire = require('mock-require');
78

8-
require('css-modules-require-hook/preset');
9+
const autoGlobals = require('auto-globals');
10+
const {test: tape, stub}= require('supertape');
911

1012
const {
1113
open,
@@ -14,22 +16,15 @@ const {
1416
_onMainClick,
1517
} = require('./modal');
1618

17-
const autoGlobals = require('auto-globals');
18-
const tape = require('supertape');
19-
2019
const {create} = autoGlobals;
2120

22-
const {
23-
reRequire,
24-
stopAll,
25-
} = mockRequire;
21+
const {reRequire, stopAll} = mockRequire;
2622

2723
const test = autoGlobals(tape);
2824

2925
test('modal: open: main exist', (t) => {
3026
const el = {};
31-
const query = stub()
32-
.returns(el);
27+
const query = stub().returns(el);
3328

3429
mockRequire('./query', query);
3530

@@ -64,7 +59,7 @@ test('modal: open: beforeShow', (t) => {
6459

6560
stopAll();
6661

67-
t.ok(beforeShow.calledWith(), 'should call querySelector');
62+
t.calledWithNoArgs(beforeShow, 'should call querySelector');
6863
t.end();
6964
});
7065

@@ -134,6 +129,7 @@ test('modal: open: images', (t) => {
134129
}];
135130

136131
const afterShow = stub();
132+
137133
open(images, {
138134
afterShow,
139135
});
@@ -154,7 +150,7 @@ test('modal: open: images', (t) => {
154150

155151
stopAll();
156152

157-
t.ok(parseImages.calledWith(el, inner, options), 'should call querySelector');
153+
t.calledWith(parseImages, [el, inner, options], 'should call querySelector');
158154
t.end();
159155
});
160156

@@ -178,16 +174,13 @@ test('modal: onMainClick: no main', (t) => {
178174

179175
_onMainClick(overlayClick, e);
180176

181-
t.notOk(overlayClick.called, 'should not call overlayClick');
177+
t.notCalled(overlayClick, 'should not call overlayClick');
182178
t.end();
183179
});
184180

185181
test('modal: close: removeChild', (t, {document}) => {
186182
const el = {};
187-
const {
188-
querySelector,
189-
body,
190-
} = document;
183+
const {querySelector, body} = document;
191184

192185
querySelector.returns(el);
193186
close();
@@ -198,10 +191,7 @@ test('modal: close: removeChild', (t, {document}) => {
198191

199192
test('modal: close: removeChild: event', (t, {document}) => {
200193
const el = {};
201-
const {
202-
querySelector,
203-
body,
204-
} = document;
194+
const {querySelector, body} = document;
205195

206196
querySelector.returns(el);
207197
close();
@@ -223,7 +213,7 @@ test('modal: close: beforeClose', (t, {document}) => {
223213

224214
close();
225215

226-
t.ok(beforeClose.calledWith(), 'should call beforeClose');
216+
t.calledWithNoArgs(beforeClose, 'should call beforeClose');
227217
t.end();
228218
});
229219

@@ -240,7 +230,7 @@ test('modal: close: afterClose', (t, {document}) => {
240230

241231
close();
242232

243-
t.ok(afterClose.calledWith(), 'should call afterClose');
233+
t.calledWithNoArgs(afterClose, 'should call afterClose');
244234
t.end();
245235
});
246236

@@ -253,7 +243,6 @@ test('modal: close: no el', (t) => {
253243

254244
close();
255245

256-
t.notOk(beforeClose.called, 'should not call afterClose');
246+
t.notCalled(beforeClose, 'should not call afterClose');
257247
t.end();
258248
});
259-

‎lib/parse-images.js‎

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ const onKeydown = (img, images) => function keydownListener(e) {
2727

2828
const {keyCode} = e;
2929

30-
if (keyCode === ArrowLeft)
30+
if (keyCode === ArrowLeft) {
3131
--i;
32-
else if (keyCode === ArrowRight)
32+
} else if (keyCode === ArrowRight) {
3333
++i;
34-
else {
34+
} else {
3535
if (keyCode === Esc)
3636
return document.body.removeEventListener('keydown', keydownListener);
3737

@@ -52,10 +52,7 @@ function setImage(i, img, images) {
5252
query('nav-left').hidden = !i;
5353
query('nav-right').hidden = i === n;
5454

55-
const {
56-
href,
57-
title,
58-
} = images[i];
55+
const {href, title} = images[i];
5956

6057
img.src = href;
6158
img.title = title;
@@ -92,11 +89,9 @@ function parseImages(parent, images, {afterShow, helpers, index}) {
9289
setImage(index, img, images);
9390
addListenerOnce(img, 'load', onload(parent, afterShow));
9491

95-
query('nav-left')
96-
.addEventListener('click', prev(img, images));
92+
query('nav-left').addEventListener('click', prev(img, images));
9793

98-
query('nav-right')
99-
.addEventListener('click', next(img, images));
94+
query('nav-right').addEventListener('click', next(img, images));
10095

10196
document.body.addEventListener('keydown', onKeydown(img, images));
10297
}
@@ -126,4 +121,3 @@ module.exports._onKeydown = onKeydown;
126121
module.exports._indexStore = indexStore;
127122
module.exports._helpersStore = helpersStore;
128123
module.exports._onload = onload;
129-

0 commit comments

Comments
 (0)