diff --git a/.changeset/shared-jsx-boolean.md b/.changeset/shared-jsx-boolean.md
new file mode 100644
index 00000000..8b860748
--- /dev/null
+++ b/.changeset/shared-jsx-boolean.md
@@ -0,0 +1,9 @@
+---
+'@frontify/eslint-config-react': patch
+'@frontify/eslint-plugin': patch
+'@frontify/oxlint-config-react': minor
+---
+
+Share the JSX boolean shorthand rule between ESLint and Oxlint. Oxlint now reports explicit `={true}` on JSX props as an error. Use the prop name alone, such as ``.
+
+Load the recommended JSX accessibility rules from the installed plugin's current configuration export.
diff --git a/packages/eslint-config-react/eslint.config.mjs b/packages/eslint-config-react/eslint.config.mjs
index b5b6ab98..c668cb9e 100644
--- a/packages/eslint-config-react/eslint.config.mjs
+++ b/packages/eslint-config-react/eslint.config.mjs
@@ -1,20 +1,19 @@
// @ts-check
import eslintPluginReact from '@eslint-react/eslint-plugin';
-import eslintReactKit from '@eslint-react/kit';
import basicConfig from '@frontify/eslint-config-basic';
+import frontifyPlugin from '@frontify/eslint-plugin';
import { defineConfig } from 'eslint/config';
-// @ts-expect-error No types available
import eslintPluginJsxA11yX from 'eslint-plugin-jsx-a11y-x';
-import { jsxShorthandBoolean } from './rules/jsx-shorthand-boolean.mjs';
-
export default defineConfig(
basicConfig,
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-argument
- eslintPluginJsxA11yX.flatConfigs.recommended,
+ eslintPluginJsxA11yX.configs.recommended,
eslintPluginReact.configs['recommended-type-checked'],
- eslintReactKit().use(jsxShorthandBoolean).getConfig(),
+ {
+ // Keep existing rule overrides and suppressions valid.
+ plugins: { '@eslint-react/kit': frontifyPlugin },
+ },
{
files: ['**/*.{js,mjs,cjs,jsx,ts,tsx,mts,cts}'],
languageOptions: {
diff --git a/packages/eslint-config-react/package.json b/packages/eslint-config-react/package.json
index d6bba8ba..78587f44 100644
--- a/packages/eslint-config-react/package.json
+++ b/packages/eslint-config-react/package.json
@@ -11,12 +11,10 @@
},
"main": "eslint.config.mjs",
"files": [
- "rules",
"eslint.config.mjs"
],
"scripts": {
"lint": "eslint .",
- "test": "node --test 'rules/**/*.test.mjs'",
"typecheck": "tsc --noEmit"
},
"peerDependencies": {
@@ -27,8 +25,8 @@
},
"dependencies": {
"@eslint-react/eslint-plugin": "^5.8.9",
- "@eslint-react/kit": "^5.8.9",
"@frontify/eslint-config-basic": "workspace:^",
+ "@frontify/eslint-plugin": "workspace:^",
"eslint-plugin-jsx-a11y-x": "^0.2.0",
"globals": "^17.6.0",
"typescript-eslint": "^8.60.0"
diff --git a/packages/eslint-config-react/rules/jsx-shorthand-boolean.mjs b/packages/eslint-config-react/rules/jsx-shorthand-boolean.mjs
deleted file mode 100644
index 260ec009..00000000
--- a/packages/eslint-config-react/rules/jsx-shorthand-boolean.mjs
+++ /dev/null
@@ -1,25 +0,0 @@
-/* (c) Copyright Frontify Ltd., all rights reserved. */
-
-// @ts-check
-
-/** @returns {import('@eslint-react/kit').RuleFunction} */
-export function jsxShorthandBoolean() {
- return (context) => ({
- JSXAttribute(node) {
- const { value } = node;
- if (
- // eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison
- value?.type === 'JSXExpressionContainer' &&
- // eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison
- value.expression.type === 'Literal' &&
- 'value' in value.expression &&
- value.expression.value === true
- ) {
- context.report({
- node,
- message: 'Use shorthand syntax for boolean JSX props instead of `={true}`.',
- });
- }
- },
- });
-}
diff --git a/packages/eslint-plugin/index.mjs b/packages/eslint-plugin/index.mjs
new file mode 100644
index 00000000..e34f3da8
--- /dev/null
+++ b/packages/eslint-plugin/index.mjs
@@ -0,0 +1,12 @@
+/* (c) Copyright Frontify Ltd., all rights reserved. */
+
+import jsxShorthandBoolean from './rules/jsx-shorthand-boolean.mjs';
+
+export default {
+ meta: {
+ name: '@frontify/eslint-plugin',
+ },
+ rules: {
+ 'jsx-shorthand-boolean': jsxShorthandBoolean,
+ },
+};
diff --git a/packages/eslint-plugin/package.json b/packages/eslint-plugin/package.json
new file mode 100644
index 00000000..6118364f
--- /dev/null
+++ b/packages/eslint-plugin/package.json
@@ -0,0 +1,29 @@
+{
+ "name": "@frontify/eslint-plugin",
+ "type": "module",
+ "version": "0.0.1",
+ "description": "Shared Frontify lint rules for ESLint and Oxlint",
+ "author": "Frontify Developers ",
+ "license": "MIT",
+ "repository": {
+ "directory": "packages/eslint-plugin",
+ "type": "git",
+ "url": "https://github.com/Frontify/code-style"
+ },
+ "exports": {
+ ".": "./index.mjs"
+ },
+ "files": [
+ "index.mjs",
+ "rules/jsx-shorthand-boolean.mjs"
+ ],
+ "scripts": {
+ "test": "node --test 'rules/**/*.test.mjs'"
+ },
+ "devDependencies": {
+ "eslint": "^10.4.1"
+ },
+ "publishConfig": {
+ "access": "public"
+ }
+}
diff --git a/packages/eslint-plugin/rules/jsx-shorthand-boolean.mjs b/packages/eslint-plugin/rules/jsx-shorthand-boolean.mjs
new file mode 100644
index 00000000..9cad70be
--- /dev/null
+++ b/packages/eslint-plugin/rules/jsx-shorthand-boolean.mjs
@@ -0,0 +1,30 @@
+/* (c) Copyright Frontify Ltd., all rights reserved. */
+
+// @ts-check
+
+const EXPLICIT_TRUE_PROP =
+ 'JSXAttribute[value.type="JSXExpressionContainer"][value.expression.type="Literal"][value.expression.value=true]';
+const SHORTHAND_MESSAGE_ID = 'shorthand';
+
+/** @satisfies {import('eslint').Rule.RuleModule} */
+const jsxShorthandBoolean = {
+ meta: {
+ schema: [],
+ messages: {
+ [SHORTHAND_MESSAGE_ID]: 'Use shorthand syntax for boolean JSX props instead of `={true}`.',
+ },
+ },
+ create(context) {
+ return {
+ /**
+ * Reports the explicit JSX prop.
+ * @param {import('eslint').JSSyntaxElement} node - The attribute matched by the selector.
+ */
+ [EXPLICIT_TRUE_PROP](node) {
+ context.report({ node, messageId: SHORTHAND_MESSAGE_ID });
+ },
+ };
+ },
+};
+
+export default jsxShorthandBoolean;
diff --git a/packages/eslint-config-react/rules/jsx-shorthand-boolean.test.mjs b/packages/eslint-plugin/rules/jsx-shorthand-boolean.test.mjs
similarity index 72%
rename from packages/eslint-config-react/rules/jsx-shorthand-boolean.test.mjs
rename to packages/eslint-plugin/rules/jsx-shorthand-boolean.test.mjs
index 51b7b2a0..bb40c30b 100644
--- a/packages/eslint-config-react/rules/jsx-shorthand-boolean.test.mjs
+++ b/packages/eslint-plugin/rules/jsx-shorthand-boolean.test.mjs
@@ -1,9 +1,9 @@
-import eslintReactKit from '@eslint-react/kit';
+/* (c) Copyright Frontify Ltd., all rights reserved. */
+
import { RuleTester } from 'eslint';
-import { jsxShorthandBoolean } from './jsx-shorthand-boolean.mjs';
+import plugin from '../index.mjs';
-const plugin = eslintReactKit().use(jsxShorthandBoolean).getPlugin();
const rule = plugin.rules['jsx-shorthand-boolean'];
const ruleTester = new RuleTester({
@@ -15,7 +15,12 @@ const ruleTester = new RuleTester({
});
ruleTester.run('jsx-shorthand-boolean', rule, {
- valid: [{ code: '' }, { code: '' }, { code: '' }],
+ valid: [
+ { code: '' },
+ { code: '' },
+ { code: '' },
+ { code: '' },
+ ],
invalid: [
{
code: '',
diff --git a/packages/oxlint-config-react/index.mjs b/packages/oxlint-config-react/index.mjs
index 651fa3f7..c94d1176 100644
--- a/packages/oxlint-config-react/index.mjs
+++ b/packages/oxlint-config-react/index.mjs
@@ -1,5 +1,7 @@
/* (c) Copyright Frontify Ltd., all rights reserved. */
+import { fileURLToPath } from 'node:url';
+
import basicConfig from '@frontify/oxlint-config-basic';
import { defineConfig } from 'oxlint';
@@ -152,14 +154,15 @@ export default defineConfig({
'jsx-a11y/tabindex-no-positive': 'error',
},
overrides: [
- // TODO: fix me when the kit plugin can be loaded in oxlint
- // {
- // files: ['**/*.{js,jsx,cjs,mjs,ts,tsx,cts,mts}'],
- // jsPlugins: ['@eslint-react/kit'],
- // rules: {
- // '@eslint-react/kit/jsx-shorthand-boolean': 'error',
- // },
- // },
+ {
+ files: ['**/*.{js,jsx,cjs,mjs,ts,tsx,cts,mts}'],
+ jsPlugins: [
+ { name: '@frontify', specifier: fileURLToPath(import.meta.resolve('@frontify/eslint-plugin')) },
+ ],
+ rules: {
+ '@frontify/jsx-shorthand-boolean': 'error',
+ },
+ },
{
files: ['**/*.{js,jsx,ts,tsx}'],
jsPlugins: ['@eslint-react/eslint-plugin'],
diff --git a/packages/oxlint-config-react/package.json b/packages/oxlint-config-react/package.json
index bf00d043..2483b741 100644
--- a/packages/oxlint-config-react/package.json
+++ b/packages/oxlint-config-react/package.json
@@ -22,7 +22,7 @@
},
"dependencies": {
"@eslint-react/eslint-plugin": "^5.8.9",
- "@eslint-react/kit": "^5.8.9",
+ "@frontify/eslint-plugin": "workspace:^",
"@frontify/oxlint-config-basic": "workspace:^"
},
"publishConfig": {
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index e3090e90..ad1e7bc1 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -105,12 +105,12 @@ importers:
'@eslint-react/eslint-plugin':
specifier: ^5.8.9
version: 5.8.9(eslint@10.4.1(jiti@2.7.0))(typescript@6.0.3)
- '@eslint-react/kit':
- specifier: ^5.8.9
- version: 5.8.9(eslint@10.4.1(jiti@2.7.0))(typescript@6.0.3)
'@frontify/eslint-config-basic':
specifier: workspace:^
version: link:../eslint-config-basic
+ '@frontify/eslint-plugin':
+ specifier: workspace:^
+ version: link:../eslint-plugin
eslint-plugin-jsx-a11y-x:
specifier: ^0.2.0
version: 0.2.0(eslint@10.4.1(jiti@2.7.0))
@@ -134,6 +134,12 @@ importers:
specifier: ^6.0.3
version: 6.0.3
+ packages/eslint-plugin:
+ devDependencies:
+ eslint:
+ specifier: ^10.4.1
+ version: 10.4.1(jiti@2.7.0)
+
packages/oxfmt-config:
dependencies:
oxfmt:
@@ -169,9 +175,9 @@ importers:
'@eslint-react/eslint-plugin':
specifier: ^5.8.9
version: 5.8.9(eslint@10.4.1(jiti@2.7.0))(typescript@6.0.3)
- '@eslint-react/kit':
- specifier: ^5.8.9
- version: 5.8.9(eslint@10.4.1(jiti@2.7.0))(typescript@6.0.3)
+ '@frontify/eslint-plugin':
+ specifier: workspace:^
+ version: link:../eslint-plugin
'@frontify/oxlint-config-basic':
specifier: workspace:^
version: link:../oxlint-config-basic
@@ -336,13 +342,6 @@ packages:
eslint: ^10.3.0
typescript: '*'
- '@eslint-react/kit@5.8.9':
- resolution: {integrity: sha512-5++nkmc7P7vFFylKbAQLtg+vCvNrw0iqDJOMrcMjgEdjAbsPlU33EacyAurhKPjzBjVtJPNf5nUPDlbCaBaX6A==}
- engines: {node: '>=22.0.0'}
- peerDependencies:
- eslint: ^10.3.0
- typescript: '*'
-
'@eslint-react/shared@5.8.9':
resolution: {integrity: sha512-1+mLQWz+lfntQxdoKzLglle7zEYSwQaJh9kvqDvOkUMjRYHoKBG8QrcudwwzVLsy6E55uFJAA7peXirtGYV6Sw==}
engines: {node: '>=22.0.0'}
@@ -2488,19 +2487,6 @@ snapshots:
transitivePeerDependencies:
- supports-color
- '@eslint-react/kit@5.8.9(eslint@10.4.1(jiti@2.7.0))(typescript@6.0.3)':
- dependencies:
- '@eslint-react/ast': 5.8.9(eslint@10.4.1(jiti@2.7.0))(typescript@6.0.3)
- '@eslint-react/core': 5.8.9(eslint@10.4.1(jiti@2.7.0))(typescript@6.0.3)
- '@eslint-react/shared': 5.8.9(eslint@10.4.1(jiti@2.7.0))(typescript@6.0.3)
- '@typescript-eslint/types': 8.60.0
- '@typescript-eslint/utils': 8.60.0(eslint@10.4.1(jiti@2.7.0))(typescript@6.0.3)
- eslint: 10.4.1(jiti@2.7.0)
- string-ts: 2.3.1
- typescript: 6.0.3
- transitivePeerDependencies:
- - supports-color
-
'@eslint-react/shared@5.8.9(eslint@10.4.1(jiti@2.7.0))(typescript@6.0.3)':
dependencies:
'@eslint-react/eslint': 5.8.9(eslint@10.4.1(jiti@2.7.0))(typescript@6.0.3)