Use Prettier for JS files (#3913)

Co-authored-by: Hadrien Croubois <hadrien.croubois@gmail.com>
This commit is contained in:
Francisco
2023-01-04 11:03:40 -03:00
committed by GitHub
parent 88754d0b36
commit a28aafdc85
135 changed files with 2737 additions and 3121 deletions

View File

@ -2,26 +2,26 @@ const { version } = require('../../package.json');
module.exports['oz-version'] = () => version;
module.exports['readme-path'] = (opts) => {
module.exports['readme-path'] = opts => {
return 'contracts/' + opts.data.root.id.replace(/\.adoc$/, '') + '/README.adoc';
};
module.exports.names = (params) => params.map(p => p.name).join(', ');
module.exports.names = params => params.map(p => p.name).join(', ');
module.exports['typed-params'] = (params) => {
module.exports['typed-params'] = params => {
return params.map(p => `${p.type}${p.name ? ' ' + p.name : ''}`).join(', ');
};
const slug = module.exports.slug = (str) => {
const slug = (module.exports.slug = str => {
if (str === undefined) {
throw new Error('Missing argument');
}
return str.replace(/\W/g, '-');
};
});
const linksCache = new WeakMap();
function getAllLinks (items) {
function getAllLinks(items) {
if (linksCache.has(items)) {
return linksCache.get(items);
}
@ -34,11 +34,11 @@ function getAllLinks (items) {
return res;
}
module.exports['with-prelude'] = (opts) => {
module.exports['with-prelude'] = opts => {
const links = getAllLinks(opts.data.site.items);
const contents = opts.fn();
const neededLinks = contents
.match(/\{[-._a-z0-9]+\}/ig)
.match(/\{[-._a-z0-9]+\}/gi)
.map(m => m.replace(/^\{(.+)\}$/, '$1'))
.filter(k => k in links);
const prelude = neededLinks.map(k => `:${k}: ${links[k]}`).join('\n');

View File

@ -1,7 +1,7 @@
const { isNodeType } = require('solidity-ast/utils');
const { slug } = require('./helpers');
module.exports.anchor = function anchor ({ item, contract }) {
module.exports.anchor = function anchor({ item, contract }) {
let res = '';
if (contract) {
res += contract.name + '-';
@ -37,13 +37,9 @@ module.exports['has-events'] = function ({ item }) {
module.exports['inherited-functions'] = function ({ item }) {
const { inheritance } = item;
const baseFunctions = new Set(
inheritance.flatMap(c => c.functions.flatMap(f => f.baseFunctions ?? [])),
);
const baseFunctions = new Set(inheritance.flatMap(c => c.functions.flatMap(f => f.baseFunctions ?? [])));
return inheritance.map((contract, i) => ({
contract,
functions: contract.functions.filter(f =>
!baseFunctions.has(f.id) && (f.name !== 'constructor' || i === 0),
),
functions: contract.functions.filter(f => !baseFunctions.has(f.id) && (f.name !== 'constructor' || i === 0)),
}));
};