Skip to content

Commit

Permalink
chore: eslint config
Browse files Browse the repository at this point in the history
  • Loading branch information
henrynoowah committed Jan 10, 2025
1 parent b7209c7 commit 1ad3e10
Show file tree
Hide file tree
Showing 14 changed files with 531 additions and 2,495 deletions.
Binary file modified .DS_Store
Binary file not shown.
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,13 @@
"devDependencies": {
"@changesets/cli": "^2.27.1",
"prettier": "^3.2.5",
"turbo": "^2.0.3"
"turbo": "^2.0.3",
"typescript": "^5.5.4",
"jiti": "^2.4.2"
},
"packageManager": "[email protected]",
"engines": {
"node": ">=18"
},
"packageManager": "[email protected]",
"name": "content-builder-design-system"
}
15 changes: 15 additions & 0 deletions packages/config-eslint/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# `@repo/config-eslint`

Collection of internal eslint configurations.

## Structure

This package contains various ESLint configurations used throughout the monorepo. Below is an explanation of each file and its purpose:

### Files

- [`base.ts`](./base.ts): Contains the base ESLint configuration that includes recommended settings for JavaScript and TypeScript.

- [`next.ts`](./next.ts): Extends the base configuration with additional rules and plugins for Next.js projects.

- [`react-internal.ts`](./react-internal.ts): Extends the base configuration with additional rules and plugins for React projects, including hooks and JSX settings.
15 changes: 15 additions & 0 deletions packages/config-eslint/base.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import js from "@eslint/js";
import type { Linter } from "eslint";
import turbo from "eslint-plugin-turbo";
import tseslint from "typescript-eslint";

// ? https://github.com/bfanger/eslint-plugin-only-warn/issues/13
import "eslint-plugin-only-warn";

const config = [
js.configs.recommended,
...tseslint.configs.recommended,
turbo.configs["flat/recommended"],
] as Linter.Config[];

export default config;
35 changes: 0 additions & 35 deletions packages/config-eslint/library.js

This file was deleted.

48 changes: 48 additions & 0 deletions packages/config-eslint/next.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import eslintConfigPrettier from "eslint-config-prettier";
import reactPlugin from "eslint-plugin-react";
import globals from "globals";
import baseConfig from "./base";

// @ts-ignore
import hooksPlugin from "eslint-plugin-react-hooks";
// @ts-ignore
import pluginNext from "@next/eslint-plugin-next";

const nextJsConfig = [
...baseConfig,
{
plugins: {
"@next/next": pluginNext,
},
rules: {
...pluginNext.configs.recommended.rules,
...pluginNext.configs["core-web-vitals"].rules,
},
},
{
files: ["**/*.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}"],
...reactPlugin.configs.flat?.recommended,
languageOptions: {
...reactPlugin.configs.flat?.recommended?.languageOptions,
globals: {
...globals.serviceworker,
...globals.browser,
},
},
rules: {
"react/react-in-jsx-scope": "off",
},
},
{
plugins: {
"react-hooks": hooksPlugin,
},
rules: hooksPlugin.configs.recommended.rules,
},
eslintConfigPrettier,
{
ignores: ["./dist", "node_modules", ".next/*"],
},
];

export default nextJsConfig;
30 changes: 21 additions & 9 deletions packages/config-eslint/package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
{
"name": "@repo/config-eslint",
"version": "0.0.0",
"type": "module",
"private": true,
"files": [
"library.js",
"react.js",
"storybook.js"
],
"exports": {
"./base": "./base.ts",
"./next-js": "./next.ts",
"./react-internal": "./react-internal.ts",
"./storybook": "./storybook.ts"
},
"devDependencies": {
"@vercel/style-guide": "^5.2.0",
"eslint-config-turbo": "^2.0.0",
"eslint-plugin-mdx": "^3.1.5",
"@eslint/js": "^9.17.0",
"@next/eslint-plugin-next": "^15.1.0",
"@types/eslint-config-prettier": "^6.11.3",
"@typescript-eslint/eslint-plugin": "^8.15.0",
"@typescript-eslint/parser": "^8.15.0",
"eslint": "^9.15.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-only-warn": "^1.1.0",
"eslint-plugin-storybook": "^0.8.0"
"eslint-plugin-storybook": "^0.11.2",
"eslint-plugin-react": "^7.37.2",
"eslint-plugin-react-hooks": "^5.0.0",
"eslint-plugin-turbo": "^2.3.0",
"globals": "^15.12.0",
"typescript": "^5.3.3",
"typescript-eslint": "^8.15.0"
}
}
36 changes: 36 additions & 0 deletions packages/config-eslint/react-internal.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import eslintConfigPrettier from "eslint-config-prettier";
import reactPlugin from "eslint-plugin-react";
import globals from "globals";
import baseConfig from "./base.ts";

// @ts-ignore
import hooksPlugin from "eslint-plugin-react-hooks";

// ? https://github.com/jsx-eslint/eslint-plugin-react?tab=readme-ov-file#configuring-shared-settings
// ? https://github.com/facebook/react/issues/28313
const config = [
...baseConfig,
{
files: ["src/components/**/*.{ts,tsx}"],
...reactPlugin.configs.flat?.recommended,
languageOptions: {
...reactPlugin.configs.flat?.recommended.languageOptions,
globals: {
...globals.serviceworker,
...globals.browser,
},
},
rules: {
"react/react-in-jsx-scope": "off",
},
},
{
plugins: {
"react-hooks": hooksPlugin,
},
rules: hooksPlugin.configs.recommended.rules,
},
eslintConfigPrettier,
];

export default config;
39 changes: 0 additions & 39 deletions packages/config-eslint/react.js

This file was deleted.

45 changes: 0 additions & 45 deletions packages/config-eslint/storybook.js

This file was deleted.

29 changes: 29 additions & 0 deletions packages/config-eslint/storybook.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import eslintConfigPrettier from "eslint-config-prettier";
import reactPlugin from "eslint-plugin-react";
import storybook from "eslint-plugin-storybook";
import globals from "globals";
import baseConfig from "./base.ts";
const config = [
...baseConfig,
{
files: ["src/stories/**/*.{ts,tsx}"],
...reactPlugin.configs.flat?.recommended,
languageOptions: {
...reactPlugin.configs.flat?.recommended.languageOptions,
globals: {
...globals.serviceworker,
...globals.browser,
},
},
rules: {
"react/react-in-jsx-scope": "off",
},
},
...storybook.configs["flat/recommended"],
eslintConfigPrettier,
{
ignores: ["!.storybook"],
},
];

export default config;
22 changes: 22 additions & 0 deletions packages/config-eslint/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "Node",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"declaration": true,
"emitDeclarationOnly": true,
"allowImportingTsExtensions": true,
"allowJs": true,
"jsx": "react-jsx",
"baseUrl": ".",
"paths": {
"@/*": ["./app/*"]
}
},
"include": ["**/*.ts"],
"exclude": ["node_modules"]
}
5 changes: 1 addition & 4 deletions packages/config-typescript/react-library.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "./base.json",
"compilerOptions": {
"jsx": "react-jsx",
"lib": ["dom", "ES2015"],
"module": "ESNext",
"target": "es6"
"jsx": "react-jsx"
}
}
Loading

0 comments on commit 1ad3e10

Please sign in to comment.