Skip to content

Commit 7badec9

Browse files
committed
Add Prettier, ESLint and Husky
1 parent d997145 commit 7badec9

17 files changed

+2289
-646
lines changed

.github/workflows/ci.yml

+16-16
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,22 @@ jobs:
1313
runs-on: ubuntu-latest
1414

1515
steps:
16-
- name: Checkout the repository
17-
uses: actions/checkout@v2
16+
- name: Checkout the repository
17+
uses: actions/checkout@v2
1818

19-
- name: Set up Node.js
20-
uses: actions/setup-node@v3
21-
with:
22-
node-version: '16'
19+
- name: Set up Node.js
20+
uses: actions/setup-node@v3
21+
with:
22+
node-version: "16"
2323

24-
- name: Install dependencies
25-
run: npm install
24+
- name: Install dependencies
25+
run: npm install
2626

27-
- name: Run tests
28-
run: npm test
29-
30-
- name: Upload coverage reports to Codecov
31-
uses: codecov/codecov-action@v5
32-
with:
33-
token: ${{ secrets.CODECOV_TOKEN }}
34-
slug: dubrox/Multiple-Dates-Picker-for-jQuery-UI
27+
- name: Run tests
28+
run: npm test
29+
30+
- name: Upload coverage reports to Codecov
31+
uses: codecov/codecov-action@v5
32+
with:
33+
token: ${{ secrets.CODECOV_TOKEN }}
34+
slug: dubrox/Multiple-Dates-Picker-for-jQuery-UI

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.eslintcache
12
.idea
23
/node_modules/
3-
/coverage/
4+
/coverage/

.husky/pre-commit

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
npx lint-staged

.prettierignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Ignore artifacts:
2+
build
3+
coverage

.prettierrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

.vscode/settings.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"editor.tabSize": 2
3+
}

README.md

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,26 @@
1-
MultiDatesPicker for jQuery UI
2-
==============================
1+
# MultiDatesPicker for jQuery UI
32

