Skip to content

Commit 7b2054d

Browse files
Merge #1663
1663: Remove prettier custom options r=curquiza a=flevi29 # Pull Request ## Related issue Fixes #1659 ## What does this PR do? - Removes unnecessary prettier options for reasons described in the linked issue - Applies these changes to all files Co-authored-by: F. Levi <[email protected]>
2 parents 6cd64e9 + 792860d commit 7b2054d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+6157
-6119
lines changed

.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,4 @@ module.exports = {
7979
},
8080
},
8181
],
82-
}
82+
};

.prettierrc.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
// https://prettier.io/docs/en/options.html
22

33
module.exports = {
4-
singleQuote: true,
5-
semi: false,
6-
trailingComma: 'es5',
74
plugins: ['./node_modules/prettier-plugin-jsdoc/dist/index.js'],
85
// https://github.com/hosseinmd/prettier-plugin-jsdoc#tsdoc
96
tsdoc: true,
10-
}
7+
};

jest-disable-built-in-fetch.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module.exports = function () {
22
// This is required for tests to work with "cross-fetch" on newer node versions,
33
// otherwise "cross-fetch" won't replace the builtin `fetch`
4-
globalThis.fetch = undefined
5-
}
4+
globalThis.fetch = undefined;
5+
};

jest.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@ const config = {
3737
testPathIgnorePatterns: ['meilisearch-test-utils', 'env/'],
3838
},
3939
],
40-
}
40+
};
4141

42-
module.exports = config
42+
module.exports = config;

playgrounds/javascript/src/app.js

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
import { MeiliSearch } from '../../../src'
1+
import { MeiliSearch } from '../../../src';
22

33
const config = {
44
host: 'http://127.0.0.1:7700',
55
apiKey: 'masterKey',
6-
}
6+
};
77

8-
const client = new MeiliSearch(config)
9-
const indexUid = 'movies'
8+
const client = new MeiliSearch(config);
9+
const indexUid = 'movies';
1010

1111
const addDataset = async () => {
12-
await client.deleteIndex(indexUid)
13-
const { taskUid } = await client.createIndex(indexUid)
14-
await client.index(indexUid).waitForTask(taskUid)
12+
await client.deleteIndex(indexUid);
13+
const { taskUid } = await client.createIndex(indexUid);
14+
await client.index(indexUid).waitForTask(taskUid);
1515

16-
const documents = await client.index(indexUid).getDocuments()
16+
const documents = await client.index(indexUid).getDocuments();
1717

1818
const dataset = [
1919
{ id: 1, title: 'Carol', genres: ['Romance', 'Drama'] },
@@ -26,35 +26,35 @@ const addDataset = async () => {
2626
},
2727
{ id: 5, title: 'Moana', genres: ['Fantasy', 'Action'] },
2828
{ id: 6, title: 'Philadelphia', genres: ['Drama'] },
29-
]
29+
];
3030
if (documents.results.length === 0) {
31-
const { taskUid } = await client.index(indexUid).addDocuments(dataset)
32-
await client.index(indexUid).waitForTask(taskUid)
31+
const { taskUid } = await client.index(indexUid).addDocuments(dataset);
32+
await client.index(indexUid).waitForTask(taskUid);
3333
}
34-
}
34+
};
3535

36-
;(async () => {
36+
(async () => {
3737
try {
38-
await addDataset()
39-
const indexes = await client.getRawIndexes()
38+
await addDataset();
39+
const indexes = await client.getRawIndexes();
4040
document.querySelector('.indexes').innerText = JSON.stringify(
4141
indexes,
4242
null,
43-
1
44-
)
43+
1,
44+
);
4545
const resp = await client.index(indexUid).search('', {
4646
attributesToHighlight: ['title'],
47-
})
48-
console.log({ resp })
49-
console.log({ hit: resp.hits[0] })
47+
});
48+
console.log({ resp });
49+
console.log({ hit: resp.hits[0] });
5050
document.querySelector('.hits').innerText = JSON.stringify(
5151
resp.hits.map((hit) => hit.title),
5252
null,
53-
1
54-
)
55-
document.querySelector('.errors_title').style.display = 'none'
53+
1,
54+
);
55+
document.querySelector('.errors_title').style.display = 'none';
5656
} catch (e) {
57-
console.error(e)
58-
document.querySelector('.errors').innerText = JSON.stringify(e, null, 1)
57+
console.error(e);
58+
document.querySelector('.errors').innerText = JSON.stringify(e, null, 1);
5959
}
60-
})()
60+
})();

