Skip to content

Commit

Permalink
feat: add prettier for formatting code
Browse files Browse the repository at this point in the history
  • Loading branch information
TomatoVan committed Apr 2, 2024
1 parent f115f56 commit 3d86890
Show file tree
Hide file tree
Showing 278 changed files with 42,666 additions and 42,229 deletions.
13 changes: 8 additions & 5 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ module.exports = {
extends: [
'plugin:react/recommended',
'airbnb',
'plugin:storybook/recommended',
'prettier',
],
parser: '@typescript-eslint/parser',
parserOptions: {
Expand All @@ -25,10 +27,7 @@ module.exports = {
'unused-imports',
],
rules: {
'react/jsx-indent': [2, 4],
'react/jsx-indent-props': [2, 4],
'unused-imports/no-unused-imports': 'error',
indent: [2, 4],
'react/jsx-filename-extension': [
2,
{ extensions: ['.js', '.jsx', '.tsx'] },
Expand Down Expand Up @@ -66,9 +65,14 @@ module.exports = {
'error',
{
alias: '@',
testFilesPatterns: ['**/*.test.*', '**/*.story.*', '**/StoreDecorator.tsx'],
testFilesPatterns: [
'**/*.test.*',
'**/*.story.*',
'**/StoreDecorator.tsx',
],
},
],
'react/jsx-max-props-per-line': ['error', { maximum: 3 }],
},
globals: {
__IS_DEV__: true,
Expand All @@ -84,5 +88,4 @@ module.exports = {
},
},
],

};
9 changes: 9 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"tabWidth": 4,
"semi": true,
"singleQuote": true,
"trailingComma": "all",
"bracketSpacing": true,
"bracketSameLine": false,
"arrowParens": "always"
}
10 changes: 5 additions & 5 deletions .stylelintrc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"extends": "stylelint-config-standard-scss",
"rules": {
"indentation": [4],
"selector-class-pattern": null
}
"extends": "stylelint-config-standard-scss",
"rules": {
"indentation": [4],
"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"]
}
37 changes: 13 additions & 24 deletions config/jest/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,10 @@ 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 All @@ -40,16 +27,18 @@ export default {
'\\.s?css$': 'identity-obj-proxy',
'\\.svg': path.resolve(__dirname, 'jestEmptyComponent.tsx'),
'^@/(.*)$': '<rootDir>/src/$1',

},
reporters: [
'default',
['jest-html-reporters', {
publicPath: '<rootDir>/reports/unit',
filename: 'report.html',
// openReport: true,
inlineSource: true,
}],
[
'jest-html-reporters',
{
publicPath: '<rootDir>/reports/unit',
filename: 'report.html',
// openReport: true,
inlineSource: true,
},
],
],

// Indicates whether the coverage information should be collected while executing the test
Expand Down
60 changes: 30 additions & 30 deletions config/storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import { buildCssLoader } from '../build/loaders/buildCssLoader';
/* eslint-disable no-mixed-spaces-and-tabs */