43
![codecov](https://codecov.io/gh/dubrox/Multiple-Dates-Picker-for-jQuery-UI/branch/main/graph/badge.svg)
54

6-
This plugin extends the jQuery UI datepicker clendar, allowing to select more than one date,
5+
This plugin extends the jQuery UI datepicker clendar, allowing to select more than one date,
76
picking them one by one or by ranges relative to the clicked date.
87

98
Take a look at [some demos](http://dubrox.github.io/Multiple-Dates-Picker-for-jQuery-UI/#demos).
109

1110
## Install
1211

13-
With any of the following package managers:
12+
With any of the following package managers:
1413

1514
`bower install jquery-ui-multidatespicker`
1615

1716
`npm install jquery-ui-multidatespicker`
1817

1918
`yarn add jquery-ui-multidatespicker`
2019

21-
Download the [zip](https://github.com/dubrox/Multiple-Dates-Picker-for-jQuery-UI/archive/latest.zip)
20+
Download the [zip](https://github.com/dubrox/Multiple-Dates-Picker-for-jQuery-UI/archive/latest.zip)
2221
and place wherever you need it:
2322

2423
## Use
2524

26-
For documentation and examples, check
25+
For documentation and examples, check
2726
[the official MDP page](https://dubrox.github.io/Multiple-Dates-Picker-for-jQuery-UI).

__tests__/multidatespicker.test.js

+18-16
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ describe("MDP Initialization", function () {
99
document.body.innerHTML = '<input id="datepicker" />';
1010
$input = $("#datepicker");
1111

12-
spyDatepickerUpdate = jest.spyOn($.datepicker, '_updateDatepicker');
12+
spyDatepickerUpdate = jest.spyOn($.datepicker, "_updateDatepicker");
1313

1414
// fix the offsetWidth to make the datepicker visible in jsdom
15-
jest.spyOn($input[0], 'offsetWidth', 'get').mockReturnValue(1);
15+
jest.spyOn($input[0], "offsetWidth", "get").mockReturnValue(1);
1616
});
1717

1818
afterEach(function () {
@@ -26,27 +26,27 @@ describe("MDP Initialization", function () {
2626

2727
it("should call a beforeShow event with default behavior", function () {
2828
$input.multiDatesPicker();
29-
29+
3030
// triggers the beforeShow event
31-
$input.trigger('focus');
31+
$input.trigger("focus");
3232

3333
expect(spyDatepickerUpdate).toHaveBeenCalledTimes(normalDatepickerUpdates);
3434
});
3535

3636
it("should call a custom beforeShow event that interrupts the default behavior", function () {
37-
const beforeShow = jest.fn(_ => false); // returning false to interrupt the default behavior
37+
const beforeShow = jest.fn((_) => false); // returning false to interrupt the default behavior
3838
$input.multiDatesPicker({ beforeShow });
3939

4040
// triggers the beforeShow event with a custom function
41-
$input.trigger('focus');
41+
$input.trigger("focus");
4242

4343
expect(beforeShow).toHaveBeenCalled();
44-
expect(spyDatepickerUpdate).toHaveBeenCalledTimes(normalDatepickerUpdates - 1);
44+
expect(spyDatepickerUpdate).toHaveBeenCalledTimes(
45+
normalDatepickerUpdates - 1,
46+
);
4547
});
4648
});
4749

48-
49-
5050
describe("setMode", function () {
5151
let $input, date;
5252

@@ -190,7 +190,7 @@ describe("init", function () {
190190

191191
it("should correctly set disabled dates and update calendar range", function () {
192192
const $input = $('<input type="text" id="test-datepicker">').appendTo(
193-
"body"
193+
"body",
194194
);
195195

196196
// Initialize with options that set minDate and maxDate
@@ -239,7 +239,9 @@ describe("invalid methods", function () {
239239
it("should error on non-existing method", function () {
240240
expect(function () {
241241
$input.multiDatesPicker("happyNewYear");
242-
}).toThrowError("Method happyNewYear does not exist on jQuery.multiDatesPicker");
242+
}).toThrowError(
243+
"Method happyNewYear does not exist on jQuery.multiDatesPicker",
244+
);
243245
});
244246
});
245247

@@ -562,7 +564,7 @@ describe("gotDate", function () {
562564
$input.multiDatesPicker(
563565
"addDates",
564566
["10/11/2024", "10/13/2024"],
565-
"disabled"
567+
"disabled",
566568
);
567569
});
568570

@@ -668,7 +670,7 @@ describe("getDates", function () {
668670
$input.multiDatesPicker(
669671
"addDates",
670672
["10/11/2024", "10/13/2024"],
671-
"disabled"
673+
"disabled",
672674
);
673675
});
674676

@@ -681,7 +683,7 @@ describe("getDates", function () {
681683
const disabledDates = $input.multiDatesPicker(
682684
"getDates",
683685
"string",
684-
"disabled"
686+
"disabled",
685687
);
686688
expect(disabledDates).toEqual(["10/11/2024", "10/13/2024"]);
687689
});
@@ -699,7 +701,7 @@ describe("getDates", function () {
699701
const disabledDates = $input.multiDatesPicker(
700702
"getDates",
701703
"object",
702-
"disabled"
704+
"disabled",
703705
);
704706
expect(disabledDates).toEqual([
705707
new Date("10/11/2024"),
@@ -720,7 +722,7 @@ describe("getDates", function () {
720722
const disabledDates = $input.multiDatesPicker(
721723
"getDates",
722724
"number",
723-
"disabled"
725+
"disabled",
724726
);
725727
expect(disabledDates).toEqual([
726728
Date.parse("10/11/2024"),

bower.json

+5-21
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,12 @@
22
"name": "jquery-ui-multidatespicker",
33
"description": "Extension to the jQuery UI Calendar allowing multiple selections",
44
"license": "(MIT OR GPLv2)",
5-
"authors": [
6-
"Luca Lauretta <[email protected]>"
7-
],
8-
"main": [
9-
"jquery-ui.multidatespicker.js",
10-
"jquery-ui.multidatespicker.css"
11-
],
5+
"authors": ["Luca Lauretta <[email protected]>"],
6+
"main": ["jquery-ui.multidatespicker.js", "jquery-ui.multidatespicker.css"],
127
"dependencies": {
138
"jquery": "1.9.1 - 3.7.x",
149
"jquery-ui": "1.7.0 - 1.14.x"
1510
},
16-
"keywords": [
17-
"jquery",
18-
"jquery-ui",
19-
"calendar",
20-
"dates"
21-
],
22-
"ignore": [
23-
"**/.*",
24-
"*.ico",
25-
"*.png",
26-
"package.json",
27-
"index.html"
28-
]
29-
}
11+
"keywords": ["jquery", "jquery-ui", "calendar", "dates"],
12+
"ignore": ["**/.*", "*.ico", "*.png", "package.json", "index.html"]
13+
}

eslint.config.mjs

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import globals from "globals";
2+
import pluginJs from "@eslint/js";
3+
import eslintConfigPrettier from "eslint-config-prettier";
4+
5+
/** @type {import('eslint').Linter.Config[]} */
6+
export default [
7+
{ languageOptions: { globals: globals.browser } },
8+
eslintConfigPrettier,
9+
pluginJs.configs.recommended,
10+
{
11+
rules: {
12+
"no-fallthrough": "off",
13+
"no-undef": "warn",
14+
"no-unused-vars": "warn",
15+
},
16+
},
17+
];

0 commit comments

Comments
 (0)