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(@aws-amplify/ui-components): Local prettier run on ui-components #8136

Merged
merged 5 commits into from
Apr 23, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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
77 changes: 39 additions & 38 deletions packages/amplify-ui-components/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,41 @@
module.exports = {
parser: '@typescript-eslint/parser', // Specifies the ESLint parser
extends: [
'plugin:@typescript-eslint/recommended', // Uses the recommended rules from the @typescript-eslint/eslint-plugin
'prettier/@typescript-eslint', // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier
'plugin:@stencil/recommended',
],
parserOptions: {
ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features
sourceType: 'module', // Allows for the use of imports
project: './tsconfig.json',
},
overrides: [
{
files: ['*.stories.tsx'],
rules: {
'@stencil/ban-side-effects': 'off',
},
},
{
files: ['*.tsx', '*.ts', '*.js'],
rules: {
'@stencil/strict-boolean-conditions': 'off',
},
},
],
rules: {
'@typescript-eslint/explicit-function-return-type': 0,
'@typescript-eslint/explicit-member-accessibility': 0,
'@typescript-eslint/no-empty-interface': 0,
'@typescript-eslint/no-explicit-any': 0,
'@typescript-eslint/no-unused-vars': 0,
'@typescript-eslint/camelcase': 0,
'@typescript-eslint/no-inferrable-types': 0,
'@typescript-eslint/explicit-module-boundary-types': 0,
'@typescript-eslint/no-empty-function': 0,
'@typescript-eslint/ban-ts-comment': 0,
'@typescript-eslint/ban-types': 0
},
parser: '@typescript-eslint/parser', // Specifies the ESLint parser
extends: [
'plugin:@typescript-eslint/recommended', // Uses the recommended rules from the @typescript-eslint/eslint-plugin
'prettier/@typescript-eslint', // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier
'plugin:@stencil/recommended',
],
parserOptions: {
ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features
sourceType: 'module', // Allows for the use of imports
project: './tsconfig.json',
},
overrides: [
{
files: ['*.stories.tsx'],
rules: {
'@stencil/ban-side-effects': 'off',
},
},
{
files: ['*.tsx', '*.ts', '*.js'],
rules: {
'@stencil/strict-boolean-conditions': 'off',
},
},
],
rules: {
'@typescript-eslint/explicit-function-return-type': 0,
'@typescript-eslint/explicit-member-accessibility': 0,
'@typescript-eslint/no-empty-interface': 0,
'@typescript-eslint/no-explicit-any': 0,
'@typescript-eslint/no-unused-vars': 0,
'@typescript-eslint/camelcase': 0,
'@typescript-eslint/no-inferrable-types': 0,
'@typescript-eslint/explicit-module-boundary-types': 0,
'@typescript-eslint/no-empty-function': 0,
'@typescript-eslint/ban-ts-comment': 0,
'@typescript-eslint/ban-types': 0,
'@stencil/decorators-style': 0
Copy link
Contributor Author

@wlee221 wlee221 Apr 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only code change made. With printwidth reduced from 120 to 80, decorators were moved to newlines which eslint didn't like. I disabled the rule here ('@stencil/decorators-style': 0).

},
};
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();
});
}
6 changes: 3 additions & 3 deletions packages/amplify-ui-components/.storybook/preview-head.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<script nomodule src="/build/amplify-ui-components.js"></script>
<link href="/build/amplify-ui-components.css" rel="stylesheet" />
<script>
if (global === undefined) {
var global = window;
}
if (global === undefined) {
var global = window;
}
</script>
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;
};
162 changes: 81 additions & 81 deletions packages/amplify-ui-components/package.json
Original file line number Diff line number Diff line change
@@ -1,83 +1,83 @@
{
"name": "@aws-amplify/ui-components",
"version": "1.2.0",
"description": "Core Amplify UI Component Library",
"module": "dist/index.mjs",
"main": "dist/index.js",
"es2015": "dist/esm/index.mjs",
"es2017": "dist/esm/index.mjs",
"unpkg": "dist/amplify-ui-components/amplify-ui-components.js",
"types": "dist/types/index.d.ts",
"collection": "dist/collection/collection-manifest.json",
"files": [
"dist/",
"loader"
],
"publishConfig": {
"access": "public"
},
"scripts": {
"lint": "eslint --ext .js,.ts,.tsx .",
"format": "eslint --fix --ext .js,.ts,.tsx .",
"pretest": "npm run lint",
"test": "stencil test --spec",
"test:screenshot": "stencil test --spec --screenshot",
"test:update-screenshot": "rm -f screenshot/builds/master.json && rm -f screenshot/images/* && stencil test --spec --screenshot --update-screenshot",
"test:watch": "stencil test --spec --watchAll",
"stencil": "stencil build --docs-readme",
"stencil:watch": "stencil build --watch",
"start": "stencil build --watch --serve --dev",
"storybook": "concurrently 'start-storybook -p 3000 -s ./www' 'yarn:stencil:watch' --raw",
"build-with-test": "npm run clean && npm test && npm run stencil",
"build": "npm run clean && npm run stencil --ci",
"build:esm:watch": "npm run clean && npm run stencil:watch",
"build:watch": "npm run clean && npm run stencil:watch",
"clean": "rimraf dist .stencil"
},
"peerDependencies": {
"aws-amplify": "3.x.x"
},
"dependencies": {
"qrcode": "^1.4.4",
"uuid": "^8.2.0"
},
"devDependencies": {
"@stencil/angular-output-target": "^0.0.2",
"@stencil/core": "1.15.0",
"@stencil/eslint-plugin": "0.2.1",
"@stencil/react-output-target": "^0.0.6",
"@stencil/sass": "^1.1.1",
"@storybook/addon-a11y": "^5.2.5",
"@storybook/addon-actions": "^5.2.5",
"@storybook/addon-console": "^1.2.1",
"@storybook/addon-knobs": "^5.2.5",
"@storybook/html": "^5.2.5",
"@types/jest": "24.9.1",
"@types/node": "^12.6.3",
"@types/puppeteer": "1.19.1",
"@types/webpack": "^4.4.35",
"@types/webpack-env": "^1.14.0",
"@typescript-eslint/eslint-plugin": "^4.11.0",
"@typescript-eslint/parser": "^1.12.0",
"babel-loader": "^8.0.6",
"concurrently": "^5.0.0",
"eslint": "^7.16.0",
"eslint-config-prettier": "^7.1.0",
"eslint-plugin-prettier": "^3.3.0",
"eslint-plugin-react": "^7.19.0",
"husky": "^2.4.1",
"jest": "24.9.0",
"jest-cli": "24.9.0",
"prettier": "^1.17.1",
"puppeteer": "1.19.0",
"rimraf": "^3.0.0",
"rollup-plugin-node-externals": "^2.1.3",
"rollup-plugin-node-polyfills": "^0.2.1"
},
"husky": {
"hooks": {
"pre-push": "npm run test"
}
},
"license": "Apache-2.0"
"name": "@aws-amplify/ui-components",
"version": "1.2.0",
"description": "Core Amplify UI Component Library",
"module": "dist/index.mjs",
"main": "dist/index.js",
"es2015": "dist/esm/index.mjs",
"es2017": "dist/esm/index.mjs",
"unpkg": "dist/amplify-ui-components/amplify-ui-components.js",
"types": "dist/types/index.d.ts",
"collection": "dist/collection/collection-manifest.json",
"files": [
"dist/",
"loader"
],
"publishConfig": {
"access": "public"
},
"scripts": {
"lint": "eslint --ext .js,.ts,.tsx .",
"format": "eslint --fix --ext .js,.ts,.tsx .",
"pretest": "npm run lint",
"test": "stencil test --spec",
"test:screenshot": "stencil test --spec --screenshot",
"test:update-screenshot": "rm -f screenshot/builds/master.json && rm -f screenshot/images/* && stencil test --spec --screenshot --update-screenshot",
"test:watch": "stencil test --spec --watchAll",
"stencil": "stencil build --docs-readme",
"stencil:watch": "stencil build --watch",
"start": "stencil build --watch --serve --dev",
"storybook": "concurrently 'start-storybook -p 3000 -s ./www' 'yarn:stencil:watch' --raw",
"build-with-test": "npm run clean && npm test && npm run stencil",
"build": "npm run clean && npm run stencil --ci",
"build:esm:watch": "npm run clean && npm run stencil:watch",
"build:watch": "npm run clean && npm run stencil:watch",
"clean": "rimraf dist .stencil"
},
"peerDependencies": {
"aws-amplify": "3.x.x"
},
"dependencies": {
"qrcode": "^1.4.4",
"uuid": "^8.2.0"
},
"devDependencies": {
"@stencil/angular-output-target": "^0.0.2",
"@stencil/core": "1.15.0",
"@stencil/eslint-plugin": "0.2.1",
"@stencil/react-output-target": "^0.0.6",
"@stencil/sass": "^1.1.1",
"@storybook/addon-a11y": "^5.2.5",
"@storybook/addon-actions": "^5.2.5",
"@storybook/addon-console": "^1.2.1",
"@storybook/addon-knobs": "^5.2.5",
"@storybook/html": "^5.2.5",
"@types/jest": "24.9.1",
"@types/node": "^12.6.3",
"@types/puppeteer": "1.19.1",
"@types/webpack": "^4.4.35",
"@types/webpack-env": "^1.14.0",
"@typescript-eslint/eslint-plugin": "^4.11.0",
"@typescript-eslint/parser": "^1.12.0",
"babel-loader": "^8.0.6",
"concurrently": "^5.0.0",
"eslint": "^7.16.0",
"eslint-config-prettier": "^7.1.0",
"eslint-plugin-prettier": "^3.3.0",
"eslint-plugin-react": "^7.19.0",
"husky": "^2.4.1",
"jest": "24.9.0",
"jest-cli": "24.9.0",
"prettier": "^1.17.1",
"puppeteer": "1.19.0",
"rimraf": "^3.0.0",
"rollup-plugin-node-externals": "^2.1.3",
"rollup-plugin-node-polyfills": "^0.2.1"
},
"husky": {
"hooks": {
"pre-push": "npm run test"
}
},
"license": "Apache-2.0"
}
Loading