Skip to content
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

[chore] migrate from eslint/prettier to biome #955

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
7 changes: 4 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ To edit the Kotlin files, open `example/android` in Android studio and find the
As of the latest update, `com.reactnativemenu.MenuViewManager` has been refactored into an abstract base class, `MenuViewManagerBase`. Any React Native version-dependent changes should be implemented in the specific version folders under `reactNativeVersionPatch`.

For consistency:

- When making version-specific modifications, ensure you update the appropriate implementation of `MenuViewManager`:
- `src/reactNativeVersionPatch/75/MenuViewManager.kt` for React Native < 0.76
- `src/reactNativeVersionPatch/latest/MenuViewManager.kt` for React Native >= 0.76
Expand All @@ -81,9 +82,9 @@ Our pre-commit hooks verify that your commit message matches this format when co

### Linting and tests

[ESLint](https://eslint.org/), [Prettier](https://prettier.io/), [TypeScript](https://www.typescriptlang.org/)
[Biome](https://biomejs.dev/), [TypeScript](https://www.typescriptlang.org/)

We use [TypeScript](https://www.typescriptlang.org/) for type checking, [ESLint](https://eslint.org/) with [Prettier](https://prettier.io/) for linting and formatting the code, and [Jest](https://jestjs.io/) for testing.
We use [TypeScript](https://www.typescriptlang.org/) for type checking, [Biome](https://biomejs.dev/) for linting and formatting the code, and [Jest](https://jestjs.io/) for testing.

Our pre-commit hooks verify that the linter and tests pass when committing.

Expand All @@ -93,7 +94,7 @@ The `package.json` file contains various scripts for common tasks:

- `yarn bootstrap`: setup project by installing all dependencies and pods.
- `yarn typescript`: type-check files with TypeScript.
- `yarn lint`: lint files with ESLint.
- `yarn lint`: lint files with Biome.
- `yarn test`: run unit tests with Jest.
- `yarn start`: start the Metro server for the example app.
- `yarn android`: run the example app on Android.
Expand Down
2 changes: 1 addition & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
presets: ['module:@react-native/babel-preset'],
presets: ["module:@react-native/babel-preset"],
};
30 changes: 30 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"vcs": {
"enabled": false,
"clientKind": "git",
"useIgnoreFile": false
},
"files": {
"ignoreUnknown": false,
"ignore": ["lib"]
},
"formatter": {
"enabled": true,
"indentStyle": "tab"
},
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
}
},
"javascript": {
"formatter": {
"quoteStyle": "double"
}
}
}
45 changes: 15 additions & 30 deletions example/app.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,17 @@
{
"name": "MenuExample",
"displayName": "MenuExample",
"components": [
{
"appKey": "MenuExample",
"displayName": "MenuExample"
}
],
"resources": {
"android": [
"dist/res",
"dist/main.android.jsbundle"
],
"ios": [
"dist/assets",
"dist/main.ios.jsbundle"
],
"macos": [
"dist/assets",
"dist/main.macos.jsbundle"
],
"visionos": [
"dist/assets",
"dist/main.visionos.jsbundle"
],
"windows": [
"dist/assets",
"dist/main.windows.bundle"
]
}
"name": "MenuExample",
"displayName": "MenuExample",
"components": [
{
"appKey": "MenuExample",
"displayName": "MenuExample"
}
],
"resources": {
"android": ["dist/res", "dist/main.android.jsbundle"],
"ios": ["dist/assets", "dist/main.ios.jsbundle"],
"macos": ["dist/assets", "dist/main.macos.jsbundle"],
"visionos": ["dist/assets", "dist/main.visionos.jsbundle"],
"windows": ["dist/assets", "dist/main.windows.bundle"]
}
}
2 changes: 1 addition & 1 deletion example/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
presets: ['module:@react-native/babel-preset'],
presets: ["module:@react-native/babel-preset"],
};
6 changes: 3 additions & 3 deletions example/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AppRegistry } from 'react-native';
import { App } from './src/App';
import { name as appName } from './app.json';
import { AppRegistry } from "react-native";
import { App } from "./src/App";
import { name as appName } from "./app.json";

