Skip to content

Commit 99ca23b

Browse files
committed
test(lint): switch to eslint 9 and antfu config
1 parent f2578cb commit 99ca23b

File tree

170 files changed

+3944
-1879
lines changed

Some content is hidden

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

170 files changed

+3944
-1879
lines changed

.github/workflows/pr-title.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: "Check PR title"
1+
name: Check PR title
22

33
on:
44
pull_request_target:

.github/workflows/release-notes.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Create release
33
on:
44
push:
55
tags:
6-
- "v*" # Push events to matching v*, i.e. v1.0, v20.15.10
6+
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
77

88
jobs:
99
build:

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
node_modules/
33
dist/
44
cache/
5+
.eslintcache

eslint.config.mjs

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// eslint.config.mjs
2+
import antfu from '@antfu/eslint-config'
3+
4+
export default antfu({
5+
ignores: [
6+
'node_modules/',
7+
'dist/',
8+
'generated/',
9+
'!.*',
10+
'schema.graphql',
11+
'.test-todo/',
12+
'**/types/test/',
13+
],
14+
15+
rules: {
16+
'ts/no-use-before-define': 'warn',
17+
'unused-imports/no-unused-vars': 'warn',
18+
'accessor-pairs': 'off',
19+
},
20+
}, {
21+
files: [
22+
'packages/docs/**',
23+
],
24+
rules: {
25+
'no-dupe-keys': 'off',
26+
'no-new': 'off',
27+
'no-console': 'off',
28+
},
29+
}, {
30+
files: [
31+
'packages/test-*/**',
32+
'**/*.test.*',
33+
],
34+
rules: {
35+
'antfu/no-top-level-await': 'off',
36+
'no-console': 'off',
37+
'unused-imports/no-unused-vars': 'off',
38+
'node/prefer-global/process': 'off',
39+
'import/no-mutable-exports': 'off',
40+
},
41+
42+
languageOptions: {
43+
globals: {
44+
cy: false,
45+
expect: false,
46+
describe: false,
47+
it: false,
48+
before: false,
49+
},
50+
},
51+
}, {
52+
files: [
53+
'**/tests/types/**',
54+
],
55+
rules: {
56+
'ts/no-unused-expressions': 'off',
57+
},
58+
})

.eslintrc.js meow.eslintrc.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ module.exports = {
3737
'@typescript-eslint/no-use-before-define': 'off',
3838
'comma-dangle': ['error', 'always-multiline'],
3939
'vue/no-multiple-template-root': 'off',
40-
indent: 'off',
40+
'indent': 'off',
4141
'@typescript-eslint/indent': ['error', 2],
42-
quotes: ['error', 'single', { allowTemplateLiterals: true }],
42+
'quotes': ['error', 'single', { allowTemplateLiterals: true }],
4343
'no-use-before-define': 'warn',
4444
'accessor-pairs': 'off',
4545
'no-async-promise-executor': 'off',
@@ -73,7 +73,7 @@ module.exports = {
7373
'packages/*/types/test/**/*.ts',
7474
],
7575
rules: {
76-
camelcase: 'off',
76+
'camelcase': 'off',
7777
'no-unused-expressions': 'off',
7878
'array-callback-return': 'warn',
7979
},

package.json

+7-11
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,19 @@
22
"name": "vue-apollo-monorepo",
33
"version": "4.2.1",
44
"private": true,
5+
"packageManager": "pnpm@10.6.1+sha512.40ee09af407fa9fbb5fbfb8e1cb40fbb74c0af0c3e10e9224d7b53c7658528615b2c92450e74cfad91e3a2dcafe3ce4050d80bda71d757756d2ce2b66213e9a3",
56
"scripts": {
67
"build": "pnpm run -r --filter \"vue-apollo*\" --filter \"@vue/apollo*\" build",
78
"test": "pnpm run -r --sequential test",
89
"test:unit": "pnpm run -r test:unit",
910
"test:types": "pnpm run -r test:types",
10-
"lint": "eslint . --ext js,vue,ts",
11+
"lint": "eslint . --cache",
1112
"release": "pnpm run build && pnpm run test && sheep release -b v4",
1213
"docs:dev": "pnpm run -r --filter \"private-vue-apollo-docs\" dev"
1314
},
14-
"resolutions": {
15-
"js-yaml": "^3.13.1"
16-
},
1715
"devDependencies": {
1816
"@akryum/sheep": "^0.5.1",
17+
"@antfu/eslint-config": "^4.7.0",
1918
"@typescript-eslint/eslint-plugin": "^4.33.0",
2019
"@typescript-eslint/parser": "^4.33.0",
2120
"@vue/eslint-config-standard": "^6.1.0",
@@ -24,15 +23,9 @@
2423
"core-js": "^3.23.2",
2524
"esbuild": "^0.25.0",
2625
"esbuild-node-externals": "^1.18.0",
27-
"eslint": "^7.32.0",
28-
"eslint-plugin-import": "^2.26.0",
29-
"eslint-plugin-node": "^11.1.0",
30-
"eslint-plugin-promise": "^4.3.1",
31-
"eslint-plugin-standard": "^5.0.0",
32-
"eslint-plugin-vue": "^7.20.0",
26+
"eslint": "^9.21.0",
3327
"typescript": "^5.8.2"
3428
},
35-
"packageManager": "pnpm@10.6.1+sha512.40ee09af407fa9fbb5fbfb8e1cb40fbb74c0af0c3e10e9224d7b53c7658528615b2c92450e74cfad91e3a2dcafe3ce4050d80bda71d757756d2ce2b66213e9a3",
3629
"pnpm": {
3730
"overrides": {
3831
"eslint-scope": "^5",
@@ -58,5 +51,8 @@
5851
"vue": "*"
5952
}
6053
}
54+
},
55+
"resolutions": {
56+
"js-yaml": "^3.13.1"
6157
}
6258
}

