Skip to content

Commit 4a2779b

Browse files
bors[bot]mdubus
andauthored
Merge #354
354: Configure prettier r=bidoubiwa a=mdubus ## What's wrong ? Prettier was installed but the rules weren't configured properly. There was different coding styles in different files. Lack of uniformity. ## What's inside this PR ? Edit of the configuration file, and formatting of every file regarding the same specification. Please take a look at the rules to see if it seems coherent to you 🙏 Co-authored-by: Morgane Dubus <[email protected]>
2 parents c79d7f7 + 5b68450 commit 4a2779b

25 files changed

+1390
-1390
lines changed

.babelrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"targets": {
77
"browsers": ["last 2 versions", "ie >= 9"]
88
}
9-
},
9+
}
1010
]
1111
],
1212
"env": {

.eslintignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,7 @@ coverage/
22
dist/
33
docs/dist
44
dist-es5-module/
5+
node_modules/
6+
assets
7+
.github
8+
scripts

.eslintrc.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
/* Using eslint-config-algolia */
22
/* eslint-disable import/no-commonjs */
33
module.exports = {
4-
extends: ['algolia', 'algolia/jest'],
4+
extends: ['algolia', 'algolia/jest', 'plugin:prettier/recommended'],
5+
plugins: ['prettier'],
56
rules: {
67
'no-console': 0,
78
'no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
89
'eslint-comments/disable-enable-pair': ['error', { allowWholeFile: true }],
10+
'prettier/prettier': [
11+
'error',
12+
{
13+
trailingComma: 'all',
14+
},
15+
],
916
},
10-
};
17+
}

.github/workflows/tests.yml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
strategy:
1616
fail-fast: false
1717
matrix:
18-
node: [ '12', '14' ]
18+
node: ['12', '14']
1919
name: Tests (Node.js ${{ matrix.node }})
2020
steps:
2121
- uses: actions/checkout@v2
@@ -34,12 +34,8 @@ jobs:
3434
name: linter-check
3535
runs-on: ubuntu-latest
3636
steps:
37-
- uses: actions/checkout@v2
38-
- name: Install dependencies
39-
run: yarn install
40-
- name: Run linter
41-
run: yarn run lint
42-
- name: Run prettier
43-
run: yarn run prettier-ci
44-
env:
45-
CI: true
37+
- uses: actions/checkout@v2
38+
- name: Install dependencies
39+
run: yarn install
40+
- name: Run linter
41+
run: yarn run lint

.prettierignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
**/.cache/
2+
.github/
3+
**/dist/

.prettierrc

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
{
2-
"overrides": [
3-
{
4-
"files": "*.scss",
5-
"options": {
6-
"singleQuote": true
7-
}
8-
}
9-
]
2+
"trailingComma": "all",
3+
"tabWidth": 2,
4+
"semi": false,
5+
"singleQuote": true
106
}

CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ yarn test:watch
7373
# Linter
7474
yarn lint
7575
# Linter with auto-correct
76-
yarn lint-fix
76+
yarn lint:fix
7777
# Prettier for Markdown (auto-correct)
7878
yarn format:md
7979
# Prettier for SCSS (auto-correct)
@@ -129,11 +129,11 @@ _[Read more about this](https://github.com/meilisearch/integration-guides/blob/m
129129
Make a PR modifying the files [`package.json`](/package.json) and [`src/lib/version.js`](/src/lib/version.js) with the right version.
130130

131131
```javascript
132-
"version": "X.X.X",
132+
'version': 'X.X.X',
133133
```
134134

135135
```javascript
136-
export default "X.X.X";
136+
export default 'X.X.X'
137137
```
138138

139139
Once the changes are merged on `main`, you can publish the current draft release via the [GitHub interface](https://github.com/meilisearch/docs-searchbar.js/releases).

README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,12 @@ If you already have your own scraper but you still want to use MeiliSearch and `
8080
<script src="https://cdn.jsdelivr.net/npm/docs-searchbar.js@{version}/dist/cdn/docs-searchbar.min.js"></script>
8181
<script>
8282
docsSearchBar({
83-
hostUrl: "https://mymeilisearch.com",
84-
apiKey: "XXX",
85-
indexUid: "docs",
86-
inputSelector: "#search-bar-input",
83+
hostUrl: 'https://mymeilisearch.com',
84+
apiKey: 'XXX',
85+
indexUid: 'docs',
86+
inputSelector: '#search-bar-input',
8787
debug: true, // Set debug to true if you want to inspect the dropdown
88-
});
88+
})
8989
</script>
9090
</body>
9191
</html>
@@ -107,7 +107,7 @@ Read more about [MeiliSearch authentication](https://docs.meilisearch.com/refere
107107
In an ES+ environment:
108108

109109
```js
110-
import "docs-searchbar.js/dist/cdn/docs-searchbar.css";
110+
import 'docs-searchbar.js/dist/cdn/docs-searchbar.css'
111111
```
112112

113113
In a `HTML` file, the `link` tag should be added in your header:
@@ -148,14 +148,14 @@ docsSearchBar({
148148
handleSelected: function (input, event, suggestion, datasetNumber, context) {
149149
// Prevents the default behavior on click and rather opens the suggestion
150150
// in a new tab.
151-
if (context.selectionMethod === "click") {
152-
input.setVal("");
151+
if (context.selectionMethod === 'click') {
152+
input.setVal('')
153153

154-
const windowReference = window.open(suggestion.url, "_blank");
155-
windowReference.focus();
154+
const windowReference = window.open(suggestion.url, '_blank')
155+
windowReference.focus()
156156
}
157157
},
158-
});
158+
})
159159
```
160160

161161
Note that, by default, you can already open a new tab thanks to the CMD/CTRL + Click action.
@@ -183,7 +183,7 @@ docsSearchBar({
183183
meilisearchOptions: {
184184
limit: 10,
185185
},
186-
});
186+
})
187187
```
188188

189189
##### More Examples <!-- omit in toc -->

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
import docsSearchBar from './src/lib/main';
1+
import docsSearchBar from './src/lib/main'
22

3-
export default docsSearchBar;
3+
export default docsSearchBar

jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ module.exports = {
44
resetMocks: true,
55
restoreMocks: true,
66
testPathIgnorePatterns: ['/node_modules/', '/dist/', '/docs/'],
7-
};
7+
}

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@
1717
"format:md": "prettier --write '**/*.md'",
1818
"playground": "yarn --cwd ./playgrounds/html && yarn --cwd ./playgrounds/html serve",
1919
"playground:js": "yarn --cwd ./playgrounds/javascript && yarn --cwd ./playgrounds/javascript serve",
20-
"lint": "eslint ./src ./*.js",
21-
"lint-fix": "eslint --fix ./src ./*.js",
22-
"prettier-ci": "prettier --check ./src/**/*.scss '**/*.md'",
20+
"lint": "eslint .",
21+
"lint:fix": "eslint --fix .",
2322
"test": "./scripts/test",
2423
"test:watch": "./scripts/test-watch"
2524
},

playgrounds/html/index.html

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,22 @@
44
<meta charset="utf-8" />
55
<meta name="color-scheme" content="dark light" />
66
<title>Docs SearchBar playground</title>
7-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/bootstrap/3.3.6/css/bootstrap.min.css" />
7+
<link
8+
rel="stylesheet"
9+
href="https://cdn.jsdelivr.net/bootstrap/3.3.6/css/bootstrap.min.css"
10+
/>
811
<link rel="stylesheet" href="../../src/styles/main.scss" />
912
</head>
1013
<body>
1114
<div class="container">
1215
<div class="col-md-12">
1316
<div class="searchbox">
14-
<input type="search" placeholder="docs-searchbar input" class="form-control" id="q">
17+
<input
18+
type="search"
19+
placeholder="docs-searchbar input"
20+
class="form-control"
21+
id="q"
22+
/>
1523
</div>
1624
</div>
1725
</div>
@@ -21,18 +29,19 @@
2129
docsSearchBar.default({
2230
// Test with MeiliSearch Documentation
2331
hostUrl: 'https://docs-search-bar.meilisearch.com',
24-
apiKey: 'd79226ae89f29d4dadba8d0c30c240e435f584fb83a7ae573b13eb62edec35cd',
32+
apiKey:
33+
'd79226ae89f29d4dadba8d0c30c240e435f584fb83a7ae573b13eb62edec35cd',
2534
indexUid: 'docs',
2635
inputSelector: '#q',
2736
handleSelected(input, event, suggestion, datasetNumber, context) {
28-
console.info(input);
29-
console.info(event);
30-
console.info(suggestion);
31-
console.info(datasetNumber);
32-
console.info(context);
37+
console.info(input)
38+
console.info(event)
39+
console.info(suggestion)
40+
console.info(datasetNumber)
41+
console.info(context)
3342
},
34-
debug: true // Set debug to true if you want to inspect the dropdown
35-
});
43+
debug: true, // Set debug to true if you want to inspect the dropdown
44+
})
3645
</script>
3746
<style>
3847
.container {

playgrounds/javascript/index.html

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,21 @@
44
<meta charset="utf-8" />
55
<meta name="color-scheme" content="dark light" />
66
<title>Docs SearchBar playground</title>
7-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/bootstrap/3.3.6/css/bootstrap.min.css" />
7+
<link
8+
rel="stylesheet"
9+
href="https://cdn.jsdelivr.net/bootstrap/3.3.6/css/bootstrap.min.css"
10+
/>
811
</head>
912
<body>
1013
<div class="container">
1114
<div class="col-md-12">
1215
<div class="searchbox">
13-
<input type="search" placeholder="docs-searchbar input" class="form-control" id="q">
16+
<input
17+
type="search"
18+
placeholder="docs-searchbar input"
19+
class="form-control"
20+
id="q"
21+
/>
1422
</div>
1523
</div>
1624
</div>

playgrounds/javascript/src/index.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import docsSearchBar from '../../../index';
2-
import '../../../src/styles/main.scss';
1+
import docsSearchBar from '../../../index'
2+
import '../../../src/styles/main.scss'
33

44
docsSearchBar({
55
// Test with MeiliSearch Documentation
@@ -8,11 +8,11 @@ docsSearchBar({
88
indexUid: 'docs',
99
inputSelector: '#q',
1010
handleSelected(input, event, suggestion, datasetNumber, context) {
11-
console.info(input);
12-
console.info(event);
13-
console.info(suggestion);
14-
console.info(datasetNumber);
15-
console.info(context);
11+
console.info(input)
12+
console.info(event)
13+
console.info(suggestion)
14+
console.info(datasetNumber)
15+
console.info(context)
1616
},
1717
debug: true, // Set debug to true if you want to inspect the dropdown
18-
});
18+
})

0 commit comments

Comments
 (0)