Skip to content

Commit

Permalink
Expand prettier coverage (MetaMask#346)
Browse files Browse the repository at this point in the history
All Markdown, JavaScript, and TypeScript files are now covered by
`prettier` in the `lint` script, excluding build files.

Aside from the adjustment to the npm `lint` script, all other changes
are the output of `yarn lint:fix`.
  • Loading branch information
Gudahtt authored Jan 17, 2022
1 parent 5943c5c commit 1de4850
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 75 deletions.
11 changes: 4 additions & 7 deletions .prettierrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@ module.exports = {
singleQuote: true,
overrides: [
{
files: [
'WatchAssetParams.ts',
'web3ToProvider.js',
],
files: ['WatchAssetParams.ts', 'web3ToProvider.js'],
options: {
quoteProps: 'preserve',
}
},
},
]
}
],
};
136 changes: 85 additions & 51 deletions docs/.vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,39 @@ module.exports = (_ctx) => ({
'/': {
lang: 'en-US',
title: 'MetaMask Docs',
description: 'Developer documentation for the MetaMask Ethereum wallet'
}
description: 'Developer documentation for the MetaMask Ethereum wallet',
},
},

head: [
['link', { rel: 'icon', href: `/metamask-fox.svg` }],
['link', { rel: 'manifest', href: '/manifest.json' }],
['meta', { name: 'theme-color', content: '#3eaf7c' }],
['meta', { name: 'apple-mobile-web-app-capable', content: 'yes' }],
['meta', { name: 'apple-mobile-web-app-status-bar-style', content: 'black' }],
['link', { rel: 'apple-touch-icon', href: `/icons/apple-touch-icon-152x152.png` }],
['link', { rel: 'mask-icon', href: '/icons/safari-pinned-tab.svg', color: '#3eaf7c' }],
['meta', { name: 'msapplication-TileImage', content: '/icons/msapplication-icon-144x144.png' }],
['meta', { name: 'msapplication-TileColor', content: '#000000' }]
[
'meta',
{ name: 'apple-mobile-web-app-status-bar-style', content: 'black' },
],
[
'link',
{ rel: 'apple-touch-icon', href: `/icons/apple-touch-icon-152x152.png` },
],
[
'link',
{
rel: 'mask-icon',
href: '/icons/safari-pinned-tab.svg',
color: '#3eaf7c',
},
],
[
'meta',
{
name: 'msapplication-TileImage',
content: '/icons/msapplication-icon-144x144.png',
},
],
['meta', { name: 'msapplication-TileColor', content: '#000000' }],
],

theme: '@vuepress/theme-default',
Expand All @@ -42,46 +61,65 @@ module.exports = (_ctx) => ({
lastUpdated: 'Last Updated',
nav: require('./nav/en'),
sidebar: {
'/guide/': getGuideSidebar('Guide', 'API Reference', 'Best Practices', 'Mobile', 'Resources'),
}
}
}
'/guide/': getGuideSidebar(
'Guide',
'API Reference',
'Best Practices',
'Mobile',
'Resources'
),
},
},
},
},

plugins: [
['@vuepress/back-to-top', true],
['@vuepress/pwa', {
serviceWorker: true,
updatePopup: true
}],
[
'@vuepress/pwa',
{
serviceWorker: true,
updatePopup: true,
},
],
['@vuepress/medium-zoom', true],
['container', {
type: 'vue',
before: '<pre class="vue-container"><code>',
after: '</code></pre>',
}],
['container', {
type: 'upgrade',
before: info => `<UpgradePath title="${info}">`,
after: '</UpgradePath>',
}],
['vuepress-plugin-redirect', {
redirectors: [
{
base: '/',
alternative: '/guide/'
},
],
}],
['tabs', {
useUrlFragment: false
}]
[
'container',
{
type: 'vue',
before: '<pre class="vue-container"><code>',
after: '</code></pre>',
},
],
[
'container',
{
type: 'upgrade',
before: (info) => `<UpgradePath title="${info}">`,
after: '</UpgradePath>',
},
],
[
'vuepress-plugin-redirect',
{
redirectors: [
{
base: '/',
alternative: '/guide/',
},
],
},
],
[
'tabs',
{
useUrlFragment: false,
},
],
],

extraWatchFiles: [
'.vuepress/nav/en.js',
]
})
extraWatchFiles: ['.vuepress/nav/en.js'],
});

function getGuideSidebar(guide, api, bestPractices, mobile, resources) {
return [
Expand All @@ -95,7 +133,7 @@ function getGuideSidebar(guide, api, bestPractices, mobile, resources) {
'initializing-dapps',
'accessing-accounts',
'sending-transactions',
]
],
},
{
title: api,
Expand All @@ -105,7 +143,7 @@ function getGuideSidebar(guide, api, bestPractices, mobile, resources) {
'provider-migration',
'rpc-api',
'signing-data',
]
],
},
{
title: bestPractices,
Expand All @@ -116,7 +154,7 @@ function getGuideSidebar(guide, api, bestPractices, mobile, resources) {
'defining-your-icon',
'onboarding-library',
'metamask-extension-provider',
]
],
},
{
title: mobile,
Expand All @@ -125,16 +163,12 @@ function getGuideSidebar(guide, api, bestPractices, mobile, resources) {
'mobile-getting-started',
'site-compatibility-checklist',
'mobile-best-practices',
]
],
},
{
title: resources,
collapsable: false,
children: [
'create-dapp',
'contributors'
]
}
]
children: ['create-dapp', 'contributors'],
},
];
}

12 changes: 6 additions & 6 deletions docs/.vuepress/enhanceApp.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@


import EthConnectButton from './components/EthConnectButton';
import EthAsyncConnectButton from './components/EthAsyncConnectButton';
import ChangeAccount from './components/ChangeAccount';
import SendTransaction from './components/SendTransaction';

export default ({ Vue, isServer }) => {
if (!isServer) {
import('vue-toasted' /* webpackChunkName: "notification" */).then((module) => {
Vue.use(module.default)
})
import('vue-toasted' /* webpackChunkName: "notification" */).then(
(module) => {
Vue.use(module.default);
}
);
}

Vue.component('EthConnectButton', EthConnectButton);
Vue.component('EthAsyncConnectButton', EthAsyncConnectButton);
Vue.component('ChangeAccount', ChangeAccount);
Vue.component('SendTransaction', SendTransaction);
}
};
2 changes: 1 addition & 1 deletion docs/.vuepress/nav/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ module.exports = [
text: 'Guide',
link: '/guide/',
},
]
];
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"dev": "yarn start",
"start": "node scripts/build.js dev",
"build": "node scripts/build.js build",
"lint": "prettier docs/guide/*.md docs/snippets/* --check",
"lint": "prettier '!docs/dist' **/*.{js,json,md,ts} --check",
"lint:fix": "yarn lint --write",
"view-info": "vuepress view-info docs",
"show-help": "vuepress --help"
Expand Down
18 changes: 9 additions & 9 deletions scripts/build.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
require('dotenv').config()
require('dotenv').config();

const { dev, build } = require('vuepress')
const config = require('../docs/.vuepress/config')()
const { dev, build } = require('vuepress');
const config = require('../docs/.vuepress/config')();

const command = process.argv[2]
const command = process.argv[2];

switch (command) {
case 'build':
build(config)
return
build(config);
return;

case 'dev':
dev(config)
return
dev(config);
return;

default:
throw new Error(`Unrecognized command "${command}".`)
throw new Error(`Unrecognized command "${command}".`);
}

0 comments on commit 1de4850

Please sign in to comment.