Shared eslint config
@nextcloud/eslint-config"">
This is a package containing the unified global eslint config used by all nextcloud apps and libraries.
It contains the necessary dependencies and peerDependencies so that other apps cannot update if this config does not support it.
Please always use dependabot to update your apps, OR pay attention to the peer dependencies error messages!
npm install @nextcloud/eslint-config --save-dev
[!NOTE]
Since version 9 this package depends on ESLint 9, which uses the new flat config system.
This package provides some predefined configurations you can choose from.
For the recommended setup add a file eslint.config.js
in the root directory of your app repository with the following content:
import { recommended } from '@nextcloud/eslint-config'
export default [
...recommended,
]
Instead of the recommended
configuration this package also provides some alternatives, depending on your app setup you can also choose:
recommended
.vue
files will be handled as Typescript).recommendedJavascript
recommended
but Vue files (the script part) will be handled as Javascript.recommendedVue2
recommended
but Vue files are considered in Vue 2 syntax.recommendedVue2Javascript
recommended
but Vue files are considered in Vue 2 syntax and the script part will be handled as Javascript instead of Typescript.This configuration also provides some bundled plugins with new rules, those options are already included in the recommended configurations.
It is possible to override the recommended configurations:
// eslint.config.js
import { recommended } from '@nextcloud/eslint-config'
export default [
...recommended,
{
files: ['**/*.js'],
rules: {
// Make deprecations error instead of warning level
'@nextcloud/no-deprecations': ['error'],
}
}
]
You can even use the plugins without using the Nextcloud ESLint config:
// eslint.config.js
import { nextcloudPlugin } from '@nextcloud/eslint-config'
export default [
{
files: ['**/*.js'],
plugins: {
'@nextcloud': nextcloudPlugin,
},
rules: {
'@nextcloud/no-removed-apis': ['error', { targetVersion: '29.0.0' }],
},
}
]
package-json
pluginRules:
sort-package-json
package.json
is sorted in consistent ordererror
level in recommended configurations@nextcloud
pluginRules:
no-deprecations
warn
level in recommended configurationno-removed-apis
error
level in recommended configurationnpm version