rollup.config.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
const nodeResolve = require('@rollup/plugin-node-resolve')
2-
const { resolve } = require('path')
3-
const commonjs = require('@rollup/plugin-commonjs')
4-
const json = require('@rollup/plugin-json')
5-
const typescript = require('rollup-plugin-typescript2')
6-
const pkg = require('./package.json')
7-
const { terser } = require('rollup-plugin-terser')
8-
const { babel } = require('@rollup/plugin-babel')
1+
const nodeResolve = require('@rollup/plugin-node-resolve');
2+
const { resolve } = require('path');
3+
const commonjs = require('@rollup/plugin-commonjs');
4+
const json = require('@rollup/plugin-json');
5+
const typescript = require('rollup-plugin-typescript2');
6+
const pkg = require('./package.json');
7+
const { terser } = require('rollup-plugin-terser');
8+
const { babel } = require('@rollup/plugin-babel');
99

1010
function getOutputFileName(fileName, isProd = false) {
11-
return isProd ? fileName.replace(/\.js$/, '.min.js') : fileName
11+
return isProd ? fileName.replace(/\.js$/, '.min.js') : fileName;
1212
}
1313

14-
const env = process.env.NODE_ENV || 'development'
15-
const ROOT = resolve(__dirname, '.')
14+
const env = process.env.NODE_ENV || 'development';
15+
const ROOT = resolve(__dirname, '.');
1616

1717
const PLUGINS = [
1818
typescript({
@@ -23,7 +23,7 @@ const PLUGINS = [
2323
exclude: ['tests', 'examples', '*.js', 'scripts'],
2424
},
2525
}),
26-
]
26+
];
2727

2828
module.exports = [
2929
// browser-friendly UMD build
@@ -36,7 +36,7 @@ module.exports = [
3636
file: getOutputFileName(
3737
// will add .min. in filename if in production env
3838
resolve(ROOT, pkg.jsdelivr),
39-
env === 'production'
39+
env === 'production',
4040
),
4141
format: 'umd',
4242
sourcemap: env === 'production', // create sourcemap for error reporting in production mode
@@ -80,7 +80,7 @@ module.exports = [
8080
{
8181
file: getOutputFileName(
8282
resolve(ROOT, pkg.module),
83-
env === 'production'
83+
env === 'production',
8484
),
8585
exports: 'named',
8686
format: 'es',
@@ -101,11 +101,11 @@ module.exports = [
101101
file: getOutputFileName(
102102
// will add .min. in filename if in production env
103103
resolve(ROOT, pkg.main),
104-
env === 'production'
104+
env === 'production',
105105
),
106106
exports: 'named',
107107
format: 'cjs',
108108
},
109109
plugins: [...PLUGINS],
110110
},
111-
]
111+
];

scripts/build.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
/** This file only purpose is to execute any build related tasks */
22

3-
const { resolve, normalize } = require('path')
4-
const { readFileSync, writeFileSync } = require('fs')
5-
const pkg = require('../package.json')
3+
const { resolve, normalize } = require('path');
4+
const { readFileSync, writeFileSync } = require('fs');
5+
const pkg = require('../package.json');
66

7-
const ROOT = resolve(__dirname, '..')
8-
const TYPES_ROOT_FILE = resolve(ROOT, normalize(pkg.typings))
7+
const ROOT = resolve(__dirname, '..');
8+
const TYPES_ROOT_FILE = resolve(ROOT, normalize(pkg.typings));
99

10-
main()
10+
main();
1111

1212
function main() {
13-
writeDtsHeader()
13+
writeDtsHeader();
1414
}
1515

1616
function writeDtsHeader() {
@@ -19,10 +19,10 @@ function writeDtsHeader() {
1919
pkg.version,
2020
pkg.author,
2121
pkg.repository.url,
22-
pkg.devDependencies.typescript
23-
)
22+
pkg.devDependencies.typescript,
23+
);
2424

25-
prependFileSync(TYPES_ROOT_FILE, dtsHeader)
25+
prependFileSync(TYPES_ROOT_FILE, dtsHeader);
2626
}
2727

