Skip to content

Commit 2168751

Browse files
authored
Merge pull request #104 from gmsgowtham/rome
Rome
2 parents 9e5decc + 99ccb52 commit 2168751

29 files changed

+1753
-2469
lines changed

CONTRIBUTING.md

+6-5
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ To run the example app on iOS:
3333
yarn example ios
3434
```
3535

36-
Make sure your code passes TypeScript and ESLint. Run the following to verify:
36+
Make sure your code passes TypeScript and Lint. Run the following to verify:
3737

3838
```sh
3939
yarn typescript
@@ -43,7 +43,7 @@ yarn lint
4343
To fix formatting errors, run the following:
4444

4545
```sh
46-
yarn lint --fix
46+
yarn format
4747
```
4848

4949
Remember to add tests for your change if possible. Run the unit tests by:
@@ -67,9 +67,9 @@ Our pre-commit hooks verify that your commit message matches this format when co
6767

6868
### Linting and tests
6969

70-
[ESLint](https://eslint.org/), [Prettier](https://prettier.io/), [TypeScript](https://www.typescriptlang.org/)
70+
[Rome](https://rome.tools/), [TypeScript](https://www.typescriptlang.org/)
7171

72-
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.
72+
We use [TypeScript](https://www.typescriptlang.org/) for type checking, [Rome](https://rome.tools/) for linting and formatting the code, and [Jest](https://jestjs.io/) for testing.
7373

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

@@ -89,7 +89,8 @@ The `package.json` file contains various scripts for common tasks:
8989

9090
- `yarn bootstrap`: setup project by installing all dependencies and pods.
9191
- `yarn typescript`: type-check files with TypeScript.
92-
- `yarn lint`: lint files with ESLint.
92+
- `yarn lint`: lint files with Rome.
93+
- `yarn format`: format files with Rome
9394
- `yarn test`: run unit tests with Jest.
9495
- `yarn example start`: start the Metro server for the example app.
9596
- `yarn example android`: run the example app on Android.

babel.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module.exports = {
2-
presets: ['module:metro-react-native-babel-preset'],
2+
presets: ["module:metro-react-native-babel-preset"],
33
};
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
1-
/* eslint-disable @typescript-eslint/no-var-requires */
2-
const path = require('path');
3-
const pak = require('../../package.json');
1+
const path = require("path");
2+
const pak = require("../../package.json");
43

54
module.exports = function (api) {
6-
api.cache(true);
5+
api.cache(true);
76

8-
return {
9-
presets: ['babel-preset-expo'],
10-
plugins: [
11-
[
12-
'module-resolver',
13-
{
14-
extensions: ['.tsx', '.ts', '.js', '.json'],
15-
alias: {
16-
// For development, we want to alias the library to the source
17-
[pak.name]: path.join(__dirname, '..', '..', pak.source),
18-
},
19-
},
20-
],
21-
],
22-
};
7+
return {
8+
presets: ["babel-preset-expo"],
9+
plugins: [
10+
[
11+
"module-resolver",
12+
{
13+
extensions: [".tsx", ".ts", ".js", ".json"],
14+
alias: {
15+
// For development, we want to alias the library to the source
16+
[pak.name]: path.join(__dirname, "..", "..", pak.source),
17+
},
18+
},
19+
],
20+
],
21+
};
2322
};

examples/react-native-marked-sample/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { registerRootComponent } from 'expo';
1+
import { registerRootComponent } from "expo";
22

3-
import App from './src/App';
3+
import App from "./src/App";
44

55
// registerRootComponent calls AppRegistry.registerComponent('main', () => App);
66
// It also ensures that whether you load the app in the Expo client or in a native build,
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,40 @@
1-
/* eslint-disable @typescript-eslint/no-var-requires */
2-
const path = require('path');
3-
const escape = require('escape-string-regexp');
4-
const { getDefaultConfig } = require('@expo/metro-config');
5-
const exclusionList = require('metro-config/src/defaults/exclusionList');
6-
const pak = require('../../package.json');
1+
const path = require("path");
2+
const escapeString = require("escape-string-regexp");
3+
const { getDefaultConfig } = require("@expo/metro-config");
4+
const exclusionList = require("metro-config/src/defaults/exclusionList");
5+
const pak = require("../../package.json");
76

8-
const root = path.resolve(__dirname, '../..');
7+
const root = path.resolve(__dirname, "../..");
98

109
const modules = Object.keys({
11-
...pak.peerDependencies,
10+
...pak.peerDependencies,
1211
});
1312

1413
const defaultConfig = getDefaultConfig(__dirname);
1514

1615
module.exports = {
17-
...defaultConfig,
18-
19-
projectRoot: __dirname,
20-
watchFolders: [root],
21-
22-
// We need to make sure that only one version is loaded for peerDependencies
23-
// So we block them at the root, and alias them to the versions in example's node_modules
24-
resolver: {
25-
...defaultConfig.resolver,
26-
27-
blacklistRE: exclusionList(
28-
modules.map(
29-
(m) =>
30-
new RegExp(`^${escape(path.join(root, 'node_modules', m))}\\/.*$`)
31-
)
32-
),
33-
34-
extraNodeModules: modules.reduce((acc, name) => {
35-
acc[name] = path.join(__dirname, 'node_modules', name);
36-
return acc;
37-
}, {}),
38-
},
16+
...defaultConfig,
17+
18+
projectRoot: __dirname,
19+
watchFolders: [root],
20+
21+
// We need to make sure that only one version is loaded for peerDependencies
22+
// So we block them at the root, and alias them to the versions in example's node_modules
23+
resolver: {
24+
...defaultConfig.resolver,
25+
26+
blacklistRE: exclusionList(
27+
modules.map(
28+
(m) =>
29+
new RegExp(
30+
`^${escapeString(path.join(root, "node_modules", m))}\\/.*$`,
31+
),
32+
),
33+
),
34+
35+
extraNodeModules: modules.reduce((acc, name) => {
36+
acc[name] = path.join(__dirname, "node_modules", name);
37+
return acc;
38+
}, {}),
39+
},
3940
};
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
1-
import * as React from 'react';
1+
import * as React from "react";
22
import {
3-
SafeAreaView,
4-
StyleSheet,
5-
StatusBar,
6-
useColorScheme,
7-
} from 'react-native';
8-
import Markdown from 'react-native-marked';
3+
SafeAreaView,
4+
StyleSheet,
5+
StatusBar,
6+
useColorScheme,
7+
} from "react-native";
8+
import Markdown from "react-native-marked";
99

10-
import { MD_STRING } from './const';
10+
import { MD_STRING } from "./const";
1111

1212
export default function App() {
13-
const theme = useColorScheme();
14-
const isLightTheme = theme === 'light';
15-
return (
16-
<>
17-
<StatusBar
18-
barStyle={isLightTheme ? 'dark-content' : 'light-content'}
19-
backgroundColor={isLightTheme ? '#fff' : '#000'}
20-
/>
21-
<SafeAreaView>
22-
<Markdown
23-
value={MD_STRING}
24-
flatListProps={{
25-
contentContainerStyle: styles.container,
26-
}}
27-
/>
28-
</SafeAreaView>
29-
</>
30-
);
13+
const theme = useColorScheme();
14+
const isLightTheme = theme === "light";
15+
return (
16+
<>
17+
<StatusBar
18+
barStyle={isLightTheme ? "dark-content" : "light-content"}
19+
backgroundColor={isLightTheme ? "#fff" : "#000"}
20+
/>
21+
<SafeAreaView>
22+
<Markdown
23+
value={MD_STRING}
24+
flatListProps={{
25+
contentContainerStyle: styles.container,
26+
}}
27+
/>
28+
</SafeAreaView>
29+
</>
30+
);
3131
}
3232

3333
const styles = StyleSheet.create({
34-
container: {
35-
paddingHorizontal: 16,
36-
},
34+
container: {
35+
paddingHorizontal: 16,
36+
},
3737
});
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,25 @@
1-
/* eslint-disable @typescript-eslint/no-var-requires */
2-
const path = require('path');
3-
const createExpoWebpackConfigAsync = require('@expo/webpack-config');
4-
const { resolver } = require('./metro.config');
1+
const path = require("path");
2+
const createExpoWebpackConfigAsync = require("@expo/webpack-config");
3+
const { resolver } = require("./metro.config");
54

6-
const root = path.resolve(__dirname, '../..');
7-
const node_modules = path.join(__dirname, 'node_modules');
5+
const root = path.resolve(__dirname, "../..");
6+
const node_modules = path.join(__dirname, "node_modules");
87

98
module.exports = async function (env, argv) {
10-
const config = await createExpoWebpackConfigAsync(env, argv);
9+
const config = await createExpoWebpackConfigAsync(env, argv);
1110

12-
config.module.rules.push({
13-
test: /\.(js|jsx|ts|tsx)$/,
14-
include: path.resolve(root, 'src'),
15-
use: 'babel-loader',
16-
});
11+
config.module.rules.push({
12+
test: /\.(js|jsx|ts|tsx)$/,
13+
include: path.resolve(root, "src"),
14+
use: "babel-loader",
15+
});
1716

18-
// We need to make sure that only one version is loaded for peerDependencies
19-
// So we alias them to the versions in example's node_modules
20-
Object.assign(config.resolve.alias, {
21-
...resolver.extraNodeModules,
22-
'react-native-web': path.join(node_modules, 'react-native-web'),
23-
});
17+
// We need to make sure that only one version is loaded for peerDependencies
18+
// So we alias them to the versions in example's node_modules
19+
Object.assign(config.resolve.alias, {
20+
...resolver.extraNodeModules,
21+
"react-native-web": path.join(node_modules, "react-native-web"),
22+
});
2423

25-
return config;
24+
return config;
2625
};

lefthook.yml

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
pre-commit:
2-
parallel: true
32
commands:
43
lint:
54
glob: '*.{js,ts,jsx,tsx}'
6-
run: npx eslint {staged_files}
5+
run: yarn run rome check {staged_files}
6+
format:
7+
glob: '*.{js,ts,jsx,tsx}'
8+
run: yarn run rome format {staged_files} --write && git add {staged_files}
79
commit-msg:
810
parallel: true
911
commands:
1012
commitlint:
11-
run: npx commitlint --edit
13+
run: yarn run commitlint --edit

package.json

+3-53
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
],
2424
"scripts": {
2525
"typescript": "tsc --noEmit",
26-
"lint": "eslint \"**/*.{js,ts,tsx}\"",
26+
"lint": "rome check ./",
27+
"format": "rome format ./ --write",
2728
"build": "bob build",
2829
"prepare": "yarn build",
2930
"release": "yarn build && release-it",
@@ -47,36 +48,27 @@
4748
},
4849
"devDependencies": {
4950
"@babel/core": "7.20.2",
50-
"@babel/eslint-parser": "7.19.1",
5151
"@babel/preset-env": "7.20.2",
5252
"@commitlint/config-conventional": "17.2.0",
5353
"@evilmartians/lefthook": "1.2.0",
54-
"@react-native-community/eslint-config": "3.2.0",
5554
"@release-it/conventional-changelog": "5.1.1",
5655
"@testing-library/jest-native": "5.1.2",
5756
"@testing-library/react-native": "11.4.0",
5857
"@types/jest": "29.2.2",
5958
"@types/marked": "4.0.7",
6059
"@types/react": "18.0.25",
6160
"@types/react-native": "0.70.6",
62-
"@typescript-eslint/eslint-plugin": "5.42.1",
63-
"@typescript-eslint/parser": "5.42.1",
6461
"commitlint": "17.2.0",
65-
"eslint": "8.27.0",
66-
"eslint-config-prettier": "8.5.0",
67-
"eslint-plugin-jest": "27.1.4",
68-
"eslint-plugin-prettier": "4.2.1",
69-
"eslint-plugin-react-native-a11y": "3.3.0",
7062
"jest": "29.3.1",
7163
"jest-environment-jsdom": "29.3.1",
7264
"metro-react-native-babel-preset": "0.73.3",
7365
"pod-install": "0.1.38",
74-
"prettier": "2.7.1",
7566
"react": "18.2.0",
7667
"react-native": "0.70.5",
7768
"react-native-builder-bob": "0.20.1",
7869
"react-test-renderer": "18.2.0",
7970
"release-it": "15.5.0",
71+
"rome": "10.0.0",
8072
"typescript": "4.8.4"
8173
},
8274
"resolutions": {
@@ -141,48 +133,6 @@
141133
}
142134
}
143135
},
144-
"eslintConfig": {
145-
"root": true,
146-
"parser": "@typescript-eslint/parser",
147-
"extends": [
148-
"@react-native-community",
149-
"prettier",
150-
"plugin:@typescript-eslint/recommended",
151-
"plugin:react-native-a11y/all"
152-
],
153-
"plugins": [
154-
"jest"
155-
],
156-
"rules": {
157-
"prettier/prettier": [
158-
"error",
159-
{
160-
"quoteProps": "consistent",
161-
"singleQuote": true,
162-
"tabWidth": 2,
163-
"trailingComma": "es5",
164-
"useTabs": false
165-
}
166-
],
167-
"@typescript-eslint/ban-ts-comment": "off"
168-
},
169-
"env": {
170-
"jest/globals": true
171-
}
172-
},
173-
"eslintIgnore": [
174-
"node_modules/",
175-
"dist/",
176-
"examples/*/node_modules",
177-
"coverage"
178-
],
179-
"prettier": {
180-
"quoteProps": "consistent",
181-
"singleQuote": true,
182-
"tabWidth": 2,
183-
"trailingComma": "es5",
184-
"useTabs": false
185-
},
186136
"react-native-builder-bob": {
187137
"source": "src",
188138
"output": "dist",

0 commit comments

Comments
 (0)