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

chore: local prettier run #8040

Closed
wants to merge 6 commits into from
Closed
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
4 changes: 2 additions & 2 deletions .prettierrc → .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
module.exports = {
"trailingComma": "es5",
"singleQuote": true,
"useTabs": true
"useTabs": true,
}
39 changes: 22 additions & 17 deletions packages/amazon-cognito-identity-js/src/AuthenticationHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ import WordArray from './utils/WordArray';

/**
* Returns a Buffer with a sequence of random nBytes
*
* @param {number} nBytes
*
* @param {number} nBytes
* @returns {Buffer} fixed-length sequence of random bytes
*/
function randomBytes(nBytes) {
return Buffer.from(new WordArray().random(nBytes).toString(), 'hex');
};
}

import BigInteger from './BigInteger';

Expand Down Expand Up @@ -74,7 +74,7 @@ export default class AuthenticationHelper {
);

this.smallAValue = this.generateRandomSmallA();
this.getLargeAValue(() => { });
this.getLargeAValue(() => {});

this.infoBits = Buffer.from('Caldera Derived Key', 'utf8');

Expand Down Expand Up @@ -353,27 +353,27 @@ export default class AuthenticationHelper {

/**
* Returns an unambiguous, even-length hex string of the two's complement encoding of an integer.
*
* It is compatible with the hex encoding of Java's BigInteger's toByteArray(), wich returns a
*
* It is compatible with the hex encoding of Java's BigInteger's toByteArray(), wich returns a
* byte array containing the two's-complement representation of a BigInteger. The array contains
* the minimum number of bytes required to represent the BigInteger, including at least one sign bit.
*
*
* Examples showing how ambiguity is avoided by left padding with:
* "00" (for positive values where the most-significant-bit is set)
* "FF" (for negative values where the most-significant-bit is set)
*
*
* padHex(bigInteger.fromInt(-236)) === "FF14"
* padHex(bigInteger.fromInt(20)) === "14"
*
*
* padHex(bigInteger.fromInt(-200)) === "FF38"
* padHex(bigInteger.fromInt(56)) === "38"
*
*
* padHex(bigInteger.fromInt(-20)) === "EC"
* padHex(bigInteger.fromInt(236)) === "00EC"
*
*
* padHex(bigInteger.fromInt(-56)) === "C8"
* padHex(bigInteger.fromInt(200)) === "00C8"
*
*
* @param {BigInteger} bigInt Number to encode.
* @returns {String} even-length hex string of the two's complement encoding.
*/
Expand All @@ -395,13 +395,18 @@ export default class AuthenticationHelper {

if (isNegative) {
/* Flip the bits of the representation */
const invertedNibbles = hexStr.split('').map(x => {
const invertedNibble = ~parseInt(x, 16) & 0xf;
return '0123456789ABCDEF'.charAt(invertedNibble);
}).join('');
const invertedNibbles = hexStr
.split('')
.map(x => {
const invertedNibble = ~parseInt(x, 16) & 0xf;
return '0123456789ABCDEF'.charAt(invertedNibble);
})
.join('');

/* After flipping the bits, add one to get the 2's complement representation */
const flippedBitsBI = new BigInteger(invertedNibbles, 16).add(BigInteger.ONE);
const flippedBitsBI = new BigInteger(invertedNibbles, 16).add(
BigInteger.ONE
);

hexStr = flippedBitsBI.toString(16);

Expand Down
2 changes: 1 addition & 1 deletion packages/amazon-cognito-identity-js/src/CookieStorage.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default class CookieStorage {
this.secure = true;
}
if (Object.prototype.hasOwnProperty.call(data, 'sameSite')) {
if (!['strict','lax','none'].includes(data.sameSite)) {
if (!['strict', 'lax', 'none'].includes(data.sameSite)) {
throw new Error(
'The sameSite value of cookieStorage must be "lax", "strict" or "none".'
);
Expand Down
44 changes: 24 additions & 20 deletions packages/amplify-ui-angular/scripts/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
import resolve from 'rollup-plugin-node-resolve';

export default {
input: 'build/es2015/core.js',
output: {
file: 'dist/fesm2015.js',
format: 'es'
},
external: (id) => {
// inline @ionic/core deps
if (id === '@ionic/core') {
return false;
}
// anything else is external
// Windows: C:\xxxxxx\xxx
const colonPosition = 1;
return !(id.startsWith('.') || id.startsWith('/') || id.charAt(colonPosition) === ':');
},
plugins: [
resolve({
module: true,
})
]
input: 'build/es2015/core.js',
output: {
file: 'dist/fesm2015.js',
format: 'es',
},
external: id => {
// inline @ionic/core deps
if (id === '@ionic/core') {
return false;
}
// anything else is external
// Windows: C:\xxxxxx\xxx
const colonPosition = 1;
return !(
id.startsWith('.') ||
id.startsWith('/') ||
id.charAt(colonPosition) === ':'
);
},
plugins: [
resolve({
module: true,
}),
],
};
4 changes: 2 additions & 2 deletions packages/amplify-ui-angular/scripts/rollup.config.legacy.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import config from './rollup.config';

const newConfig = {
...config,
input: 'build/es5/core.js',
...config,
input: 'build/es5/core.js',
};
newConfig.output.file = 'dist/fesm5.js';

Expand Down
14 changes: 7 additions & 7 deletions packages/amplify-ui-angular/tsconfig.legacy.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"target": "es5",
"declarationDir": "build/es5",
"outDir": "build/es5"
}
}
"extends": "./tsconfig.json",
"compilerOptions": {
"target": "es5",
"declarationDir": "build/es5",
"outDir": "build/es5"
}
}
4 changes: 4 additions & 0 deletions packages/amplify-ui-components/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
...require('../../.prettierrc.js'),
printWidth: 120,
};
26 changes: 13 additions & 13 deletions packages/amplify-ui-components/.storybook/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import { withA11y } from '@storybook/addon-a11y';
import { setConsoleOptions } from '@storybook/addon-console';

addDecorator((storyFn, context) => {
setConsoleOptions({
log: `${context.kind}/${context.story}`,
warn: `${context.kind}/${context.story}/warn`,
error: `${context.kind}/${context.story}/error`,
});
setConsoleOptions({
log: `${context.kind}/${context.story}`,
warn: `${context.kind}/${context.story}/warn`,
error: `${context.kind}/${context.story}/error`,
});

return storyFn(context);
return storyFn(context);
});

addDecorator(withKnobs);
Expand All @@ -19,11 +19,11 @@ addDecorator(withA11y);
configure(require.context('../src/components', true, /.stories.tsx$/), module);

if (module.hot) {
// Listening for `dispose` indicates when a build has taken place so that
// we can reload the iframe `window` with changes from stencil's build process.
// (`module.hot.accept` will refresh the sidebar as well, since `req.id`).
module.hot.dispose(() => {
window.history.pushState(null, null, window.location.href);
window.location.reload();
});
// Listening for `dispose` indicates when a build has taken place so that
// we can reload the iframe `window` with changes from stencil's build process.
// (`module.hot.accept` will refresh the sidebar as well, since `req.id`).
module.hot.dispose(() => {
window.history.pushState(null, null, window.location.href);
window.location.reload();
});
}
44 changes: 22 additions & 22 deletions packages/amplify-ui-components/.storybook/stencil-jsx.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,31 @@
*/

export const h = (tag, props, ...children) => {
const node = document.createElement(tag);
const node = document.createElement(tag);

if (props) {
Object.entries(props).forEach(([key, value]) => {
if (key.match(/^on[A-Z]/)) {
const eventName = key.charAt(2).toLowerCase() + key.slice(3);
if (props) {
Object.entries(props).forEach(([key, value]) => {
if (key.match(/^on[A-Z]/)) {
const eventName = key.charAt(2).toLowerCase() + key.slice(3);

if (typeof value === 'function') {
node.addEventListener(eventName, value);
}
}
if (typeof value === 'function') {
node.addEventListener(eventName, value);
}
}

node[key] = value;
});
}
node[key] = value;
});
}

children.forEach(child => {
if (['number', 'string'].includes(typeof child)) {
node.appendChild(document.createTextNode(child));
} else if (child === null) {
node.appendChild(document.createComment(''));
} else {
node.appendChild(child);
}
});
children.forEach(child => {
if (['number', 'string'].includes(typeof child)) {
node.appendChild(document.createTextNode(child));
} else if (child === null) {
node.appendChild(document.createComment(''));
} else {
node.appendChild(child);
}
});

return node;
return node;
};
36 changes: 18 additions & 18 deletions packages/amplify-ui-components/.storybook/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@ const path = require('path');
const webpack = require('webpack');

module.exports = ({ config, mode }) => {
config = Object.assign(
{
module: {
rules: [],
},
plugins: [],
},
config || {},
);
config = Object.assign(
{
module: {
rules: [],
},
plugins: [],
},
config || {}
);

config.module.rules.push({
test: /\.(ts|tsx)$/,
include: path.resolve(__dirname, '../src'),
loader: require.resolve('ts-loader'),
});
config.module.rules.push({
test: /\.(ts|tsx)$/,
include: path.resolve(__dirname, '../src'),
loader: require.resolve('ts-loader'),
});

config.resolve.extensions.push('.ts', '.tsx');
config.resolve.extensions.push('.ts', '.tsx');

// Stencil requires a build step, stories using JSX will create DOM nodes instead.
config.resolve.alias['@stencil/core$'] = require.resolve('./stencil-jsx');
// Stencil requires a build step, stories using JSX will create DOM nodes instead.
config.resolve.alias['@stencil/core$'] = require.resolve('./stencil-jsx');

return config;
return config;
};
Loading