2828
/**
@@ -33,16 +33,16 @@ function writeDtsHeader() {
3333
* @param {string} tsVersion
3434
*/
3535
function getDtsHeader(pkgName, version, author, repoUrl, tsVersion) {
36-
const extractUserName = repoUrl.match(/\.com\/([\w-]+)\/\w+/i)
37-
const githubUserUrl = extractUserName ? extractUserName[1] : 'Unknown'
36+
const extractUserName = repoUrl.match(/\.com\/([\w-]+)\/\w+/i);
37+
const githubUserUrl = extractUserName ? extractUserName[1] : 'Unknown';
3838

3939
return `
4040
// Type definitions for ${pkgName} ${version}
4141
// Project: ${repoUrl}
4242
// Definitions by: ${author} <https://github.com/${githubUserUrl}>
4343
// Definitions: ${repoUrl}
4444
// TypeScript Version: ${tsVersion}
45-
`.replace(/^\s+/gm, '')
45+
`.replace(/^\s+/gm, '');
4646
}
4747

4848
/**
@@ -52,10 +52,10 @@ function getDtsHeader(pkgName, version, author, repoUrl, tsVersion) {
5252
function prependFileSync(path, data) {
5353
const existingFileContent = readFileSync(path, {
5454
encoding: 'utf8',
55-
})
56-
const newFileContent = [data, existingFileContent].join('\n')
55+
});
56+
const newFileContent = [data, existingFileContent].join('\n');
5757
writeFileSync(path, newFileContent, {
5858
flag: 'w+',
5959
encoding: 'utf8',
60-
})
60+
});
6161
}

scripts/file-size.js

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,50 @@
1-
const { basename, normalize } = require('path')
2-
const { readFile: readFileCb } = require('fs')
3-
const { promisify } = require('util')
4-
const readFile = promisify(readFileCb)
1+
const { basename, normalize } = require('path');
2+
const { readFile: readFileCb } = require('fs');
3+
const { promisify } = require('util');
4+
const readFile = promisify(readFileCb);
55

6-
const kolor = require('kleur')
7-
const prettyBytes = require('pretty-bytes')
8-
const brotliSize = require('brotli-size')
9-
const gzipSize = require('gzip-size')
10-
const { log } = console
11-
const pkg = require('../package.json')
6+
const kolor = require('kleur');
7+
const prettyBytes = require('pretty-bytes');
8+
const brotliSize = require('brotli-size');
9+
const gzipSize = require('gzip-size');
10+
const { log } = console;
11+
const pkg = require('../package.json');
1212

13-
main()
13+
main();
1414

1515
async function main() {
16-
const args = process.argv.splice(2)
17-
const filePaths = [...args.map(normalize)]
16+
const args = process.argv.splice(2);
17+
const filePaths = [...args.map(normalize)];
1818
const fileMetadata = await Promise.all(
1919
filePaths.map(async (filePath) => {
2020
return {
2121
path: filePath,
2222
blob: await readFile(filePath, { encoding: 'utf8' }),
23-
}
24-
})
25-
)
23+
};
24+
}),
25+
);
2626

2727
const output = await Promise.all(
28-
fileMetadata.map((metadata) => getSizeInfo(metadata.blob, metadata.path))
29-
)
28+
fileMetadata.map((metadata) => getSizeInfo(metadata.blob, metadata.path)),
29+
);
3030

31-
log(getFormatedOutput(pkg.name, output))
31+
log(getFormatedOutput(pkg.name, output));
3232
}
3333

3434
/**
3535
* @param {string} pkgName
3636
* @param {string[]} filesOutput
3737
*/
3838
function getFormatedOutput(pkgName, filesOutput) {
39-
const MAGIC_INDENTATION = 3
40-
const WHITE_SPACE = ' '.repeat(MAGIC_INDENTATION)
39+
const MAGIC_INDENTATION = 3;
40+
const WHITE_SPACE = ' '.repeat(MAGIC_INDENTATION);
4141

4242
return (
4343
kolor.blue(`${pkgName} bundle sizes: 📦`) +
4444
`\n${WHITE_SPACE}` +
4545
readFile.name +
4646
filesOutput.join(`\n${WHITE_SPACE}`)
47-
)
47+
);
4848
}
4949

5050
/**
@@ -54,13 +54,13 @@ function getFormatedOutput(pkgName, filesOutput) {
5454
* @param {boolean} raw
5555
*/
5656
function formatSize(size, filename, type, raw) {
57-
const pretty = raw ? `${size} B` : prettyBytes(size)
58-
const color = size < 5000 ? 'green' : size > 40000 ? 'red' : 'yellow'
59-
const MAGIC_INDENTATION = type === 'br' ? 13 : 10
57+
const pretty = raw ? `${size} B` : prettyBytes(size);
58+
const color = size < 5000 ? 'green' : size > 40000 ? 'red' : 'yellow';
59+
const MAGIC_INDENTATION = type === 'br' ? 13 : 10;
6060

6161
return `${' '.repeat(MAGIC_INDENTATION - pretty.length)}${kolor[color](
62-
pretty
63-
)}: ${kolor.white(basename(filename))}.${type}`
62+
pretty,
63+
)}: ${kolor.white(basename(filename))}.${type}`;
6464
}
6565

