Skip to content

Commit 93d6565

Browse files
authored
Merge pull request #97 from sectsect/feature/migrate-eslint-flat-config
chore: replace renamed package eslint-plugin-vitest with @vitest/eslint-plugin
2 parents a9cf308 + a1611fa commit 93d6565

File tree

4 files changed

+57
-29
lines changed

4 files changed

+57
-29
lines changed

eslint.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import _import from 'eslint-plugin-import';
2121
import prettier from 'eslint-plugin-prettier';
2222
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
2323
import testingLibrary from 'eslint-plugin-testing-library';
24-
import vitest from 'eslint-plugin-vitest';
24+
import vitest from '@vitest/eslint-plugin';
2525
import deprecation from 'eslint-plugin-deprecation';
2626
// import nextPlugin from '@next/eslint-plugin-next';
2727
import pluginQuery from '@tanstack/eslint-plugin-query';

includes/index.php

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,14 +564,45 @@ function ajax_wto_options(): void {
564564
add_action( 'wp_ajax_wto_options', 'ajax_wto_options' );
565565
add_action( 'wp_ajax_nopriv_wto_options', 'ajax_wto_options' );
566566

567+
/**
568+
* Sanitizes the enabled taxonomies setting.
569+
*
570+
* @param mixed $value The value to sanitize.
571+
* @return array<string> Sanitized array of taxonomy names.
572+
*/
573+
function wpto_sanitize_enabled_taxonomies( $value ): array {
574+
if ( ! is_array( $value ) ) {
575+
return array();
576+
}
577+
578+
$sanitized = array();
579+
foreach ( $value as $taxonomy ) {
580+
$taxonomy = wpto_cast_mixed_to_string( $taxonomy );
581+
// Ensure the taxonomy exists and is registered.
582+
if ( taxonomy_exists( sanitize_key( $taxonomy ) ) ) {
583+
$sanitized[] = sanitize_key( $taxonomy );
584+
}
585+
}
586+
587+
return $sanitized;
588+
}
589+
567590
/**
568591
* Registers the plugin settings.
569592
* This function registers settings that can be configured from the plugin's options page.
570593
*
571594
* @return void
572595
*/
573596
function register_wpto_settings(): void {
574-
register_setting( 'wpto-settings-group', 'wpto_enabled_taxonomies' );
597+
register_setting(
598+
'wpto-settings-group',
599+
'wpto_enabled_taxonomies',
600+
array(
601+
'type' => 'array',
602+
'sanitize_callback' => 'wpto_sanitize_enabled_taxonomies',
603+
'default' => array(),
604+
)
605+
);
575606
}
576607

577608
/**

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"@types/webpack-bundle-analyzer": "^4.7.0",
3838
"@typescript-eslint/eslint-plugin": "^6.21.0",
3939
"@typescript-eslint/parser": "^6.21.0",
40+
"@vitest/eslint-plugin": "^1.1.25",
4041
"css-loader": "^7.1.2",
4142
"eslint": "^8.57.1",
4243
"eslint-config-airbnb": "^19.0.4",
@@ -54,7 +55,6 @@
5455
"eslint-plugin-testing-library": "^7.1.1",
5556
"eslint-plugin-tsdoc": "^0.2.17",
5657
"eslint-plugin-unused-imports": "^3.2.0",
57-
"eslint-plugin-vitest": "^0.5.4",
5858
"eslint-rspack-plugin": "^4.2.1",
5959
"fork-ts-checker-notifier-webpack-plugin": "^9.0.0",
6060
"fork-ts-checker-webpack-plugin": "^9.0.2",

pnpm-lock.yaml

Lines changed: 23 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)