Skip to content

feat!: Migrate to support ESLint v9 #223

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions .travis.yml

This file was deleted.

4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to this project will be documented in this file.

## 3.0.0 - unreleased
### Breaking
* Added ESLint v9 and flat config compatibility - ESLint v8 is no longer supported.

## 2.2.1 - 2024-04-21
### Fixed
* fix: Relax recommended config to work also with libraries \([\#180](https://github.com/nextcloud-libraries/eslint-plugin/pull/185)\)
Expand Down
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,6 @@ It is also possible to detect that your supported Nextcloud version from your `a

* `nextcloud/recommended`: Recommended configuration that loads the Nextcloud ESlint plugin, adds the Nextcloud environment and configures all recommended Nextcloud rules.


## Supported Environments

* `nextcloud/nextcloud`: Manifests global variables defined by Nextcloud server


## Supported Rules

* `nextcloud/no-deprecations`: Detects properties and functions that were deprecated in Nextcloud server
Expand Down
File renamed without changes.
4 changes: 4 additions & 0 deletions lib/configs/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { recommended } from './recommended'
import { recommendedWithGlobals } from './recommended-globals'

export default [recommended, recommendedWithGlobals]
28 changes: 28 additions & 0 deletions lib/configs/recommended-globals.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import type { ESLint } from 'eslint'

/**
* Similar to `@nextcloud/recommended` config, but additionally with global variables.
*/
export function recommendedWithGlobals(plugin: ESLint.Plugin) {
plugin.configs = plugin.configs ?? {}

plugin.configs['@nextcloud/recommended-legacy'] = {
name: '@nextcloud/recommended-globals',
languageOptions: {
globals: {
t: 'readonly',
n: 'readonly',
OC: 'readonly',
OCA: 'readonly',
OCP: 'readonly',
},
},
plugins: {
'@nextcloud': plugin,
},
rules: {
'@nextcloud/no-deprecations': ['warn'],
'@nextcloud/no-removed-apis': ['error'],
},
}
}
14 changes: 0 additions & 14 deletions lib/configs/recommended.js

This file was deleted.

20 changes: 20 additions & 0 deletions lib/configs/recommended.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import type { ESLint } from 'eslint'

/**
* The recommended plugin configuration for Nextcloud
*/
export function recommended(plugin: ESLint.Plugin) {
plugin.configs = plugin.configs ?? {}

// registering the configuration
plugin.configs['@nextcloud/recommended'] = {
name: '@nextcloud/recommended',
plugins: {
'@nextcloud': plugin,
},
rules: {
'@nextcloud/no-deprecations': ['warn'],
'@nextcloud/no-removed-apis': ['error'],
},
}
}
11 changes: 0 additions & 11 deletions lib/environments/nextcloud.js

This file was deleted.

6 changes: 6 additions & 0 deletions lib/globals.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
declare global {
// Injected by vite
const __PACKAGE_VERSION__: string
}

export {}
25 changes: 0 additions & 25 deletions lib/index.js

This file was deleted.

34 changes: 34 additions & 0 deletions lib/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: MIT
*/

import type { ESLint } from 'eslint'
import { rules } from './rules/index.ts'
import configs from './configs/index.ts'
import { Linter } from 'eslint/universal'

const plugin: ESLint.Plugin = {
// with ESLint flat configs this information needs to be provided manually by us
meta: {
name: '@nextcloud/eslint-plugin',
version: __PACKAGE_VERSION__,
},

configs: {
// empty as we need to prevent cyclic dependency between configs and the plugin
},

rules,
}

// Register the configs
// This is needed because they have cyclic dependencies on the plugin otherwise
configs.forEach((config) => config(plugin))

export default plugin as ESLint.Plugin & {
configs: {
recommended: Linter.Config,
'recommended-globals': Linter.Config,
},
}
8 changes: 8 additions & 0 deletions lib/rules/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import type { Rule } from 'eslint'
import noDeprecations from './no-deprecations.ts'
import noRemovedApis from './no-removed-apis.ts'

export const rules: Record<string, Rule.RuleModule> = {
'@nextcloud/no-deprecations': noDeprecations,
'@nextcloud/no-removed-apis': noRemovedApis,
}
188 changes: 0 additions & 188 deletions lib/rules/no-deprecations.js

This file was deleted.

Loading
Loading