Skip to content

Commit

Permalink
feat: add prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
sashtje committed Oct 4, 2023
1 parent 4eb2007 commit 2137d81
Show file tree
Hide file tree
Showing 236 changed files with 2,401 additions and 2,090 deletions.
122 changes: 76 additions & 46 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ module.exports = {
es2021: true,
jest: true,
},
extends: ['plugin:react/recommended', 'airbnb', 'plugin:i18next/recommended'],
extends: [
'plugin:react/recommended',
'airbnb',
'plugin:i18next/recommended',
'plugin:storybook/recommended',
'prettier',
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaFeatures: {
Expand All @@ -23,11 +29,12 @@ module.exports = {
'eslint-plugin-import',
],
rules: {
indent: [2, 2],
'react/jsx-indent': [2, 2],
'react/jsx-filename-extension': [2, {
extensions: ['.jsx', '.tsx'],
}],
'react/jsx-filename-extension': [
2,
{
extensions: ['.jsx', '.tsx'],
},
],
'import/no-unresolved': 'off',
'import/prefer-default-export': 'off',
'react/react-in-jsx-scope': 'off',
Expand All @@ -39,18 +46,26 @@ module.exports = {
'import/extensions': 'off',
'import/no-extraneous-dependencies': 'warn',
'no-underscore-dangle': 'off',
'i18next/no-literal-string': ['error', {
markupOnly: true,
ignoreAttribute: [
'data-testid', 'to', 'target', 'direction',
'justify', 'align', 'gap', 'role', 'as',
'borderRadius', 'height', 'width',
],
}],
'max-len': ['error', {
ignoreComments: true,
code: 120,
}],
'i18next/no-literal-string': [
'error',
{
markupOnly: true,
ignoreAttribute: [
'data-testid',
'to',
'target',
'direction',
'justify',
'align',
'gap',
'role',
'as',
'borderRadius',
'height',
'width',
],
},
],
'linebreak-style': 'off',
'jsx-a11y/no-static-element-interactions': 'off',
'jsx-a11y/click-events-have-key-events': 'off',
Expand All @@ -60,40 +75,55 @@ module.exports = {
'no-undef': 'off',
'react/no-array-index-key': 'off',
// I am using this plugin with npm link to test it
// 'fsd-checker/path-checker': ['error', {
// alias: '@',
// }],
// 'fsd-checker/public-api-imports': ['error', {
// alias: '@',
// testFiles: ['**/*.test.*', '**/StoreDecorator.tsx', '**/*.stories.tsx'],
// }],
// 'fsd-checker/layer-imports': ['error', {
// alias: '@',
// ignoreImport: ['**/StoreProvider', '**/testing'],
// }],
// 'fsd-checker/path-checker': [
// 'error',
// {
// alias: '@',
// },
// ],
// 'fsd-checker/public-api-imports': [
// 'error',
// {
// alias: '@',
// testFiles: ['**/*.test.*', '**/StoreDecorator.tsx', '**/*.stories.tsx'],
// },
// ],
// 'fsd-checker/layer-imports': [
// 'error',
// {
// alias: '@',
// ignoreImport: ['**/StoreProvider', '**/testing'],
// },
// ],
'unused-imports/no-unused-imports': 'error',
'import/order': ['error', {
groups: ['builtin', 'external', 'internal'],
pathGroups: [
{
pattern: '@/**',
group: 'external',
position: 'after',
},
],
'newlines-between': 'always',
}],
'import/order': [
'error',
{
groups: ['builtin', 'external', 'internal'],
pathGroups: [
{
pattern: '@/**',
group: 'external',
position: 'after',
},
],
'newlines-between': 'always',
},
],
'react/jsx-max-props-per-line': ['error', { maximum: 4 }],
},
globals: {
__IS_DEV__: true,
__API__: true,
__PROJECT__: true,
},
overrides: [{
files: ['**/src/**/*.{test,stories}.{ts,tsx}'],
rules: {
'i18next/no-literal-string': 'off',
'max-len': 'off',
overrides: [
{
files: ['**/src/**/*.{test,stories}.{ts,tsx}'],
rules: {
'i18next/no-literal-string': 'off',
'max-len': 'off',
},
},
}],
],
};
9 changes: 9 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Ignore artifacts:
build
coverage
node_modules
*.html
*.css
*.scss
package.json
package-lock.json
10 changes: 10 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"tabWidth": 2,
"semi": true,
"singleQuote": true,
"trailingComma": "all",
"bracketSpacing": true,
"bracketSameLine": false,
"arrowParens": "always",
"printWidth": 80
}
2 changes: 1 addition & 1 deletion .stylelintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
"rules": {
"selector-class-pattern": null
}
}
}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ npm run start:dev or npm run start:dev:vite - to launch client and backend part
- `npm run start:dev:server` - Running a backend server
- `npm run build:prod` - Build in prod mode
- `npm run build:dev` - Build in dev mode (without minimization)
- `npm run prettier` - Running prettier on .ts and .tsx files
- `npm run lint:ts` - Running eslint on .ts and .tsx files
- `npm run lint:ts:fix` - Running eslint fix on .ts and .tsx files
- `npm run lint:scss` - Running stylelint on style files
Expand Down
14 changes: 10 additions & 4 deletions babel.config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
{
"presets": ["@babel/preset-env", "@babel/preset-typescript",
["@babel/preset-react", {
"runtime": "automatic"
}]]
"presets": [
"@babel/preset-env",
"@babel/preset-typescript",
[
"@babel/preset-react",
{
"runtime": "automatic"
}
]
]
}
28 changes: 7 additions & 21 deletions config/jest/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,11 @@ export default {
},
clearMocks: true,
testEnvironment: 'jsdom',
coveragePathIgnorePatterns: [
'\\\\node_modules\\\\',
],
moduleDirectories: [
'node_modules',
],
modulePaths: [
'<rootDir>src',
],
moduleFileExtensions: [
'js',
'jsx',
'ts',
'tsx',
'json',
'node',
],
testMatch: [
'<rootDir>src/**/*(*.)@(spec|test).[tj]s?(x)',
],
coveragePathIgnorePatterns: ['\\\\node_modules\\\\'],
moduleDirectories: ['node_modules'],
modulePaths: ['<rootDir>src'],
moduleFileExtensions: ['js', 'jsx', 'ts', 'tsx', 'json', 'node'],
testMatch: ['<rootDir>src/**/*(*.)@(spec|test).[tj]s?(x)'],
rootDir: '../../',
setupFilesAfterEnv: ['<rootDir>config/jest/setupTests.ts'],
moduleNameMapper: {
Expand All @@ -38,7 +23,8 @@ export default {
reporters: [
'default',
[
'jest-html-reporters', {
'jest-html-reporters',
{
publicPath: '<rootDir>/reports/unit',
filename: 'report.html',
// openReport: true,
Expand Down
16 changes: 8 additions & 8 deletions config/storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ import { buildCssLoader } from '../build/loaders/buildCssLoader';
import { BuildPaths } from '../build/types/config';

export default {
stories: [
'../../src/**/*.stories.@(js|jsx|ts|tsx)',
],
stories: ['../../src/**/*.stories.@(js|jsx|ts|tsx)'],

addons: [
'@storybook/addon-links',
Expand Down Expand Up @@ -58,11 +56,13 @@ export default {
});
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'),
}));
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;
Expand Down
11 changes: 6 additions & 5 deletions cypress/component/EditableProfileCard.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ describe('EditableProfileCard.cy.tsx', () => {
cy.intercept('GET', '**/profile/*', { fixture: 'profile.json' });

cy.mount(
<TestProvider options={{
initialState: {
user: { authData: { id: USER_ID } },
},
}}
<TestProvider
options={{
initialState: {
user: { authData: { id: USER_ID } },
},
}}
>
<EditableProfileCard id={USER_ID} />
</TestProvider>,
Expand Down
4 changes: 1 addition & 3 deletions cypress/fixtures/article-details.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
"views": 3005,
"createdAt": "04.09.2023",
"userId": "2",
"type": [
"IT"
],
"type": ["IT"],
"blocks": [
{
"id": "1",
Expand Down
Loading

0 comments on commit 2137d81

Please sign in to comment.