Skip to content

Commit

Permalink
fixed prettier formatting (#276)
Browse files Browse the repository at this point in the history
* fixed prettier formatting
  • Loading branch information
tumms2021389 authored Jan 12, 2024
1 parent 3e8773b commit 9f0b6b0
Show file tree
Hide file tree
Showing 279 changed files with 4,509 additions and 5,137 deletions.
7 changes: 7 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
**/.git
**/.github
**/.vscode
**/.svn
**/.hg
**/*.md
**/assets
9 changes: 9 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Prettier config options: https://prettier.io/docs/en/options.html
// Shared front-end config: https://git.pega.io/projects/FE/repos/configs/browse/packages/prettier-config/index.json

const pegaPrettierConfig = require('@pega/prettier-config');

module.exports = {
...pegaPrettierConfig,
printWidth: 150
};
27 changes: 11 additions & 16 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,30 @@

"editor.insertSpaces": true,
"editor.tabSize": 2,
"editor.formatOnSave": false,
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.codeActionsOnSave": [
/*"source.fixAll.eslint"*/
],
"editor.codeActionsOnSave": ["source.fixAll.eslint"],

"[javascript]": {
"editor.formatOnSave": false
"editor.formatOnSave": true
},
"[javascriptreact]": {
"editor.formatOnSave": false
"editor.formatOnSave": true
},
"[typescript]": {
"editor.formatOnSave": false
"editor.formatOnSave": true
},
"[typescriptreact]": {
"editor.formatOnSave": false
"editor.formatOnSave": true
},
"[json]": {
"editor.formatOnSave": false
"editor.formatOnSave": true
},
"[jsonc]": {
"editor.formatOnSave": false
"editor.formatOnSave": true
},
"[html]": {
"editor.formatOnSave": false
"editor.formatOnSave": true
},
"[markdown]": {
"editor.formatOnSave": false
Expand All @@ -50,9 +48,6 @@

"eslint.enable": true,
"eslint.validate": ["javascript", "javascriptreact", "typescript", "typescriptreact"],

"jest.pathToJest": "npm test --",

"json.schemas": [
]
"eslint.workingDirectories": [{ "pattern": "." }],
"prettier.configPath": ".prettierrc.js"
}
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ module.exports = {
'^.+\\.(t|j)sx?$': 'ts-jest'
},
setupFilesAfterEnv: ['<rootDir>/packages/react-sdk-components/tests/setupTests.js'],
coverageDirectory: "tests/coverage"
coverageDirectory: 'tests/coverage'
};
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,12 @@
"copy-local-component-map-to-lib": "shx cp ./packages/react-sdk-components/sdk-local-component-map.js ./packages/react-sdk-components/lib",
"copy-types-to-lib": "shx mkdir -p ./packages/react-sdk-components/lib/types && shx cp -r ./packages/react-sdk-components/src/types ./packages/react-sdk-components/lib",
"edit-pega-components-map": "node scripts/edit-pega-components-map-in-lib.js",
"lint": "npx eslint \"packages/react-sdk-components/src/**\"",
"lint-errors-only": "npx eslint \"packages/react-sdk-components/src/**\" --quiet",
"lint": "run-p -cl lint:*",
"lint:es": "eslint --color --cache --cache-location node_modules/.cache/eslint/ \"packages/react-sdk-components/src/**\"",
"lint:format": "prettier --log-level warn -c .",
"fix": "run-s -cl fix:*",
"fix:es": "eslint --color --fix --cache --cache-location node_modules/.cache/eslint/ \"packages/react-sdk-components/src/**\"",
"fix:format": "prettier --log-level warn -w .",
"build-dev-only": "webpack --mode=development",
"build-prod-only": "webpack --mode=production",
"build:dev": "run-p -l lint build-dev-only",
Expand Down
7 changes: 0 additions & 7 deletions packages/react-sdk-components/.prettierrc.json

This file was deleted.

2 changes: 1 addition & 1 deletion packages/react-sdk-components/sdk-local-component-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// found locally. If not found here, we'll look in the Pega-provided component map

const localSdkComponentMap = {
/*map end - DO NOT REMOVE*/
/*map end - DO NOT REMOVE*/
};

export default localSdkComponentMap;
168 changes: 84 additions & 84 deletions packages/react-sdk-components/src/auth.html
Original file line number Diff line number Diff line change
@@ -1,94 +1,94 @@
<!DOCTYPE html>
<!doctype html>
<html>
<head>
<script>
// This script file is retrieved by the standard html page that is specified as the
// redirect uri for an authorization code grant (with or without PKCE) flow.
// It attempts to pass back the received code, state and error using 3 techniques
// 1) Try to call directly into a callback function (won't work across servers)
// 2) Try to call directly to postMessage (won't work across domains)
// 3) Awaits a message from the host page and when received immediately postMessages back with the code
<head>
<script>
// This script file is retrieved by the standard html page that is specified as the
// redirect uri for an authorization code grant (with or without PKCE) flow.
// It attempts to pass back the received code, state and error using 3 techniques
// 1) Try to call directly into a callback function (won't work across servers)
// 2) Try to call directly to postMessage (won't work across domains)
// 3) Awaits a message from the host page and when received immediately postMessages back with the code