export default {
stories: [
'../../src/**/*.stories.@(js|jsx|ts|tsx)',
],
stories: ['../../src/**/*.stories.@(js|jsx|ts|tsx)'],
addons: [
'@storybook/addon-links',
{
Expand All @@ -32,36 +30,38 @@ export default {
locales: '',
buildLocales: '',
};
config!.resolve!.modules!.push(paths.src);
config!.resolve!.extensions!.push('.ts', '.tsx');
config!.resolve!.alias = {
...config!.resolve!.alias,
'@': paths.src,
};
config!.resolve!.modules!.push(paths.src);
config!.resolve!.extensions!.push('.ts', '.tsx');
config!.resolve!.alias = {
...config!.resolve!.alias,
'@': paths.src,
};

// @ts-ignore
config!.module!.rules = config!.module!.rules!.map((rule: RuleSetRule) => {
if (/svg/.test(rule.test as string)) {
return { ...rule, exclude: /\.svg$/i };
}
// @ts-ignore
config!.module!.rules = config!.module!.rules!.map(
(rule: RuleSetRule) => {
if (/svg/.test(rule.test as string)) {
return { ...rule, exclude: /\.svg$/i };
}

return rule;
});
return rule;
},
);

config!.module!.rules.push({
test: /\.svg$/,
use: ['@svgr/webpack'],
});
config!.module!.rules.push(buildCssLoader(true));
config!.module!.rules.push({
test: /\.svg$/,
use: ['@svgr/webpack'],
});
config!.module!.rules.push(buildCssLoader(true));

config!.plugins!.push(
new DefinePlugin({
__IS_DEV__: JSON.stringify(true),
__API__: JSON.stringify('https://testapi.ru'),
__PROJECT__: JSON.stringify('storybook'),
}),
);
// Return the altered config
return config;
config!.plugins!.push(
new DefinePlugin({
__IS_DEV__: JSON.stringify(true),
__API__: JSON.stringify('https://testapi.ru'),
__PROJECT__: JSON.stringify('storybook'),
}),
);
// Return the altered config
return config;
},
};
4 changes: 3 additions & 1 deletion cypress/e2e/articles/article-details.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ describe('to article details page', () => {
cy.getByTestId('CommentCard.Content').should('have.length', 1);
});
it('article details rating (fixtures)', () => {
cy.intercept('GET', '**/articles/*', { fixture: 'article-details.json' });
cy.intercept('GET', '**/articles/*', {
fixture: 'article-details.json',
});
cy.getByTestId('ArticlesDetails.Info');
cy.getByTestId('RatingCard').scrollIntoView();
cy.setRate(3, 'feedback test');
Expand Down
5 changes: 4 additions & 1 deletion cypress/e2e/profile/profile-edit.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ describe('to profile page', () => {
const newLastname = 'newLastname';
cy.updateProfile(newName, newLastname);
cy.getByTestId('ProfileCard.firstname').should('have.value', newName);
cy.getByTestId('ProfileCard.lastname').should('have.value', newLastname);
cy.getByTestId('ProfileCard.lastname').should(
'have.value',
newLastname,
);
});
});
56 changes: 26 additions & 30 deletions cypress/fixtures/article-details.json
Original file line number Diff line number Diff line change
@@ -1,33 +1,29 @@
{
"id": "7",
"title": "Ruby news",
"subtitle": "Что нового в JS за 2022 год?",
"img": "https://res.cloudinary.com/practicaldev/image/fetch/s--oqV3akcU--/c_imagga_scale,f_auto,fl_progressive,h_500,q_auto,w_1000/https://dev-to-uploads.s3.amazonaws.com/i/pgnw91fs7tpxn0wyeqh2.jpg",
"views": 100,
"createdAt": "21.02.2022",
"userId": "1",
"type": [
"IT"
],
"blocks": [
{
"id": "1",
"type": "TEXT",
"title": "Заголовок этого блока",
"paragraphs": [
"Программа, которую по традиции называют «Hello, world!», очень проста. Она выводит куда-либо фразу «Hello, world!», или другую подобную, средствами некоего языка.",
"JavaScript — это язык, программы на котором можно выполнять в разных средах. В нашем случае речь идёт о браузерах и о серверной платформе Node.js. Если до сих пор вы не написали ни строчки кода на JS и читаете этот текст в браузере, на настольном компьютере, это значит, что вы буквально в считанных секундах от своей первой JavaScript-программы.",
"Существуют и другие способы запуска JS-кода в браузере. Так, если говорить об обычном использовании программ на JavaScript, они загружаются в браузер для обеспечения работы веб-страниц. Как правило, код оформляют в виде отдельных файлов с расширением .js, которые подключают к веб-страницам, но программный код можно включать и непосредственно в код страницы. Всё это делается с помощью тега <script>. Когда браузер обнаруживает такой код, он выполняет его. Подробности о теге script можно посмотреть на сайте w3school.com. В частности, рассмотрим пример, демонстрирующий работу с веб-страницей средствами JavaScript, приведённый на этом ресурсе. Этот пример можно запустить и средствами данного ресурса (ищите кнопку Try it Yourself), но мы поступим немного иначе. А именно, создадим в каком-нибудь текстовом редакторе (например — в VS Code или в Notepad++) новый файл, который назовём hello.html, и добавим в него следующий код:"
]
}
],
"user": {
"id": "1",
"username": "admin",
"password": "123",
"roles": [
"ADMIN"
"id": "7",
"title": "Ruby news",
"subtitle": "Что нового в JS за 2022 год?",
"img": "https://res.cloudinary.com/practicaldev/image/fetch/s--oqV3akcU--/c_imagga_scale,f_auto,fl_progressive,h_500,q_auto,w_1000/https://dev-to-uploads.s3.amazonaws.com/i/pgnw91fs7tpxn0wyeqh2.jpg",
"views": 100,
"createdAt": "21.02.2022",
"userId": "1",
"type": ["IT"],
"blocks": [
{
"id": "1",
"type": "TEXT",
"title": "Заголовок этого блока",
"paragraphs": [
"Программа, которую по традиции называют «Hello, world!», очень проста. Она выводит куда-либо фразу «Hello, world!», или другую подобную, средствами некоего языка.",
"JavaScript — это язык, программы на котором можно выполнять в разных средах. В нашем случае речь идёт о браузерах и о серверной платформе Node.js. Если до сих пор вы не написали ни строчки кода на JS и читаете этот текст в браузере, на настольном компьютере, это значит, что вы буквально в считанных секундах от своей первой JavaScript-программы.",
"Существуют и другие способы запуска JS-кода в браузере. Так, если говорить об обычном использовании программ на JavaScript, они загружаются в браузер для обеспечения работы веб-страниц. Как правило, код оформляют в виде отдельных файлов с расширением .js, которые подключают к веб-страницам, но программный код можно включать и непосредственно в код страницы. Всё это делается с помощью тега <script>. Когда браузер обнаруживает такой код, он выполняет его. Подробности о теге script можно посмотреть на сайте w3school.com. В частности, рассмотрим пример, демонстрирующий работу с веб-страницей средствами JavaScript, приведённый на этом ресурсе. Этот пример можно запустить и средствами данного ресурса (ищите кнопку Try it Yourself), но мы поступим немного иначе. А именно, создадим в каком-нибудь текстовом редакторе (например — в VS Code или в Notepad++) новый файл, который назовём hello.html, и добавим в него следующий код:"
]
}
],
"avatar": "https://yakutsk.ru/wp-content/uploads/2022/07/12/bystrov_haker.jpeg"
}
"user": {
"id": "1",
"username": "admin",
"password": "123",
"roles": ["ADMIN"],
"avatar": "https://yakutsk.ru/wp-content/uploads/2022/07/12/bystrov_haker.jpeg"
}
}
Loading

0 comments on commit 3d86890

Please sign in to comment.