packages/docs/package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
{
22
"name": "private-vue-apollo-docs",
3+
"type": "module",
34
"version": "4.0.0-alpha.16",
45
"private": true,
5-
"type": "module",
66
"scripts": {
77
"dev": "vitepress dev src",
88
"build": "vitepress build src"
99
},
10-
"devDependencies": {
11-
"vitepress": "^1.0.0-rc.36"
12-
},
1310
"dependencies": {
1411
"vue-github-button": "^3.0.3"
12+
},
13+
"devDependencies": {
14+
"vitepress": "^1.0.0-rc.36"
1515
}
1616
}

packages/docs/src/.vitepress/config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ export default defineConfig({
327327
},
328328

329329
locales: {
330-
root: {
330+
'root': {
331331
label: 'English',
332332
lang: 'en-US',
333333
title: 'Vue Apollo',

packages/docs/src/.vitepress/theme/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import './styles/index.pcss'
55

66
export default {
77
...DefaultTheme,
8-
enhanceApp ({ app }) {
8+
enhanceApp({ app }) {
99
app.component('SponsorButton', SponsorButton)
1010
},
1111
}

packages/docs/src/api/apollo-mutation.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ See [apollo context](https://www.apollographql.com/docs/react/api/link/apollo-li
209209
Signature:
210210

211211
```ts
212-
mutate(options = null): Promise<FetchResult>
212+
function mutate(options = null): Promise<FetchResult>
213213
```
214214

215215
- `options`: [mutation options](https://www.apollographql.com/docs/react/api/core/ApolloClient/#ApolloClient.mutate).

packages/docs/src/api/apollo-provider.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ const apolloProvider = createApolloProvider({
2626
},
2727
// Watch loading state for all queries
2828
// See 'Smart Query > options > watchLoading' for detail
29-
watchLoading (isLoading, countModifier) {
29+
watchLoading(isLoading, countModifier) {
3030
loading += countModifier
3131
console.log('Global loading', loading, countModifier)
3232
},
3333
// Global error handler for all smart queries and subscriptions
34-
errorHandler (error) {
34+
errorHandler(error) {
3535
console.log('Global error handler')
3636
console.error(error)
3737
},

packages/docs/src/api/smart-query.md

+58-52
Original file line numberDiff line numberDiff line change
@@ -24,61 +24,63 @@ Each query declared in the `apollo` definition (that is, which doesn't start wit
2424
Example:
2525

2626
```js
27+
export default {
2728
// Apollo-specific options
28-
apollo: {
29+
apollo: {
2930
// Advanced query with parameters
3031
// The 'variables' method is watched by vue
31-
pingMessage: {
32-
query: gql`query PingMessage($message: String!) {
32+
pingMessage: {
33+
query: gql`query PingMessage($message: String!) {
3334
ping(message: $message)
3435
}`,
35-
// Reactive parameters
36-
variables () {
36+
// Reactive parameters
37+
variables() {
3738
// Use vue reactive properties here
38-
return {
39-
message: this.pingInput,
40-
}
41-
},
42-
// Polling interval in milliseconds
43-
pollInterval: 10000,
44-
// Or, set polling interval as a vue reactive property
45-
pollInterval() {
46-
return this.pollInterval;
47-
},
48-
// Variables: deep object watch
49-
deep: false,
50-
// We use a custom update callback because
51-
// the field names don't match
52-
// By default, the 'pingMessage' attribute
53-
// would be used on the 'data' result object
54-
// Here we know the result is in the 'ping' attribute
55-
// considering the way the apollo server works
56-
update (data) {
57-
console.log(data)
58-
// The returned value will update
59-
// the vue property 'pingMessage'
60-
return data.ping
61-
},
62-
// Optional result hook
63-
result ({ data, loading, networkStatus }) {
64-
console.log('We got some result!')
65-
},
66-
// Error handling
67-
error (error) {
68-
console.error('We\'ve got an error!', error)
69-
},
70-
// Loading state
71-
// loadingKey is the name of the data property
72-
// that will be incremented when the query is loading
73-
// and decremented when it no longer is.
74-
loadingKey: 'loadingQueriesCount',
75-
// watchLoading will be called whenever the loading state changes
76-
watchLoading (isLoading, countModifier) {
39+
return {
40+
message: this.pingInput,
41+
}
42+
},
43+
// Polling interval in milliseconds
44+
pollInterval: 10000,
45+
// Or, set polling interval as a vue reactive property
46+
pollInterval() {
47+
return this.pollInterval
48+
},
49+
// Variables: deep object watch
50+
deep: false,
51+
// We use a custom update callback because
52+
// the field names don't match
53+
// By default, the 'pingMessage' attribute
54+
// would be used on the 'data' result object
55+
// Here we know the result is in the 'ping' attribute
56+
// considering the way the apollo server works
57+
update(data) {
58+
console.log(data)
59+
// The returned value will update
60+
// the vue property 'pingMessage'
61+
return data.ping
62+
},
63+
// Optional result hook
64+
result({ data, loading, networkStatus }) {
65+
console.log('We got some result!')
66+
},
67+
// Error handling
68+
error(error) {
69+
console.error('We\'ve got an error!', error)
70+
},
71+
// Loading state
72+
// loadingKey is the name of the data property
73+
// that will be incremented when the query is loading
74+
// and decremented when it no longer is.
75+
loadingKey: 'loadingQueriesCount',
76+
// watchLoading will be called whenever the loading state changes
77+
watchLoading(isLoading, countModifier) {
7778
// isLoading is a boolean
7879
// countModifier is either 1 or -1
80+
},
7981
},
8082
},
81-
},
83+
}
8284
```
8385

8486
If you use `ES2015`, you can also write the `update` like this:
@@ -90,14 +92,18 @@ update: data => data.ping
9092
Manual mode example:
9193

9294
```js
93-
{
94-
query: gql`...`,
95-
manual: true,
96-
result ({ data, loading }) {
97-
if (!loading) {
98-
this.items = data.items
95+
export default {
96+
apollo: {
97+
myQuery: {
98+
query: gql`...`,
99+
manual: true,
100+
result({ data, loading }) {
101+
if (!loading) {
102+
this.items = data.items
103+
}
104+
},
99105
}
100-
},
106+
}
101107
}
102108
```
103109

packages/docs/src/api/ssr.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const states = ApolloSSR.getStates(clientsObject, options)
1717
`options` defaults to:
1818

1919
```js
20-
{
20+
const defaultOptions = {
2121
// Prefix for the keys of each apollo client state
2222
exportNamespace: '',
2323
}
@@ -34,14 +34,14 @@ const js = ApolloSSR.exportStates(clientsObject, options)
3434
`options` defaults to:
3535

3636
```js
37-
{
37+
const defaultOptions = {
3838
// Global variable name
3939
globalName: '__APOLLO_STATE__',
4040
// Global object on which the variable is set
4141
attachTo: 'window',
4242
// Prefix for the keys of each apollo client state
4343
exportNamespace: '',
44-
// By default we use sanitize js library to prevent XSS
44+
// By default we use sanitize js library to prevent XSS
4545
// pass true here will perform a standard JSON.stringify on the states
4646
useUnsafeSerializer: false,
4747
}

packages/docs/src/api/use-lazy-query.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,16 @@ Extends [useQuery](./use-query.md)
1111
```js
1212
const { load, refetch } = useLazyQuery(query, variables, options)
1313

14-
function fetchOrRefetch () {
14+
function fetchOrRefetch() {
1515
load() || refetch()
1616
}
1717

18-
function waitForLoad () {
18+
async function waitForLoad() {
1919
try {
2020
const result = await load()
2121
// do something with result
22-
} catch (error) {
22+
}
23+
catch (error) {
2324
// handle error
2425
}
2526
}

0 commit comments

Comments
 (0)