Skip to content

Commit 6c5fa55

Browse files
committed
fix eslint not working properly across monorepo packages
1 parent 9a34e31 commit 6c5fa55

20 files changed

+161
-121
lines changed

.eslintrc.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// This configuration only applies to the package manager root.
2+
/** @type {import("eslint").Linter.Config} */
3+
module.exports = {
4+
ignorePatterns: ["apps/**", "packages/**"],
5+
extends: ["@marceloterreiro/eslint-config"],
6+
parser: "@typescript-eslint/parser",
7+
parserOptions: {
8+
project: true,
9+
},
10+
};

apps/example/.eslintrc.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/** @type {import('eslint').Linter.Config} */
2+
module.exports = {
3+
root: true,
4+
extends: ["@marceloterreiro/eslint-config"],
5+
rules: {
6+
'import/order': 'off',
7+
}
8+
};

apps/example/.storybook/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import AsyncStorage from '@react-native-async-storage/async-storage';
2-
import { view } from './storybook.requires';
1+
import AsyncStorage from "@react-native-async-storage/async-storage";
2+
import { view } from "./storybook.requires";
33

44
const StorybookUIRoot = view.getStorybookUI({
55
storage: {

apps/example/.storybook/preview.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Preview } from '@storybook/react';
1+
import type { Preview } from "@storybook/react";
22

33
const preview: Preview = {
44
parameters: {

apps/example/babel.config.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
module.exports = function(api) {
1+
module.exports = function (api) {
22
api.cache(true);
33
return {
4-
presets: ['babel-preset-expo'],
4+
presets: ["babel-preset-expo"],
55
};
66
};

apps/example/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { registerRootComponent } from "expo";
2+
23
import App from "./src/App";
34

45
registerRootComponent(App);

apps/example/metro.config.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
const { getDefaultConfig } = require("expo/metro-config");
2-
const { generate } = require("@storybook/react-native/scripts/generate");
3-
42
const path = require("path");
53

4+
const { generate } = require("@storybook/react-native/scripts/generate");
5+
66
// Storybook setup
77
generate({
88
configPath: path.resolve(__dirname, "./.storybook"),

apps/example/package.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"web": "expo start --web",
1010
"dev": "expo start --ios",
1111
"clean": "rm -rf dist && rm -rf node_modules",
12-
"storybook-generate": "sb-rn-get-stories"
12+
"storybook-generate": "sb-rn-get-stories",
13+
"lint": "eslint ."
1314
},
1415
"dependencies": {
1516
"@marceloterreiro/flash-calendar": "*",
@@ -21,6 +22,8 @@
2122
"devDependencies": {
2223
"@babel/core": "^7.20.0",
2324
"@marceloterreiro/tsconfig": "*",
25+
"@marceloterreiro/eslint-config": "*",
26+
"eslint": "^8.56.0",
2427
"@react-native-async-storage/async-storage": "^1.21.0",
2528
"@react-native-community/datetimepicker": "^7.6.2",
2629
"@react-native-community/slider": "^4.5.0",
@@ -31,7 +34,7 @@
3134
"babel-loader": "^8.3.0",
3235
"react-dom": "^18.2.0",
3336
"react-native-safe-area-context": "^4.9.0",
34-
"typescript": "^5.3.0"
37+
"typescript": "^5.3.3"
3538
},
3639
"private": true
3740
}

bun.lockb

9.34 KB
Binary file not shown.

package.json

+10-4
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,20 @@
77
"packages/*"
88
],
99
"scripts": {
10+
"build": "turbo build",
11+
"clean": "turbo clean && rm -rf node_modules",
1012
"dev": "turbo dev",
1113
"lint": "turbo lint",
12-
"test": "turbo test",
13-
"build": "turbo build",
14-
"clean": "turbo clean && rm -rf node_modules"
14+
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
15+
"test": "turbo test"
1516
},
1617
"devDependencies": {
18+
"@marceloterreiro/eslint-config": "*",
1719
"@marceloterreiro/tsconfig": "*",
20+
"@typescript-eslint/typescript-estree": "^6.21.0",
21+
"prettier": "^2.8.8",
22+
"turbo": "^1.12.1",
1823
"typescript": "^5.3.0"
19-
}
24+
},
25+
"packageManager": "[email protected]"
2026
}

packages/eslint-config/index.js

+35-8
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,41 @@
1-
// Copied from Cedric's repo: https://github.com/byCedric/expo-monorepo-example/blob/main/packages/eslint-config/index.js
1+
const { resolve } = require("node:path");
22

3+
const project = resolve(process.cwd(), "tsconfig.json");
4+
5+
/** @type {import('eslint').Linter.Config} */
36
module.exports = {
4-
extends: "eslint-config-universe",
5-
// do some additional things with it
6-
rules: {
7-
"prettier/prettier": ["error", { endOfLine: "auto" }],
7+
extends: [
8+
"eslint:recommended",
9+
"eslint-config-universe",
10+
"eslint-config-turbo",
11+
"prettier",
12+
],
13+
parserOptions: {
14+
project,
15+
},
16+
globals: {
17+
React: true,
18+
JSX: true,
19+
},
20+
env: {
21+
node: true,
822
},
9-
// Disable import/namespace due to https://github.com/facebook/react-native/issues/28549
10-
// By setting delimiters to `\|/`, this ignore is supported on Windows too
1123
settings: {
12-
"import/ignore": ["node_modules(\\\\|/)react-native(\\\\|/)index\\.js$"],
24+
"import/resolver": {
25+
typescript: {
26+
project,
27+
},
28+
},
1329
},
30+
ignorePatterns: [
31+
// Ignore dotfiles
32+
".*.js",
33+
"node_modules/",
34+
"dist/",
35+
],
36+
overrides: [
37+
{
38+
files: ["*.js?(x)", "*.ts?(x)"],
39+
},
40+
],
1441
};

packages/eslint-config/package.json

+10-19
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,16 @@
11
{
2-
"private": true,
32
"name": "@marceloterreiro/eslint-config",
4-
"version": "0.0.1",
5-
"description": "A shared eslint configuration for Marcelo's projects",
6-
"author": "Marcelo Prado <[email protected]>",
73
"license": "MIT",
8-
"main": "index.js",
9-
"files": [
10-
"index.js"
11-
],
12-
"scripts": {
13-
"lint": "eslint --ext js,ts,tsx ."
14-
},
15-
"dependencies": {
16-
"@typescript-eslint/eslint-plugin": "^5.42.1",
17-
"@typescript-eslint/parser": "^5.42.1",
18-
"eslint": "^8.34.0",
4+
"main": "./index.js",
5+
"version": "0.0.1",
6+
"private": true,
7+
"devDependencies": {
8+
"@typescript-eslint/eslint-plugin": "^6.21.0",
9+
"@typescript-eslint/parser": "^6.21.0",
10+
"eslint-config-prettier": "^9.1.0",
11+
"eslint-config-turbo": "^1.12.3",
1912
"eslint-config-universe": "^11.2.0",
20-
"prettier": "^2.7.1"
21-
},
22-
"eslintConfig": {
23-
"extends": "."
13+
"eslint-import-resolver-typescript": "^3.6.1",
14+
"typescript": "^5.3.0"
2415
}
2516
}

packages/flash-calendar/.eslintrc.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/** @type {import('eslint').Linter.Config} */
2+
module.exports = {
3+
root: true,
4+
extends: ["@marceloterreiro/eslint-config", "plugin:react-hooks/recommended"],
5+
parser: "@typescript-eslint/parser",
6+
parserOptions: {
7+
project: "./tsconfig.json",
8+
},
9+
rules: {
10+
"react-hooks/exhaustive-deps": "error",
11+
},
12+
};

packages/flash-calendar/package.json

+9-12
Original file line numberDiff line numberDiff line change
@@ -10,31 +10,28 @@
1010
"license": "MIT",
1111
"scripts": {
1212
"dev": "tsup --watch --silent",
13-
"lint": "eslint --ext js,ts,tsx .",
13+
"lint": "eslint src",
1414
"test": "bun test",
1515
"build": "tsup --dts",
1616
"clean": "rm -rf dist && rm -rf node_modules"
1717
},
18-
"dependencies": {},
18+
"dependencies": {
19+
"date-fns": "^3.3.1"
20+
},
1921
"peerDependencies": {
2022
"react": "*",
2123
"react-native": "*"
2224
},
2325
"devDependencies": {
2426
"@marceloterreiro/eslint-config": "*",
2527
"@marceloterreiro/tsconfig": "*",
28+
"eslint-plugin-react-hooks": "^4.6.0",
29+
"eslint": "^8.56.0",
2630
"@types/bun": "^1.0.5",
27-
"date-fns": "^3.3.1",
2831
"react": "18.2.0",
2932
"react-native": "0.73.4",
30-
"tsup": "^8.0.1"
33+
"tsup": "^8.0.1",
34+
"typescript": "^5.3.3"
3135
},
32-
"private": false,
33-
"eslintConfig": {
34-
"extends": "@marceloterreiro/eslint-config",
35-
"ignorePatterns": [
36-
"node_modules",
37-
"build"
38-
]
39-
}
36+
"private": false
4037
}

packages/flash-calendar/src/components/CaledarItemDay.stories.tsx

-49
This file was deleted.

packages/flash-calendar/src/components/Calendar.tsx

+12-2
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,20 @@ import {
66
CalendarItemEmpty,
77
} from "@/components/CalendarItemDay";
88
import { CalendarItemWeekName } from "@/components/CalendarItemWeekName";
9-
import { CalendarRowMonth } from "@/components/CalendarRowMonth";
9+
import {
10+
CalendarRowMonth,
11+
CalendarRowMonthProps,
12+
} from "@/components/CalendarRowMonth";
1013
import { CalendarRowWeek } from "@/components/CalendarRowWeek";
1114
import { VStack } from "@/components/VStack";
1215
import { uppercaseFirstLetter } from "@/helpers/strings";
1316
import { tokens } from "@/helpers/tokens";
1417
import { BuildCalendarParams, useCalendar } from "@/hooks/useCalendar";
1518

19+
export type CalendarTheme = {
20+
rowMonthTheme: CalendarRowMonthProps["theme"];
21+
};
22+
1623
export interface CalendarProps extends BuildCalendarParams {
1724
onDayPress: (dateId: string, date: Date) => void;
1825
disabledDates?: string[];
@@ -23,6 +30,8 @@ export interface CalendarProps extends BuildCalendarParams {
2330
* @default 8
2431
*/
2532
calendarRowSpacing?: number;
33+
/** Theme to customize the calendar component. */
34+
theme?: CalendarTheme;
2635
}
2736

2837
export const Calendar = memo(
@@ -31,6 +40,7 @@ export const Calendar = memo(
3140
disabledDates,
3241
activeDateRanges,
3342
calendarRowSpacing = 8,
43+
theme,
3444
...buildCalendarParams
3545
}: CalendarProps) => {
3646
const { calendarRowMonth, weeksList, weekDaysList } =
@@ -41,7 +51,7 @@ export const Calendar = memo(
4151
alignItems="center"
4252
spacing={calendarRowSpacing as keyof typeof tokens.spacing}
4353
>
44-
<CalendarRowMonth>
54+
<CalendarRowMonth height={20} theme={theme?.rowMonthTheme}>
4555
{uppercaseFirstLetter(calendarRowMonth)}
4656
</CalendarRowMonth>
4757
<CalendarRowWeek spacing={8}>

0 commit comments

Comments
 (0)