AppRegistry.registerComponent(appName, () => App);
174 changes: 174 additions & 0 deletions example/src/App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
import { jsx as _jsx } from "react/jsx-runtime";
import * as React from "react";
import { Platform, StyleSheet, Text, View } from "react-native";
import { MenuView } from "@react-native-menu/menu";
export const App = () => {
const [themeVariant] = React.useState("light");
return (_jsx(View, { style: styles.container, children: _jsx(MenuView, { title: "Menu Title", onPressAction: ({ nativeEvent }) => {
console.warn(JSON.stringify(nativeEvent));
}, actions: [
{
id: "add",
title: "Add to List",
titleColor: "#2367A2",
image: Platform.select({
ios: "plus",
android: "ic_menu_add",
}),
imageColor: "#2367A2",
subactions: [
{
id: "nested1",
title: "Nested action",
titleColor: "rgba(250,180,100,0.5)",
subtitle: "State is mixed",
image: Platform.select({
ios: "heart.fill",
android: "ic_menu_today",
}),
imageColor: "rgba(100,200,250,0.3)",
state: "mixed",
},
{
id: "nestedDestructive",
title: "Destructive Action",
attributes: {
destructive: true,
},
image: Platform.select({
ios: "trash",
android: "ic_menu_delete",
}),
},
],
},
{
id: "share",
title: "Share Action",
titleColor: "#46F289",
subtitle: "Share action on SNS",
image: Platform.select({
ios: "square.and.arrow.up",
android: "ic_menu_share",
}),
imageColor: "#46F289",
state: "on",
},
{
id: "mixed",
title: "Mixed State",
titleColor: "rgba(100,200,250,0.3)",
subtitle: "State is mixed",
image: Platform.select({
ios: "heart.fill",
android: "ic_menu_today",
}),
imageColor: "rgba(100,200,250,0.3)",
state: "mixed",
subactions: [
{
id: "nested2",
title: "Nested action",
titleColor: "rgba(250,180,100,0.5)",
subtitle: "State is mixed",
image: Platform.select({
ios: "tray",
android: "ic_menu_agenda",
}),
imageColor: "rgba(100,200,250,0.3)",
state: "mixed",
},
{
id: "nestedMixed",
title: "Mixed State",
subtitle: "State is mixed",
image: Platform.select({
ios: "heart.fill",
android: "ic_menu_today",
}),
imageColor: "#46F289",
subactions: [
{
id: "nestednesteddisabled",
title: "Disabled Action",
subtitle: "Action is disabled",
attributes: {
disabled: true,
},
image: Platform.select({
ios: "tray",
android: "ic_menu_agenda",
}),
},
{
id: "nestednestedhidden",
title: "Hidden Action",
subtitle: "Action is hidden",
attributes: {
hidden: true,
},
},
{
id: "nestednesteddestructive",
title: "Destructive Action",
attributes: {
destructive: true,
},
image: Platform.select({
ios: "trash",
android: "ic_menu_delete",
}),
},
],
},
],
},
{
id: "disabled",
title: "Disabled Action",
subtitle: "Action is disabled",
attributes: {
disabled: true,
},
image: Platform.select({
ios: "tray",
android: "ic_menu_agenda",
}),
},
{
id: "hidden",
title: "Hidden Action",
subtitle: "Action is hidden",
attributes: {
hidden: true,
},
},
{
id: "destructive",
title: "Destructive Action",
attributes: {
destructive: true,
},
image: Platform.select({
ios: "trash",
android: "ic_menu_delete",
}),
},
], shouldOpenOnLongPress: true, themeVariant: themeVariant, testID: "menuView", children: _jsx(View, { style: styles.button, children: _jsx(Text, { style: styles.buttonText, children: "Test" }) }) }) }));
};
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: "center",
justifyContent: "center",
},
button: {
height: 100,
width: 100,
backgroundColor: "red",
borderRadius: 50,
justifyContent: "center",
alignItems: "center",
},
buttonText: { color: "white" },
});
Loading
Loading