Skip to content

Commit 3053e23

Browse files
committed
add globals and format code with linter
1 parent b9b321c commit 3053e23

File tree

6 files changed

+103
-60
lines changed

6 files changed

+103
-60
lines changed

package-lock.json

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"devDependencies": {
1111
"@eslint/js": "^9.24.0",
1212
"eslint": "^9.24.0",
13+
"globals": "^16.1.0",
1314
"sass": "^1.87.0",
1415
"vite": "^6.3.5"
1516
},

src/index.html

Lines changed: 71 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,46 @@
66
<title>Bootstrap w/ Vite</title>
77
<link
88
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
9-
rel="stylesheet">
9+
rel="stylesheet"
10+
/>
1011
</head>
1112

1213
<body class="d-flex flex-column min-vh-100">
13-
<div class="modal fade" id="modal" tabindex="-1" role="dialog"
14-
aria-labelledby="modal" aria-hidden="true">
14+
<div
15+
class="modal fade"
16+
id="modal"
17+
tabindex="-1"
18+
role="dialog"
19+
aria-labelledby="modal"
20+
aria-hidden="true"
21+
>
1522
<div class="modal-dialog" role="document">
1623
<div class="modal-content">
1724
<div class="modal-header">
18-
<h5 class="modal-title"></h5><button type="button"
19-
class="btn-close close" data-bs-dismiss="modal"
20-
aria-label="Close"></button>
25+
<h5 class="modal-title"></h5>
26+
<button
27+
type="button"
28+
class="btn-close close"
29+
data-bs-dismiss="modal"
30+
aria-label="Close"
31+
></button>
2132
</div>
2233
<div class="modal-body text-break"></div>
23-
<div class="modal-footer"><a class="btn btn-primary full-article"
24-
href="#" role="button" target="_blank"
25-
rel="noopener noreferrer">Читать полностью </a><button type="button"
26-
class="btn btn-secondary" data-bs-dismiss="modal">Закрыть</button>
34+
<div class="modal-footer">
35+
<a
36+
class="btn btn-primary full-article"
37+
href="#"
38+
role="button"
39+
target="_blank"
40+
rel="noopener noreferrer"
41+
>Читать полностью </a
42+
><button
43+
type="button"
44+
class="btn btn-secondary"
45+
data-bs-dismiss="modal"
46+
>
47+
Закрыть
48+
</button>
2749
</div>
2850
</div>
2951
</div>
@@ -33,42 +55,67 @@ <h5 class="modal-title"></h5><button type="button"
3355
<div class="row">
3456
<div class="col-md-10 col-lg-8 mx-auto text-white">
3557
<h1 class="display-3 mb-0">RSS агрегатор</h1>
36-
<p class="lead">Начните читать RSS сегодня! Это легко, это красиво.
58+
<p class="lead">
59+
Начните читать RSS сегодня! Это легко, это красиво.
3760
</p>
3861
<form action="" id="rss-form" class="rss-form text-body">
3962
<div class="row">
4063
<div class="col">
41-
<div class="form-floating"><input id="url-input" autofocus=""
42-
required="" name="url" aria-label="url"
43-
class="form-control w-100" placeholder="ссылка RSS"
44-
autocomplete="off"> <label for="url-input">Ссылка
45-
RSS</label></div>
64+
<div class="form-floating">
65+
<input
66+
id="url-input"
67+
autofocus=""
68+
required=""
69+
name="url"
70+
aria-label="url"
71+
class="form-control w-100"
72+
placeholder="ссылка RSS"
73+
autocomplete="off"
74+
/>
75+
<label for="url-input">Ссылка RSS</label>
76+
</div>
4677
</div>
47-
<div class="col-auto"><button id="add-feed-btn" type="submit" aria-label="add"
48-
class="h-100 btn btn-lg btn-primary px-sm-5">Добавить</button>
78+
<div class="col-auto">
79+
<button
80+
id="add-feed-btn"
81+
type="submit"
82+
aria-label="add"
83+
class="h-100 btn btn-lg btn-primary px-sm-5"
84+
>
85+
Добавить
86+
</button>
4987
</div>
5088
</div>
5189
</form>
52-
<p class="mt-2 mb-0 text-muted">Пример:
53-
https://lorem-rss.hexlet.app/feed</p>
90+
<p class="mt-2 mb-0 text-muted">
91+
Пример: https://lorem-rss.hexlet.app/feed
92+
</p>
5493
<p class="feedback m-0 position-absolute small text-danger"></p>
5594
</div>
5695
</div>
5796
</section>
5897
<section class="container-fluid container-xxl p-5">
5998
<div class="row">
6099
<div class="col-md-10 col-lg-8 order-1 mx-auto posts"></div>
61-
<div class="col-md-10 col-lg-4 mx-auto order-0 order-lg-1 feeds"></div>
100+
<div
101+
class="col-md-10 col-lg-4 mx-auto order-0 order-lg-1 feeds"
102+
></div>
62103
</div>
63104
</section>
64105
</main>
65106
<footer class="footer border-top py-3 mt-5 bg-light">
66107
<div class="container-xl">
67-
<div class="text-center">created by <a
108+
<div class="text-center">
109+
created by
110+
<a
68111
href="https://ru.hexlet.io/professions/frontend/projects/11"
69-
target="_blank">Hexlet</a></div>
112+
target="_blank"
113+
>Hexlet</a
114+
>
115+
</div>
70116
</div>
71-
</footer><deepl-input-controller translate="no"></deepl-input-controller>
117+
</footer>
118+
<deepl-input-controller translate="no"></deepl-input-controller>
72119
<script type="module" src="./js/main.js"></script>
73120
</body>
74121
</html>

