Skip to content

Commit c368ae8

Browse files
committed
Update Prettier and ESLint, adapt code
1 parent 3d10392 commit c368ae8

Some content is hidden

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

59 files changed

+1048
-1813
lines changed

.changeset/bright-rabbits-juggle.md

Lines changed: 0 additions & 7 deletions
This file was deleted.

.changeset/strong-dodos-carry.md

Lines changed: 0 additions & 6 deletions
This file was deleted.

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ jobs:
165165
- name: Install dependencies
166166
run: yarn install
167167
- name: Tests style
168-
run: yarn lint
168+
run: yarn style
169169
- name: Yaml Style
170170
uses: ibiqlik/action-yamllint@v3
171171
with:

.prettierrc.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// https://prettier.io/docs/en/options.html
2+
3+
export default {
4+
plugins: ['./node_modules/prettier-plugin-jsdoc/dist/index.js'],
5+
// https://github.com/hosseinmd/prettier-plugin-jsdoc#tsdoc
6+
tsdoc: true,
7+
// TODO: Remove everything underneath and remove .editorconfig!
8+
singleQuote: true,
9+
arrowParens: 'always',
10+
semi: false,
11+
bracketSpacing: true,
12+
trailingComma: 'es5',
13+
printWidth: 80,
14+
}

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ yarn test
4545
# End-to-end tests
4646
yarn test:e2e
4747
# Linter
48-
yarn lint
48+
yarn style
4949
# Linter with fixing
50-
yarn lint:fix
50+
yarn style:fix
5151
# Build the project
5252
yarn build
5353
```

eslint.config.js

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
import eslint from '@eslint/js'
2+
import tseslint from 'typescript-eslint'
3+
import tsdoc from 'eslint-plugin-tsdoc'
4+
import vitest from '@vitest/eslint-plugin'
5+
import globals from 'globals'
6+
import prettier from 'eslint-config-prettier'
7+
import pluginCypress from 'eslint-plugin-cypress/flat'
8+
9+
// TODO: Vue,React
10+
export default tseslint.config([
11+
{ ignores: ['{packages,playgrounds}/*/dist/', 'coverage/'] },
12+
eslint.configs.recommended,
13+
{
14+
files: ['**/*.{js,cjs,mjs}'],
15+
languageOptions: { globals: globals.node },
16+
},
17+
// TSDoc
18+
{
19+
// TODO: Ignore test files
20+
files: ['packages/*/src/**/*.ts'],
21+
plugins: { tsdoc },
22+
rules: { 'tsdoc/syntax': 'off' },
23+
},
24+
// Cypress
25+
{
26+
files: [
27+
'playgrounds/{autocomplete,local-react}/cypress/integration/*.spec.js',
28+
],
29+
extends: [pluginCypress.configs.recommended],
30+
// TODO: Remove rules
31+
rules: {
32+
'cypress/no-unnecessary-waiting': 'off',
33+
'cypress/unsafe-to-chain-command': 'off',
34+
},
35+
},
36+
// TypeScript
37+
{
38+
files: ['**/*.ts'],
39+
extends: [tseslint.configs.recommendedTypeChecked],
40+
languageOptions: {
41+
parserOptions: {
42+
projectService: true,
43+
tsconfigRootDir: import.meta.dirname,
44+
},
45+
},
46+
rules: {
47+
// TODO: Remove the ones between "~~", adapt code
48+
// ~~
49+
'@typescript-eslint/ban-ts-comment': 'off',
50+
'@typescript-eslint/no-unnecessary-type-assertion': 'off',
51+
'@typescript-eslint/no-unsafe-call': 'off',
52+
'@typescript-eslint/no-unsafe-member-access': 'off',
53+
'@typescript-eslint/no-unsafe-return': 'off',
54+
'@typescript-eslint/no-unsafe-assignment': 'off',
55+
'@typescript-eslint/no-unsafe-argument': 'off',
56+
'@typescript-eslint/no-redundant-type-constituents': 'off',
57+
// ~~
58+
'@typescript-eslint/array-type': ['off', { default: 'array-simple' }],
59+
// TODO: Should be careful with this rule, should leave it be and disable
60+
// it within files where necessary with explanations
61+
'@typescript-eslint/no-explicit-any': 'off',
62+
'@typescript-eslint/no-unused-vars': [
63+
'error',
64+
// argsIgnorePattern: https://eslint.org/docs/latest/rules/no-unused-vars#argsignorepattern
65+
// varsIgnorePattern: https://eslint.org/docs/latest/rules/no-unused-vars#varsignorepattern
66+
{ args: 'all', argsIgnorePattern: '^_', varsIgnorePattern: '^_' },
67+
],
68+
},
69+
},
70+
// Vitest
71+
{
72+
files: ['packages/*/{src,__tests__}/**/*.test.ts'],
73+
extends: [vitest.configs.recommended],
74+
// TODO: Remove rules
75+
rules: {
76+
'vitest/no-identical-title': 'off',
77+
'vitest/valid-title': 'off',
78+
},
79+
},
80+
// Disable any style linting, as prettier takes care of that separately
81+
prettier,
82+
])

package.json

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,12 @@
2020
"playground:autocomplete": "turbo @meilisearch/autocomplete-playground#dev",
2121
"test:e2e": "turbo test:e2e",
2222
"test:e2e:watch": "turbo test:e2e:watch",
23-
"lint": "turbo lint",
24-
"lint:fix": "turbo lint:fix",
23+
"fmt": "prettier -c ./**/*.{js,ts}",
24+
"fmt:fix": "prettier -w ./**/*.{js,ts}",
25+
"lint": "eslint",
26+
"lint:fix": "eslint --fix",
27+
"style": "yarn fmt && yarn lint",
28+
"style:fix": "yarn fmt:fix && yarn lint:fix",
2529
"build": "turbo build",
2630
"test": "yarn build && vitest run",
2731
"test:watch": "yarn build && vitest",
@@ -32,8 +36,6 @@
3236
"release": "yarn build && changeset publish"
3337
},
3438
"devDependencies": {
35-
"instantsearch.css": "^8.5.1",
36-
"prettier": "^3.4.2",
3739
"vite": "^6.0.9",
3840
"@vitest/coverage-v8": "^3.0.2",
3941
"concurrently": "^9.1.2",
@@ -45,7 +47,19 @@
4547
"typescript": "^5.7.3",
4648
"@algolia/client-search": "^5.19.0",
4749
"algoliasearch": "^5.19.0",
48-
"search-insights": "^2.17.3"
50+
"search-insights": "^2.17.3",
51+
"prettier": "^3.4.2",
52+
"prettier-plugin-jsdoc": "^1.3.0",
53+
"@eslint/js": "^9.16.0",
54+
"@types/eslint__js": "^8.42.3",
55+
"eslint": "^9.16.0",
56+
"eslint-plugin-tsdoc": "^0.4.0",
57+
"@vitest/eslint-plugin": "^1.1.23",
58+
"eslint-config-prettier": "^9.1.0",
59+
"@typescript-eslint/utils": "^8.19.0",
60+
"globals": "^15.14.0",
61+
"typescript-eslint": "^8.19.0",
62+
"eslint-plugin-cypress":"^4.1.0"
4963
},
5064
"packageManager": "[email protected]"
5165
}

packages/autocomplete-client/package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
},
99
"scripts": {
1010
"build": "vite build && tsc -p tsconfig.json",
11-
"lint": "eslint --ext .js,.ts,.tsx .",
12-
"lint:fix": "eslint --ext .js,.ts,.tsx . --fix",
1311
"version": "node scripts/update_version.cjs"
1412
},
1513
"type": "module",
@@ -48,7 +46,6 @@
4846
"devDependencies": {
4947
"@algolia/autocomplete-js": "^1.7.4",
5048
"cssnano": "^4.1.10",
51-
"eslint-config-meilisearch": "*",
5249
"instantsearch.js": "^4.56.2"
5350
}
5451
}
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import { PACKAGE_VERSION } from '../package-version.js'
22
import { createSearchClient } from './createSearchClient.js'
33

4-
/**
5-
* Create searchClient instance for autocomplete
6-
*/
4+
/** Create searchClient instance for autocomplete */
75
const userAgent = `Meilisearch autocomplete-client (v${PACKAGE_VERSION})`
86
export const meilisearchAutocompleteClient = createSearchClient({ userAgent })

packages/autocomplete-client/src/client/createSearchClient.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ export const concatUserAgents = (clientAgents: string[]): string[] => {
66
return clientAgents.concat(clientAgents.filter((agent) => agent))
77
}
88

9-
/**
10-
* Create a searchClient instance
11-
*/
9+
/** Create a searchClient instance */
1210
export function createSearchClient({ userAgent }: { userAgent: string }) {
1311
return ({
1412
url,

0 commit comments

Comments
 (0)