6666
/**
@@ -69,8 +69,8 @@ function formatSize(size, filename, type, raw) {
6969
* @param {boolean} [raw=false] Default is `false`
7070
*/
7171
async function getSizeInfo(code, filename, raw = false) {
72-
const isRaw = raw || code.length < 5000
73-
const gzip = formatSize(await gzipSize(code), filename, 'gz', isRaw)
74-
const brotli = formatSize(await brotliSize.sync(code), filename, 'br', isRaw)
75-
return gzip + '\n' + brotli
72+
const isRaw = raw || code.length < 5000;
73+
const gzip = formatSize(await gzipSize(code), filename, 'gz', isRaw);
74+
const brotli = formatSize(await brotliSize.sync(code), filename, 'br', isRaw);
75+
return gzip + '\n' + brotli;
7676
}

src/browser.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
export * from './types'
2-
export * from './errors'
3-
export * from './indexes'
4-
import { MeiliSearch } from './clients/browser-client'
1+
export * from './types';
2+
export * from './errors';
3+
export * from './indexes';
4+
import { MeiliSearch } from './clients/browser-client';
55

6-
export { MeiliSearch, MeiliSearch as Meilisearch }
7-
export default MeiliSearch
6+
export { MeiliSearch, MeiliSearch as Meilisearch };
7+
export default MeiliSearch;

src/clients/browser-client.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { Config } from '../types'
2-
import { Client } from './client'
1+
import { Config } from '../types';
2+
import { Client } from './client';
33

44
class MeiliSearch extends Client {
55
constructor(config: Config) {
6-
super(config)
6+
super(config);
77
}
88
}
99

10-
export { MeiliSearch }
10+
export { MeiliSearch };

0 commit comments

Comments
 (0)