src/js/main.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,15 @@ import { updateInputValue, addRssFeed, validateInput } from "./model";
33
const input = document.querySelector("#url-input");
44
const form = document.querySelector("#rss-form");
55

6-
input.addEventListener('input', (e) => {
6+
input.addEventListener("input", (e) => {
77
updateInputValue(e.target.value);
88
});
99

10-
form.addEventListener('submit', (e) => {
10+
form.addEventListener("submit", (e) => {
1111
e.preventDefault();
1212
validateInput()
1313
.then(() => {
1414
addRssFeed();
1515
})
16-
.catch(() => console.log('валидация не пройдена'));
16+
.catch(() => console.log("валидация не пройдена"));
1717
});
18-
19-
20-
21-
22-
23-

src/js/model.js

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import onChange from "on-change";
2-
import * as yup from 'yup';
2+
import * as yup from "yup";
33

4-
import { renderErrors, renderInputValue } from './view.js';
4+
import { renderErrors, renderInputValue } from "./view.js";
55

66
const object = {
7-
inputValue: '',
7+
inputValue: "",
88
rssFeed: [],
9-
errors: null
9+
errors: null,
1010
};
1111

1212
const state = onChange(object, (path, value) => {
@@ -25,11 +25,16 @@ const state = onChange(object, (path, value) => {
2525
const schema = yup
2626
.string()
2727
.url()
28-
.required('Обязательное поле')
29-
.test('no-duplicate', 'Эта лента уже добавлена', (value) => !state.rssFeed.includes(value));
28+
.required("Обязательное поле")
29+
.test(
30+
"no-duplicate",
31+
"Эта лента уже добавлена",
32+
(value) => !state.rssFeed.includes(value),
33+
);
3034

3135
export const validateInput = () => {
32-
return schema.validate(state.inputValue, { abortEarly: false })
36+
return schema
37+
.validate(state.inputValue, { abortEarly: false })
3338
.then(() => {
3439
state.errors = null;
3540
})
@@ -50,21 +55,3 @@ export const addRssFeed = () => {
5055
state.rssFeed = [...state.rssFeed, state.inputValue];
5156
console.log("обновлён список rss", state.rssFeed);
5257
};
53-
54-
55-
56-
57-
58-
59-
60-
61-
62-
63-
64-
65-
66-
67-
68-
69-
70-

src/js/view.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const input = document.querySelector('#url-input');
2-
const feedback = document.querySelector('.feedback');
1+
const input = document.querySelector("#url-input");
2+
const feedback = document.querySelector(".feedback");
33

44
export const renderErrors = (errors) => {
55
if (errors && errors.length > 0) {

0 commit comments

Comments
 (0)