// For enabling logging via debugger (do not let it be a const...then can't change in debugger)
// eslint-disable-next-line prefer-const
let bDebug = false;
// For enabling logging via debugger (do not let it be a const...then can't change in debugger)
// eslint-disable-next-line prefer-const
let bDebug = false;

const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
const code = urlParams.get('code');
const state = urlParams.get('state');
const error = urlParams.get('error');
const errorDesc = urlParams.get('error_description');
// Silent authentication will work with just regular console.log
// eslint-disable-next-line no-console
let fnLog = console.log;
try {
// Check if in a popup window. If so use main window console.
if (window.opener.console.log) {
fnLog = window.opener.console.log;
}
// eslint-disable-next-line no-empty
} catch (e0) {}
const doLog = (arg) => {
if (bDebug) {
fnLog(arg);
}
};
// doLog('Testing do Log');
let bSuccess = false;
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
const code = urlParams.get('code');
const state = urlParams.get('state');
const error = urlParams.get('error');
const errorDesc = urlParams.get('error_description');
// Silent authentication will work with just regular console.log
// eslint-disable-next-line no-console
let fnLog = console.log;
try {
// Check if in a popup window. If so use main window console.
if (window.opener.console.log) {
fnLog = window.opener.console.log;
}
// eslint-disable-next-line no-empty
} catch (e0) {}
const doLog = arg => {
if (bDebug) {
fnLog(arg);
}
};
// doLog('Testing do Log');
let bSuccess = false;

const getEmbedOriginFromState = () => {
let embedOrigin = null;
try {
// Expect state to contain the embedding page's origin followed by random state separated by '.'
if (state) {
embedOrigin = window.atob(state.split('.')[0]);
}
// eslint-disable-next-line no-empty
} catch (e) {}
if (!embedOrigin) {
embedOrigin = window.location.origin;
}
return embedOrigin;
};
const getEmbedOriginFromState = () => {
let embedOrigin = null;
try {
// Expect state to contain the embedding page's origin followed by random state separated by '.'
if (state) {
embedOrigin = window.atob(state.split('.')[0]);
}
// eslint-disable-next-line no-empty
} catch (e) {}
if (!embedOrigin) {
embedOrigin = window.location.origin;
}
return embedOrigin;
};

// eslint-disable-next-line sonarjs/cognitive-complexity
function main() {
if (code || error) {
try {
window.opener.authCodeCallback(code, state, error, errorDesc);
bSuccess = true;
} catch (e) {
doLog('auth.html: Failed to directly access authCodeCallback.');
}
// eslint-disable-next-line sonarjs/cognitive-complexity
function main() {
if (code || error) {
try {
window.opener.authCodeCallback(code, state, error, errorDesc);
bSuccess = true;
} catch (e) {
doLog('auth.html: Failed to directly access authCodeCallback.');
}

// Post messages require a targetDomain...trying to pass this via state
const embedOrigin = getEmbedOriginFromState();
if (!bSuccess) {
try {
window.opener.postMessage({ type: 'PegaAuth', code, state, error, errorDesc }, embedOrigin);
bSuccess = true;
} catch (e) {
doLog('auth.html: Failed to directly post message to opener');
}
}
// Post messages require a targetDomain...trying to pass this via state
const embedOrigin = getEmbedOriginFromState();
if (!bSuccess) {
try {
window.opener.postMessage({ type: 'PegaAuth', code, state, error, errorDesc }, embedOrigin);
bSuccess = true;
} catch (e) {
doLog('auth.html: Failed to directly post message to opener');
}
}

if (!bSuccess) {
window.addEventListener('message', (event) => {
doLog('authDone.js: received PegaAuth message');
if (event.data && event.data.type && event.data.type === 'PegaAuth') {
doLog('authDone.js: posting message back');
event.source.postMessage({ type: 'PegaAuth', code, state, error, errorDesc }, embedOrigin);
if (!bSuccess) {
window.addEventListener('message', event => {
doLog('authDone.js: received PegaAuth message');
if (event.data && event.data.type && event.data.type === 'PegaAuth') {
doLog('authDone.js: posting message back');
event.source.postMessage({ type: 'PegaAuth', code, state, error, errorDesc }, embedOrigin);
}
});
}
}
});
}
}
}
}

(() => {
main();
})();
</script>
<body>
</body>
(() => {
main();
})();
</script>
</head>
<body></body>
</html>
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { createContext, useContext } from "react";
import { createContext, useContext } from 'react';

declare const process:any;
declare const process: any;

// Argument was null but that failed TypeScript compilation. Change to empty object

const ReactReduxContext = createContext({});

if (process.env.NODE_ENV !== "production") {
ReactReduxContext.displayName = "ReactRedux";
if (process.env.NODE_ENV !== 'production') {
ReactReduxContext.displayName = 'ReactRedux';
}

export const useConstellationContext = () => useContext(ReactReduxContext);
Expand Down
Loading

0 comments on commit 9f0b6b0

Please sign in to comment.