Skip to content

Commit

Permalink
style: enable trailingComma in prettier
Browse files Browse the repository at this point in the history
I think we don't have to strictly conform to the styles from vuejs/core,
so let's choose a style that better suited for this project.
  • Loading branch information
haoqunjiang committed Oct 25, 2024
1 parent dd60a39 commit 50d5e85
Show file tree
Hide file tree
Showing 30 changed files with 203 additions and 191 deletions.
4 changes: 1 addition & 3 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{
"semi": false,
"tabWidth": 2,
"singleQuote": true,
"printWidth": 100,
"trailingComma": "none"
"printWidth": 100
}
26 changes: 13 additions & 13 deletions __test__/renderEslint.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describe('renderEslint', () => {
needsVitest: false,
needsCypress: false,
needsCypressCT: false,
needsPlaywright: false
needsPlaywright: false,
})
expect(additionalConfigs).toStrictEqual([])
})
Expand All @@ -17,7 +17,7 @@ describe('renderEslint', () => {
needsVitest: true,
needsCypress: false,
needsCypressCT: false,
needsPlaywright: false
needsPlaywright: false,
})
expect(additionalConfigs).toHaveLength(1)
const [additionalVitestConfig] = additionalConfigs
Expand All @@ -34,19 +34,19 @@ describe('renderEslint', () => {
needsVitest: false,
needsCypress: true,
needsCypressCT: false,
needsPlaywright: false
needsPlaywright: false,
})
expect(additionalConfigs).toHaveLength(1)
const [additionalCypressConfig] = additionalConfigs
expect(additionalCypressConfig.devDependencies['eslint-plugin-cypress']).not.toBeUndefined()
expect(additionalCypressConfig.afterVuePlugin).toHaveLength(1)
const [additionalCypressPlugin] = additionalCypressConfig.afterVuePlugin!
expect(additionalCypressPlugin.importer).toBe(
"import pluginCypress from 'eslint-plugin-cypress/flat'"
"import pluginCypress from 'eslint-plugin-cypress/flat'",
)
expect(additionalCypressPlugin.content).toContain('...pluginCypress.configs.recommended')
expect(additionalCypressPlugin.content).toContain(
"'cypress/e2e/**/*.{cy,spec}.{js,ts,jsx,tsx}'"
"'cypress/e2e/**/*.{cy,spec}.{js,ts,jsx,tsx}'",
)
expect(additionalCypressPlugin.content).toContain("'cypress/support/**/*.{js,ts,jsx,tsx}'")
})
Expand All @@ -56,20 +56,20 @@ describe('renderEslint', () => {
needsVitest: false,
needsCypress: true,
needsCypressCT: true,
needsPlaywright: false
needsPlaywright: false,
})
expect(additionalConfigs).toHaveLength(1)
const [additionalCypressConfig] = additionalConfigs
expect(additionalCypressConfig.devDependencies['eslint-plugin-cypress']).not.toBeUndefined()
expect(additionalCypressConfig.afterVuePlugin).toHaveLength(1)
const [additionalCypressPlugin] = additionalCypressConfig.afterVuePlugin!
expect(additionalCypressPlugin.importer).toBe(
"import pluginCypress from 'eslint-plugin-cypress/flat'"
"import pluginCypress from 'eslint-plugin-cypress/flat'",
)
expect(additionalCypressPlugin.content).toContain('...pluginCypress.configs.recommended')
expect(additionalCypressPlugin.content).toContain("'**/__tests__/*.{cy,spec}.{js,ts,jsx,tsx}'")
expect(additionalCypressPlugin.content).toContain(
"'cypress/e2e/**/*.{cy,spec}.{js,ts,jsx,tsx}'"
"'cypress/e2e/**/*.{cy,spec}.{js,ts,jsx,tsx}'",
)
expect(additionalCypressPlugin.content).toContain("'cypress/support/**/*.{js,ts,jsx,tsx}'")
})
Expand All @@ -79,23 +79,23 @@ describe('renderEslint', () => {
needsVitest: false,
needsCypress: false,
needsCypressCT: false,
needsPlaywright: true
needsPlaywright: true,
})
expect(additionalConfigs).toHaveLength(1)
const [additionalPlaywrightConfig] = additionalConfigs
expect(
additionalPlaywrightConfig.devDependencies['eslint-plugin-playwright']
additionalPlaywrightConfig.devDependencies['eslint-plugin-playwright'],
).not.toBeUndefined()
expect(additionalPlaywrightConfig.afterVuePlugin).toHaveLength(1)
const [additionalPlaywrightPlugin] = additionalPlaywrightConfig.afterVuePlugin!
expect(additionalPlaywrightPlugin.importer).toBe(
"import pluginPlaywright from 'eslint-plugin-playwright'"
"import pluginPlaywright from 'eslint-plugin-playwright'",
)
expect(additionalPlaywrightPlugin.content).toContain(
"...pluginPlaywright.configs['flat/recommended']"
"...pluginPlaywright.configs['flat/recommended']",
)
expect(additionalPlaywrightPlugin.content).toContain(
"files: ['e2e/**/*.{test,spec}.{js,ts,jsx,tsx}']"
"files: ['e2e/**/*.{test,spec}.{js,ts,jsx,tsx}']",
)
})
})
12 changes: 6 additions & 6 deletions __test__/sortDependencies.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describe('sortDependencies', () => {
dependencies: {
vue: '^3.3.4',
'vue-router': '^4.2.5',
pinia: '^2.1.7'
pinia: '^2.1.7',
},
devDependencies: {
'@vitejs/plugin-vue-jsx': '^3.0.2',
Expand All @@ -20,14 +20,14 @@ describe('sortDependencies', () => {
'@vitejs/plugin-vue': '^4.4.0',
'eslint-plugin-cypress': '^2.15.1',
'eslint-plugin-vue': '^9.17.0',
vitest: '^0.34.6'
}
vitest: '^0.34.6',
},
}
expect(sortDependencies(packageJson)).toStrictEqual({
dependencies: {
pinia: '^2.1.7',
vue: '^3.3.4',
'vue-router': '^4.2.5'
'vue-router': '^4.2.5',
},
devDependencies: {
'@vitejs/plugin-vue': '^4.4.0',
Expand All @@ -40,8 +40,8 @@ describe('sortDependencies', () => {
jsdom: '^22.1.0',
'start-server-and-test': '^2.0.1',
vite: '^4.4.11',
vitest: '^0.34.6'
}
vitest: '^0.34.6',
},
})
})
})
Loading

0 comments on commit 50d5e85

Please sign in to comment.