diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index d9784d96a..000000000 --- a/.eslintrc.js +++ /dev/null @@ -1,80 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2024 LibreCode coop and contributors - * SPDX-License-Identifier: AGPL-3.0-or-later - */ -module.exports = { - globals: { - appName: true, - }, - extends: [ - '@nextcloud', - ], - rules: { - // production only - 'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'warn', - 'vue/no-unused-components': process.env.NODE_ENV === 'production' ? 'error' : 'warn', - 'import/order': [ - 'error', - { - groups: ['builtin', 'external', 'internal', ['parent', 'sibling', 'index'], 'unknown'], - pathGroups: [ - { - // group all style imports at the end - pattern: '{*.css,*.scss}', - patternOptions: { matchBase: true }, - group: 'unknown', - position: 'after', - }, - { - // group material design icons - pattern: 'vue-material-design-icons/**', - group: 'external', - position: 'after', - }, - { - // group @nextcloud imports - pattern: '@nextcloud/{!(vue),!(vue)/**}', - group: 'external', - position: 'after', - }, - { - // group @nextcloud/vue imports - pattern: '{@nextcloud/vue,@nextcloud/vue/**}', - group: 'external', - position: 'after', - }, - { - // group project components - pattern: '*.vue', - patternOptions: { matchBase: true }, - group: 'parent', - position: 'before', - }, - ], - pathGroupsExcludedImportTypes: ['@nextcloud', 'vue-material-design-icons'], - 'newlines-between': 'always', - alphabetize: { - order: 'asc', - caseInsensitive: true, - }, - warnOnUnassignedImports: true, - }, - ], - 'import/no-unresolved': ['error', { - // Ignore Webpack query parameters, not supported by eslint-plugin-import - // https://github.com/import-js/eslint-plugin-import/issues/2562 - ignore: ['\\?raw$'], - }], - }, - overrides: [ - { - files: ['src/types/openapi/*.ts'], - rules: { - '@typescript-eslint/no-explicit-any': 'off', - quotes: 'off', - 'no-multiple-empty-lines': 'off', - 'no-use-before-define': 'off', - }, - }, - ], -} diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 000000000..db96bf43e --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,98 @@ +/** + * SPDX-FileCopyrightText: 2024 LibreCode coop and contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +import nextcloudConfig from '@nextcloud/eslint-config' +import globals from 'globals' + +export default [ + ...(Array.isArray(nextcloudConfig) ? nextcloudConfig : [nextcloudConfig]), + + { + name: 'libresign/ignores', + ignores: [ + // Generated files + 'src/types/openapi/*', + 'js/*', + // Build artifacts + 'build/*', + // Node modules + 'node_modules/*', + // TODO: upstream + 'openapi-*.json', + ], + }, + + { + name: 'libresign/config', + rules: { + // production only + 'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'warn', + 'vue/no-unused-components': process.env.NODE_ENV === 'production' ? 'error' : 'warn', + 'import/order': [ + 'error', + { + groups: ['builtin', 'external', 'internal', ['parent', 'sibling', 'index'], 'unknown'], + pathGroups: [ + { + // group all style imports at the end + pattern: '{*.css,*.scss}', + patternOptions: { matchBase: true }, + group: 'unknown', + position: 'after', + }, + { + // group material design icons + pattern: 'vue-material-design-icons/**', + group: 'external', + position: 'after', + }, + { + // group @nextcloud imports + pattern: '@nextcloud/{!(vue),!(vue)/**}', + group: 'external', + position: 'after', + }, + { + // group @nextcloud/vue imports + pattern: '{@nextcloud/vue,@nextcloud/vue/**}', + group: 'external', + position: 'after', + }, + { + // group project components + pattern: '*.vue', + patternOptions: { matchBase: true }, + group: 'parent', + position: 'before', + }, + ], + pathGroupsExcludedImportTypes: ['@nextcloud', 'vue-material-design-icons'], + 'newlines-between': 'always', + alphabetize: { + order: 'asc', + caseInsensitive: true, + }, + warnOnUnassignedImports: true, + }, + ], + 'import/no-unresolved': ['error', { + // Ignore Webpack query parameters, not supported by eslint-plugin-import + // https://github.com/import-js/eslint-plugin-import/issues/2562 + ignore: ['\\?raw$'], + }], + }, + }, + + { + name: 'libresign/openapi-overrides', + files: ['src/types/openapi/*.ts'], + rules: { + '@typescript-eslint/no-explicit-any': 'off', + quotes: 'off', + 'no-multiple-empty-lines': 'off', + 'no-use-before-define': 'off', + }, + }, +] diff --git a/package.json b/package.json index d7aa212a1..eb3954fbd 100644 --- a/package.json +++ b/package.json @@ -11,8 +11,8 @@ "serve": "webpack serve --node-env development --progress --allowed-hosts all --host 0.0.0.0", "typescript:check": "tsc --noEmit", "typescript:generate": "npx openapi-typescript -t", - "lint": "eslint --ext .js,.vue src", - "lint:fix": "eslint --ext .js,.vue src --fix", + "lint": "eslint", + "lint:fix": "eslint --fix", "stylelint": "stylelint css/*.css css/*.scss src/**/*.scss src/**/*.vue", "stylelint:fix": "stylelint css/*.css css/*.scss src/**/*.scss src/**/*.vue --fix", "test": "jest",