Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to Prettier 3 #7654

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"hermes-eslint": "^0.21.1",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"prettier": "^2.8.8",
"prettier": "^3.3.0",
"prettier-plugin-hermes-parser": "^0.20.1",
"typescript": "^5.4.5"
},
"packageManager": "yarn@4.2.2"
Expand Down
9 changes: 9 additions & 0 deletions prettier.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,13 @@ module.exports = {
tabWidth: 2,
trailingComma: 'all',
quoteProps: 'consistent',
plugins: ['prettier-plugin-hermes-parser'],
overrides: [
{
files: ['*.js', '*.jsx', '*.flow'],
options: {
parser: 'hermes',
},
},
],
};
4 changes: 3 additions & 1 deletion src/abacus-backoffice/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

const path = require('path');

const setupFilesAfterEnv /*: string */ = path.join(__dirname, 'jest-setup.js');

module.exports = {
rootDir: __dirname,
setupFilesAfterEnv: [(path.join(__dirname, 'jest-setup.js') /*: string */)],
setupFilesAfterEnv: [setupFilesAfterEnv],
};
6 changes: 4 additions & 2 deletions src/abacus-backoffice/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const { key: cspKey, value: cspValue } = createContentSecurityPolicy({
reportOnly: true,
});

module.exports = (withPlugins(
const NextConfig /*: $FlowFixMe */ = withPlugins(
[
[withCustomBabelConfigFile],
[withSentryConfigPlugin],
Expand Down Expand Up @@ -133,4 +133,6 @@ module.exports = (withPlugins(
];
},
},
) /*: $FlowFixMe */);
);

