Skip to content

Commit

Permalink
Add eslint-plugin-promise back (woodpecker-ci#4022)
Browse files Browse the repository at this point in the history
  • Loading branch information
qwerty287 authored and 6543 committed Sep 5, 2024
1 parent f145bf7 commit d41acd4
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 159 deletions.
76 changes: 34 additions & 42 deletions web/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import antfu from '@antfu/eslint-config';
import js from '@eslint/js';
import vueI18n from '@intlify/eslint-plugin-vue-i18n';
import eslintPromise from 'eslint-plugin-promise';
import eslintPluginVueScopedCSS from 'eslint-plugin-vue-scoped-css';

export default antfu(
Expand All @@ -20,54 +21,17 @@ export default antfu(
},

js.configs.recommended,
// eslintPromise.configs.recommended,

// TypeScript
//...tseslint.configs.recommended,
//...tseslint.configs.recommendedTypeChecked,
//...tseslint.configs.strictTypeChecked,
//...tseslint.configs.stylisticTypeChecked,
eslintPromise.configs['flat/recommended'],
...eslintPluginVueScopedCSS.configs['flat/recommended'],
...vueI18n.configs['flat/recommended'],

{
rules: {
'import/order': 'off',
'sort-imports': 'off',
},
},

...eslintPluginVueScopedCSS.configs['flat/recommended'],

// Vue
{
files: ['**/*.vue'],
rules: {
'vue/multi-word-component-names': 'off',
'vue/html-self-closing': [
'error',
{
html: {
void: 'always',
normal: 'always',
component: 'always',
},
svg: 'always',
math: 'always',
},
],
'vue/block-order': [
'error',
{
order: ['template', 'script', 'style'],
},
],
'vue/singleline-html-element-content-newline': ['off'],
},
},
'promise/prefer-await-to-callbacks': 'error',

// Vue I18n
...vueI18n.configs['flat/recommended'],
{
rules: {
// Vue I18n
'@intlify/vue-i18n/no-raw-text': [
'error',
{
Expand All @@ -93,6 +57,7 @@ export default antfu(
'@intlify/vue-i18n/sfc-locale-attr': 'error',
},
settings: {
// Vue I18n
'vue-i18n': {
localeDir: './src/assets/locales/en.json',
// Specify the version of `vue-i18n` you are using.
Expand All @@ -102,6 +67,33 @@ export default antfu(
},
},

// Vue
{
files: ['**/*.vue'],
rules: {
'vue/multi-word-component-names': 'off',
'vue/html-self-closing': [
'error',
{
html: {
void: 'always',
normal: 'always',
component: 'always',
},
svg: 'always',
math: 'always',
},
],
'vue/block-order': [
'error',
{
order: ['template', 'script', 'style'],
},
],
'vue/singleline-html-element-content-newline': ['off'],
},
},

// Ignore list
{
ignores: [
Expand Down
3 changes: 1 addition & 2 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,13 @@
"@vue/compiler-sfc": "^3.4.27",
"@vue/test-utils": "^2.4.6",
"eslint": "^9.4.0",
"eslint-plugin-promise": "^6.2.0",
"eslint-plugin-promise": "^7.0.0",
"eslint-plugin-vue-scoped-css": "^2.8.0",
"jsdom": "^24.1.0",
"prettier": "^3.3.0",
"replace-in-file": "^8.0.0",
"tinycolor2": "^1.6.0",
"typescript": "5.5.4",
"typescript-eslint": "^7.12.0",
"vite": "^5.2.12",
"vite-plugin-prismjs": "^0.0.11",
"vite-plugin-windicss": "^1.9.3",
Expand Down
118 changes: 10 additions & 108 deletions web/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion web/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const apiClient = useApiClient();
const { notify } = useNotifications();
const i18n = useI18n();
// TODO reenable with eslint-plugin-promise eslint-disable-next-line promise/prefer-await-to-callbacks
// eslint-disable-next-line promise/prefer-await-to-callbacks
apiClient.setErrorHandler((err) => {
if (err.status === 404) {
notify({ title: i18n.t('errors.not_found'), type: 'error' });
Expand Down
4 changes: 2 additions & 2 deletions web/src/compositions/usePaginate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ async function waitForState<T>(ref: Ref<T>, expected: T): Promise<void> {
});
}

// TODO enable again with eslint-plugin-promise eslint-disable-next-line promise/prefer-await-to-callbacks
// eslint-disable-next-line promise/prefer-await-to-callbacks
export const mountComposition = (cb: () => void) => {
const wrapper = shallowMount({
setup() {
// TODO enable again with eslint-plugin-promise eslint-disable-next-line promise/prefer-await-to-callbacks
// eslint-disable-next-line promise/prefer-await-to-callbacks
cb();
return {};
},
Expand Down
2 changes: 1 addition & 1 deletion web/src/lib/api/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export default class ApiClient {
const events = new EventSource(_path);
events.onmessage = (event) => {
const data = JSON.parse(event.data as string) as T;
// TODO enable again with eslint-plugin-promise eslint-disable-next-line promise/prefer-await-to-callbacks
// eslint-disable-next-line promise/prefer-await-to-callbacks
callback(data);
};

Expand Down
4 changes: 2 additions & 2 deletions web/src/lib/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ export default class WoodpeckerClient extends ApiClient {
return this._post(`/api/repos/repair`);
}

// TODO enable again with eslint-plugin-promise eslint-disable-next-line promise/prefer-await-to-callbacks
// eslint-disable-next-line promise/prefer-await-to-callbacks
on(callback: (data: { pipeline?: Pipeline; repo?: Repo }) => void): EventSource {
return this._subscribe('/api/stream/events', callback, {
reconnect: true,
Expand All @@ -409,7 +409,7 @@ export default class WoodpeckerClient extends ApiClient {
repoId: number,
pipeline: number,
step: number,
// TODO enable again with eslint-plugin-promise eslint-disable-next-line promise/prefer-await-to-callbacks
// eslint-disable-next-line promise/prefer-await-to-callbacks
callback: (data: PipelineLog) => void,
): EventSource {
return this._subscribe(`/api/stream/logs/${repoId}/${pipeline}/${step}`, callback, {
Expand Down
Loading

0 comments on commit d41acd4

Please sign in to comment.