Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 3 additions & 12 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module.exports = {
'plugin:react/recommended',
'airbnb',
'plugin:i18next/recommended',
'plugin:prettier/recommended',
],
parser: '@typescript-eslint/parser',
parserOptions: {
Expand All @@ -17,20 +18,12 @@ module.exports = {
ecmaVersion: 'latest',
sourceType: 'module',
},
plugins: [
'react',
'@typescript-eslint',
'i18next',
'react-hooks',
],
plugins: ['react', '@typescript-eslint', 'i18next', 'react-hooks'],
rules: {
'react/jsx-indent': [1, 2],
'react/jsx-indent-props': [1, 2],
indent: [1, 2],
'react/jsx-filename-extension': [
2,
{ extensions: ['.js', '.jsx', '.tsx'] },
],
'react/jsx-filename-extension': [2, { extensions: ['.js', '.jsx', '.tsx'] }],
'import/no-unresolved': 'off',
'import/prefer-default-export': 'off',
'no-unused-vars': 'warn',
Expand All @@ -49,7 +42,6 @@ module.exports = {
ignoreAttribute: ['data-testid', 'to'],
},
],
'max-len': ['error', { ignoreComments: true, code: 100 }],
'jsx-a11y/no-static-element-interactions': 'off',
'jsx-a11y/click-events-have-key-events': 'off',
'react-hooks/rules-of-hooks': 'error',
Expand All @@ -65,7 +57,6 @@ module.exports = {
files: ['**/src/**/*.{test,stories}.{ts,tsx}'],
rules: {
'i18next/no-literal-string': 'off',
'max-len': 'off',
},
},
],
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ node_modules
/storybook-static
.loki/report.html
.loki/report.json
.vscode
.cursor
7 changes: 7 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules
build
dist
storybook-static
.loki
package-lock.json
yarn.lock
10 changes: 10 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = {
printWidth: 100,
tabWidth: 2,
useTabs: false,
semi: true,
singleQuote: true,
trailingComma: 'all',
bracketSpacing: true,
arrowParens: 'always',
};
8 changes: 4 additions & 4 deletions .stylelintrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"extends": "stylelint-config-standard-scss",
"rules": {
"selector-class-pattern": null
}
"extends": "stylelint-config-standard-scss",
"rules": {
"selector-class-pattern": null
}
}
24 changes: 11 additions & 13 deletions babel.config.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
{
"presets": [
"@babel/preset-env",
"@babel/preset-typescript",
[
"@babel/preset-react",
{
"runtime": "automatic"
}
]
],
"plugins": [
"i18next-extract"
]
"presets": [
"@babel/preset-env",
"@babel/preset-typescript",
[
"@babel/preset-react",
{
"runtime": "automatic"
}
]
],
"plugins": ["i18next-extract"]
}
21 changes: 4 additions & 17 deletions config/jest/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,10 @@ import path from 'path';
export default {
clearMocks: true,
testEnvironment: 'jsdom',
coveragePathIgnorePatterns: [
'\\\\node_modules\\\\',
],
moduleFileExtensions: [
'js',
'jsx',
'ts',
'tsx',
'json',
'node',
],
moduleDirectories: [
'node_modules',
],
modulePaths: [
'<rootDir>src',
],
coveragePathIgnorePatterns: ['\\\\node_modules\\\\'],
moduleFileExtensions: ['js', 'jsx', 'ts', 'tsx', 'json', 'node'],
moduleDirectories: ['node_modules'],
modulePaths: ['<rootDir>src'],
testMatch: [
// Обнаружил разницу между МАК ОС и ВИНДОУС!!!
'<rootDir>src/**/*(*.)@(spec|test).[tj]s?(x)',
Expand Down
22 changes: 10 additions & 12 deletions config/storybook/main.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
module.exports = {
stories: [
'../../src/**/*.stories.@(js|jsx|ts|tsx)',
],
addons: [
'@storybook/addon-links',
'@storybook/addon-essentials',
'@storybook/addon-interactions',
],
framework: '@storybook/react',
core: {
builder: 'webpack5',
},
stories: ['../../src/**/*.stories.@(js|jsx|ts|tsx)'],
addons: [
'@storybook/addon-links',
'@storybook/addon-essentials',
'@storybook/addon-interactions',
],
framework: '@storybook/react',
core: {
builder: 'webpack5',
},
};
14 changes: 7 additions & 7 deletions config/storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import { Theme } from '../../src/app/providers/ThemeProvider';
import { RouterDecorator } from '../../src/shared/config/storybook/RouterDecorator/RouterDecorator';

export const parameters = {
actions: { argTypesRegex: '^on[A-Z].*' },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
},
actions: { argTypesRegex: '^on[A-Z].*' },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
},
};