module.exports = NextConfig;
29 changes: 12 additions & 17 deletions src/abacus-backoffice/src/products/ProductEditHeading.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,21 @@ export default function ProductEditHeading(props: Props): React.Node {
const router = useRouter();
const [displayFleshMessage] = useFlashMessages();

const [archiveProductMutation] = useMutation(
graphql`
mutation ProductEditHeadingArchiveMutation(
$productKey: ID!
$clientLocale: SupportedLocale!
) {
commerce {
productOrError: productArchive(productKey: $productKey, clientLocale: $clientLocale) {
... on Product {
__typename
}
... on ProductError {
__typename
message
}
const [archiveProductMutation] = useMutation(graphql`
mutation ProductEditHeadingArchiveMutation($productKey: ID!, $clientLocale: SupportedLocale!) {
commerce {
productOrError: productArchive(productKey: $productKey, clientLocale: $clientLocale) {
... on Product {
__typename
}
... on ProductError {
__typename
message
}
}
}
`,
);
}
`);

const product = useFragment(
graphql`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,47 +19,43 @@ export default function ProductEditHeadingPublishUnpublish(
const applicationLocale = useApplicationLocale();
const [displayFleshMessage] = useFlashMessages();

const [publishProductMutation] = useMutation(
graphql`
mutation ProductEditHeadingPublishUnpublishPublishMutation(
$productKey: ID!
$clientLocale: SupportedLocale!
) {
commerce {
productOrError: productPublish(productKey: $productKey, clientLocale: $clientLocale) {
... on Product {
__typename
}
... on ProductError {
__typename
message
}
const [publishProductMutation] = useMutation(graphql`
mutation ProductEditHeadingPublishUnpublishPublishMutation(
$productKey: ID!
$clientLocale: SupportedLocale!
) {
commerce {
productOrError: productPublish(productKey: $productKey, clientLocale: $clientLocale) {
... on Product {
__typename
}
... on ProductError {
__typename
message
}
}
}
`,
);
}
`);

const [unpublishProductMutation] = useMutation(
graphql`
mutation ProductEditHeadingPublishUnpublishUnpublishMutation(
$productKey: ID!
$clientLocale: SupportedLocale!
) {
commerce {
productOrError: productUnpublish(productKey: $productKey, clientLocale: $clientLocale) {
... on Product {
__typename
}
... on ProductError {
__typename
message
}
const [unpublishProductMutation] = useMutation(graphql`
mutation ProductEditHeadingPublishUnpublishUnpublishMutation(
$productKey: ID!
$clientLocale: SupportedLocale!
) {
commerce {
productOrError: productUnpublish(productKey: $productKey, clientLocale: $clientLocale) {
... on Product {
__typename
}
... on ProductError {
__typename
message
}
}
}
`,
);
}
`);

return props.isPublished === false ? (
<LayoutHeadingButton
Expand Down
6 changes: 4 additions & 2 deletions src/abacus-kochka/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const { key: cspKey, value: cspValue } = createContentSecurityPolicy({
reportOnly: true,
});

module.exports = (withPlugins(
const NextConfig /*: $FlowFixMe */ = withPlugins(
[
[withCustomBabelConfigFile],
[withSentryConfigPlugin],
Expand Down Expand Up @@ -136,4 +136,6 @@ module.exports = (withPlugins(
];
},
},
) /*: $FlowFixMe */);
);

module.exports = NextConfig;
9 changes: 5 additions & 4 deletions src/abacus-kochka/pages/_app.css
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@
font-family: 'GidoleKochka';
font-style: normal;
font-weight: 400;
src: local('Gidole'), url('/fonts/Gidole-Regular-subset.ttf') format('truetype');
src:
local('Gidole'),
url('/fonts/Gidole-Regular-subset.ttf') format('truetype');

/* All characters from: "KOCHKA CAFÉ®" */
unicode-range: /*K*/ U+4B, /*O*/ U+4F, /*C*/ U+43, /*H*/ U+48, /*A*/ U+41, /* */ U+20, /*F*/ U+46,
/*É*/ U+C9, /*®*/ U+AE;
/* All characters from: "KOCHKA CAFÉ®" ("KOCHAFÉ® ") */
unicode-range: U+4B, U+4F, U+43, U+48, U+41, U+20, U+46, U+C9, U+AE;
}

html,
Expand Down
6 changes: 4 additions & 2 deletions src/abacus-tools/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const withCustomBabelConfigFile = require('next-plugin-custom-babel-config')({
babelConfigFile: path.join(__dirname, '.babelrc.js'),
});

module.exports = (withPlugins(
const NextConfig /*: $FlowFixMe */ = withPlugins(
[
[withCustomBabelConfigFile],
// other plugins here
Expand All @@ -36,4 +36,6 @@ module.exports = (withPlugins(
esmExternals: 'loose',
},
},
) /*: $FlowFixMe */);
);

module.exports = NextConfig;
6 changes: 4 additions & 2 deletions src/eslint-config-adeira/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ const { WARN } = require('./src/constants');

/*::

import type { EslintConfig } from './src/EslintConfig.flow';
import type { EslintConfig as EslintConfigType } from './src/EslintConfig.flow';

*/

module.exports = (getCommonConfig(WARN, basePreset) /*: EslintConfig */);
const EslintConfig /*: EslintConfigType */ = getCommonConfig(WARN, basePreset);

module.exports = EslintConfig;
6 changes: 4 additions & 2 deletions src/eslint-config-adeira/fbt.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ const { WARN } = require('./src/constants');

/*::

import type { EslintConfig } from './src/EslintConfig.flow';
import type { EslintConfig as EslintConfigType } from './src/EslintConfig.flow';

*/

module.exports = (getCommonConfig(WARN, fbtPreset) /*: EslintConfig */);
const EslintConfig /*: EslintConfigType */ = getCommonConfig(WARN, fbtPreset);

module.exports = EslintConfig;
6 changes: 4 additions & 2 deletions src/eslint-config-adeira/flowtype.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ const { WARN } = require('./src/constants');

/*::

import type { EslintConfig } from './src/EslintConfig.flow';
import type { EslintConfig as EslintConfigType } from './src/EslintConfig.flow';

*/

module.exports = (getCommonConfig(WARN, flowtypePreset) /*: EslintConfig */);
const EslintConfig /*: EslintConfigType */ = getCommonConfig(WARN, flowtypePreset);

module.exports = EslintConfig;
8 changes: 5 additions & 3 deletions src/eslint-config-adeira/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ const { WARN } = require('./src/constants');

/*::

import type { EslintConfig } from './src/EslintConfig.flow';
import type { EslintConfig as EslintConfigType } from './src/EslintConfig.flow';

*/

module.exports = (getCommonConfig(WARN, {
const EslintConfig /*: EslintConfigType */ = getCommonConfig(WARN, {
rules: {
...basePreset.rules,
...flowtypePreset.rules,
Expand Down Expand Up @@ -46,4 +46,6 @@ module.exports = (getCommonConfig(WARN, {
...reactPreset.settings,
...relayPreset.settings,
},
}) /*: EslintConfig */);
});

module.exports = EslintConfig;
6 changes: 4 additions & 2 deletions src/eslint-config-adeira/jest.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ const { WARN } = require('./src/constants');

/*::

import type { EslintConfig } from './src/EslintConfig.flow';
import type { EslintConfig as EslintConfigType } from './src/EslintConfig.flow';

*/

module.exports = (getCommonConfig(WARN, jestPreset) /*: EslintConfig */);
const EslintConfig /*: EslintConfigType */ = getCommonConfig(WARN, jestPreset);

module.exports = EslintConfig;
6 changes: 4 additions & 2 deletions src/eslint-config-adeira/next.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ const { WARN } = require('./src/constants');

/*::

import type { EslintConfig } from './src/EslintConfig.flow';
import type { EslintConfig as EslintConfigType } from './src/EslintConfig.flow';

*/

module.exports = (getCommonConfig(WARN, nextPreset) /*: EslintConfig */);
const EslintConfig /*: EslintConfigType */ = getCommonConfig(WARN, nextPreset);

module.exports = EslintConfig;
5 changes: 3 additions & 2 deletions src/eslint-config-adeira/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,16 @@
"eslint-plugin-jsx-a11y": "^6.8.0",
"eslint-plugin-monorepo": "^0.3.2",
"eslint-plugin-n": "^17.7.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-promise": "^6.2.0",
"eslint-plugin-react": "^7.34.2",
"eslint-plugin-react-hooks": "^4.6.2",
"eslint-plugin-react-native": "^4.1.0",
"eslint-plugin-relay": "^1.8.3",
"eslint-plugin-sx": "^0.14.0",
"eslint-plugin-testing-library": "^6.2.2",
"prettier": "^2.8.8"
"prettier": "^3.3.0",
"prettier-plugin-hermes-parser": "^0.20.1"
},
"devDependencies": {
"deep-diff": "^1.0.2",
Expand Down
6 changes: 4 additions & 2 deletions src/eslint-config-adeira/react.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ const { WARN } = require('./src/constants');

/*::

import type { EslintConfig } from './src/EslintConfig.flow';
import type { EslintConfig as EslintConfigType } from './src/EslintConfig.flow';

*/

module.exports = (getCommonConfig(WARN, reactPreset) /*: EslintConfig */);
const EslintConfig /*: EslintConfigType */ = getCommonConfig(WARN, reactPreset);

module.exports = EslintConfig;
6 changes: 4 additions & 2 deletions src/eslint-config-adeira/relay.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ const { WARN } = require('./src/constants');

/*::

import type { EslintConfig } from './src/EslintConfig.flow';
import type { EslintConfig as EslintConfigType } from './src/EslintConfig.flow';

*/

module.exports = (getCommonConfig(WARN, relayPreset) /*: EslintConfig */);
const EslintConfig /*: EslintConfigType */ = getCommonConfig(WARN, relayPreset);

module.exports = EslintConfig;
6 changes: 4 additions & 2 deletions src/eslint-config-adeira/src/deprecatedRules.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow strict

module.exports = (new Set([
const deprecatedRulesSet /*: Set<string> */ = new Set([
// https://eslint.org/docs/rules/#deprecated
'indent-legacy', // indent
'lines-around-directive', // padding-line-between-statements
Expand Down Expand Up @@ -39,4 +39,6 @@ module.exports = (new Set([
'jest/no-try-expect', // https://github.com/jest-community/eslint-plugin-jest/commit/6d07cadd5f78ed7a64a86792931d49d3cd943d69

'react/jsx-sort-default-props', // use `react/sort-default-props` instead
]) /*: Set<string> */);
]);

module.exports = deprecatedRulesSet;
4 changes: 3 additions & 1 deletion src/eslint-config-adeira/src/extraPrettierRules.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ import type { EslintConfigRules } from './EslintConfig.flow';
// https://github.com/prettier/eslint-config-prettier#excluding-deprecated-rules
process.env.ESLINT_CONFIG_PRETTIER_NO_DEPRECATED = 'true';

module.exports = (require('eslint-config-prettier').rules /*: EslintConfigRules */);
const rules /*: EslintConfigRules */ = require('eslint-config-prettier').rules;

module.exports = rules;
9 changes: 9 additions & 0 deletions src/eslint-config-adeira/src/getCommonConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ module.exports = function getCommonConfig(
tabWidth: 2,
trailingComma: 'all',
quoteProps: 'consistent',
plugins: ['prettier-plugin-hermes-parser'],
overrides: [
{
files: ['*.js', '*.jsx', '*.flow'],
options: {
parser: 'hermes',
},
},
],
},
],
},
Expand Down
Loading
Loading