addDecorator(StyleDecorator);
Expand Down
2 changes: 1 addition & 1 deletion config/storybook/webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import path from 'path';
import { buildCssLoader } from '../build/loaders/buildCssLoader';
import { BuildPaths } from '../build/types/config';

export default ({ config }: {config: webpack.Configuration}) => {
export default ({ config }: { config: webpack.Configuration }) => {
const paths: BuildPaths = {
build: '',
html: '',
Expand Down
1 change: 1 addition & 0 deletions extractedTranslations/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"Войти": "Войти",
"Главная": "Главная",
"Главная страница": "Главная страница",
"Короткий язык": "Короткий язык",
"О сайте": "О сайте",
"О сайте123123": "О сайте123123",
"Обновить страницу": "Обновить страницу",
Expand Down
1 change: 1 addition & 0 deletions extractedTranslations/ru/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"Войти": "Войти",
"Главная": "Главная",
"Главная страница": "Главная страница",
"Короткий язык": "Короткий язык",
"О сайте": "О сайте",
"О сайте123123": "О сайте123123",
"Обновить страницу": "Обновить страницу",
Expand Down
16 changes: 5 additions & 11 deletions json-server/db.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
{
"posts": [
{"id": 1, "title": "json-server", "author": "typicode"}
],
"comments": [
{"id": 1, "body": "some comment", "postId": 1}
],
"users": [
{"id": 1, "username": "admin", "password": "123"}
],
"profile": { "name": "typicode" }
}
"posts": [{ "id": 1, "title": "json-server", "author": "typicode" }],
"comments": [{ "id": 1, "body": "some comment", "postId": 1 }],
"users": [{ "id": 1, "username": "admin", "password": "123" }],
"profile": { "name": "typicode" }
}
54 changes: 27 additions & 27 deletions json-server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,47 +12,47 @@ server.use(jsonServer.bodyParser);

// Нужно для небольшой задержки, чтобы запрос проходил не мгновенно, имитация реального апи
server.use(async (req, res, next) => {
await new Promise((res) => {
setTimeout(res, 800);
});
next();
await new Promise((res) => {
setTimeout(res, 800);
});
next();
});

// Эндпоинт для логина
server.post('/login', (req, res) => {
try {
const { username, password } = req.body;
const db = JSON.parse(fs.readFileSync(path.resolve(__dirname, 'db.json'), 'UTF-8'));
const { users = [] } = db;

const userFromBd = users.find(
(user) => user.username === username && user.password === password,
);

if (userFromBd) {
return res.json(userFromBd);
}

return res.status(403).json({ message: 'User not found' });
} catch (e) {
console.log(e);
return res.status(500).json({ message: e.message });
}
try {
const { username, password } = req.body;
const db = JSON.parse(fs.readFileSync(path.resolve(__dirname, 'db.json'), 'UTF-8'));
const { users = [] } = db;

const userFromBd = users.find(
(user) => user.username === username && user.password === password,
);

if (userFromBd) {
return res.json(userFromBd);
}

return res.status(403).json({ message: 'User not found' });
} catch (e) {
console.log(e);
return res.status(500).json({ message: e.message });
}
});

// проверяем, авторизован ли пользователь
// eslint-disable-next-line
server.use((req, res, next) => {
if (!req.headers.authorization) {
return res.status(403).json({ message: 'AUTH ERROR' });
}
if (!req.headers.authorization) {
return res.status(403).json({ message: 'AUTH ERROR' });
}

next();
next();
});

server.use(router);

// запуск сервера
server.listen(8000, () => {
console.log('server is running on 8000 port');
console.log('server is running on 8000 port');
});
Loading