Skip to content

Commit 7053830

Browse files
authored
Merge pull request #211 from thedanchez/eslint
chore(eslint): migrate to eslint flat config for project
2 parents a93263f + 617415b commit 7053830

File tree

112 files changed

+1289
-1055
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+1289
-1055
lines changed

.github/workflows/ci.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ jobs:
3131
run: pnpm run typecheck
3232
- name: Format Check
3333
run: pnpm run format
34-
- name: Lint Check (Packages)
35-
run: pnpm run lint:packages
34+
- name: Lint Check
35+
run: pnpm run lint
3636
- name: Test (Packages)
3737
run: pnpm run test:packages
3838
- name: Build (Packages)

.husky/pre-commit

Lines changed: 0 additions & 4 deletions
This file was deleted.

eslint.config.ts

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
import js from "@eslint/js";
2+
import { defineConfig } from "eslint/config";
3+
import react from "eslint-plugin-react";
4+
import simpleImportSort from "eslint-plugin-simple-import-sort";
5+
import solid from "eslint-plugin-solid/configs/typescript";
6+
import globals from "globals";
7+
import tseslint from "typescript-eslint";
8+
9+
export default defineConfig([
10+
//
11+
// ────────────────────────────────
12+
// 1️⃣ Ignored paths (like .eslintignore)
13+
// ────────────────────────────────
14+
//
15+
{
16+
ignores: [
17+
"**/build/**",
18+
"**/coverage/**",
19+
"**/dist/**",
20+
"**/node_modules/**",
21+
// TODO: Revisit these sections later so that we can have linting across everything
22+
"examples/todo-server-tests/features/**",
23+
"examples/todo-angular-featurehub-app/**",
24+
"plugins/**",
25+
],
26+
},
27+
//
28+
// ────────────────────────────────
29+
// 2️⃣ Base recommended rules
30+
// ────────────────────────────────
31+
//
32+
js.configs.recommended,
33+
tseslint.configs.strict,
34+
//
35+
// ────────────────────────────────
36+
// 3️⃣ Import sorting
37+
// ────────────────────────────────
38+
//
39+
{
40+
plugins: {
41+
"simple-import-sort": simpleImportSort,
42+
},
43+
rules: {
44+
"simple-import-sort/imports": "error",
45+
"simple-import-sort/exports": "error",
46+
},
47+
},
48+
//
49+
// ────────────────────────────────
50+
// 3️⃣ TypeScript (General - Base rules)
51+
// ────────────────────────────────
52+
//
53+
{
54+
files: ["**/*.ts", "**/*.tsx"],
55+
languageOptions: {
56+
parser: tseslint.parser,
57+
parserOptions: {
58+
sourceType: "module",
59+
ecmaFeatures: { jsx: true },
60+
},
61+
globals: {
62+
...globals.browser,
63+
...globals.es2022,
64+
...globals.node,
65+
},
66+
},
67+
rules: {
68+
"@typescript-eslint/no-explicit-any": "off",
69+
"@typescript-eslint/no-extraneous-class": "warn",
70+
"@typescript-eslint/no-non-null-assertion": "off",
71+
"@typescript-eslint/no-unused-vars": [
72+
"error",
73+
{
74+
args: "after-used",
75+
argsIgnorePattern: "^_",
76+
caughtErrors: "all",
77+
caughtErrorsIgnorePattern: "^_",
78+
},
79+
],
80+
},
81+
},
82+
//
83+
// ────────────────────────────────
84+
// 5️⃣ React
85+
// ────────────────────────────────
86+
//
87+
{
88+
files: [
89+
"packages/react/**/*.{jsx,ts,tsx}",
90+
"examples/todo-frontend-react-sdk/**/*.{jsx,ts,tsx}",
91+
"examples/todo-frontend-react-typescript/**/*.{jsx,ts,tsx}",
92+
"examples/todo-frontend-react-typescript-catch-and-release/**/*.{jsx,ts,tsx}",
93+
"examples/todo-frontend-react-typescript-feature-override/**/*.{jsx,ts,tsx}",
94+
],
95+
...react.configs.flat.recommended,
96+
...react.configs.flat["jsx-runtime"],
97+
languageOptions: {
98+
...react.configs.flat.recommended.languageOptions,
99+
globals: {
100+
...globals.browser,
101+
},
102+
},
103+
},
104+
//
105+
// ────────────────────────────────
106+
// 6️⃣ SolidJS
107+
// ────────────────────────────────
108+
//
109+
{
110+
files: [
111+
"packages/solid/**/*.{jsx,ts,tsx}",
112+
"examples/todo-frontend-solid-sdk/**/*.{jsx,ts,tsx}",
113+
],
114+
languageOptions: {
115+
parser: tseslint.parser,
116+
parserOptions: {
117+
sourceType: "module",
118+
ecmaFeatures: { jsx: true },
119+
},
120+
globals: {
121+
...globals.browser,
122+
},
123+
},
124+
plugins: {
125+
solid: {
126+
meta: solid.plugins.solid.meta,
127+
// @ts-expect-error — Solid config typing is a bit off
128+
rules: solid.plugins.solid.rules,
129+
},
130+
},
131+
rules: solid.rules,
132+
},
133+
//
134+
// ────────────────────────────────
135+
// 7️⃣ Test environment (Vitest)
136+
// ────────────────────────────────
137+
//
138+
{
139+
files: ["**/*.test.{ts,tsx}", "**/*.spec.{ts,tsx}"],
140+
languageOptions: {
141+
globals: {
142+
...globals.node,
143+
...globals.vitest,
144+
},
145+
},
146+
rules: {
147+
"@typescript-eslint/no-explicit-any": "off",
148+
"@typescript-eslint/naming-convention": "off",
149+
},
150+
},
151+
]);

examples/todo-backend-typescript/app/app.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
import * as restify from "restify";
2-
import * as corsMiddleware from "restify-cors-middleware2";
3-
import type { ITodoApiController } from "./generated-interface";
4-
import { TodoApiRouter, Todo } from "./generated-interface";
51
import {
62
type ClientContext,
73
EdgeFeatureHubConfig,
@@ -13,6 +9,11 @@ import {
139
StrategyAttributeDeviceName,
1410
StrategyAttributePlatformName,
1511
} from "featurehub-javascript-node-sdk";
12+
import * as restify from "restify";
13+
import * as corsMiddleware from "restify-cors-middleware2";
14+
15+
import type { ITodoApiController } from "./generated-interface";
16+
import { Todo, TodoApiRouter } from "./generated-interface";
1617

1718
if (
1819
process.env["FEATUREHUB_EDGE_URL"] === undefined ||

examples/todo-backend-typescript/app/generated-interface.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,9 @@
1-
/* tslint:disable:no-string-literal */
2-
/* tslint:disable:member-ordering */
3-
/* tslint:disable:quotemark */
4-
/* tslint:disable:typedef-whitespace */
5-
61
import type { Request, Server } from "restify";
72
import * as restify from "restify";
83

94
export class Todo {
105
"id": string;
11-
126
"title": string;
13-
147
"resolved": boolean;
158
}
169

examples/todo-frontend-react-sdk/src/App.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
import { useEffect, useState } from "react";
2-
import reactLogo from "./assets/react.svg";
31
import "./App.css";
2+
43
import { FeatureHub, useFeature, useFeatureHub } from "featurehub-react-sdk";
4+
import { useEffect, useState } from "react";
5+
6+
import reactLogo from "./assets/react.svg";
57

68
const SAMPLE_TEXT =
79
"This is some random text content which may have its case-sensitivity modified.";
@@ -66,10 +68,10 @@ function Main() {
6668
return (
6769
<div className="App">
6870
<div>
69-
<a href="https://vitejs.dev" target="_blank">
71+
<a href="https://vitejs.dev" target="_blank" rel="noreferrer">
7072
<img src="/vite.svg" className="logo" alt="Vite logo" />
7173
</a>
72-
<a href="https://reactjs.org" target="_blank">
74+
<a href="https://reactjs.org" target="_blank" rel="noreferrer">
7375
<img src={reactLogo} className="logo react" alt="React logo" />
7476
</a>
7577
</div>

examples/todo-frontend-react-sdk/src/main.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
import "./index.css";
2+
13
import React from "react";
24
import ReactDOM from "react-dom/client";
5+
36
import App from "./App";
4-
import "./index.css";
57

68
ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
79
<React.StrictMode>

examples/todo-frontend-react-sdk/vite.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { defineConfig } from "vite";
21
import react from "@vitejs/plugin-react-swc";
2+
import { defineConfig } from "vite";
33

44
// https://vitejs.dev/config/
55
export default defineConfig({

examples/todo-frontend-react-typescript-catch-and-release/src/App.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
import * as React from "react";
2-
import { Configuration, type Todo, TodoServiceApi } from "./api";
31
import "./App.css";
2+
43
import globalAxios from "axios";
54
import {
65
type ClientContext,
76
EdgeFeatureHubConfig,
8-
Readyness,
97
fhLog,
8+
Readyness,
109
} from "featurehub-javascript-client-sdk";
10+
import * as React from "react";
11+
12+
import { Configuration, type Todo, TodoServiceApi } from "./api";
1113

1214
let todoApi: TodoServiceApi;
1315
let initialized = false;
@@ -49,7 +51,7 @@ class ConfigData {
4951
fhApiKey: string = "";
5052
}
5153

52-
class App extends React.Component<{}, { todos: TodoData }> {
54+
class App extends React.Component<object, { todos: TodoData }> {
5355
private titleInput!: HTMLInputElement;
5456

5557
constructor() {
@@ -151,7 +153,7 @@ class App extends React.Component<{}, { todos: TodoData }> {
151153
</div>
152154
);
153155
}
154-
let buttonStyle = {
156+
const buttonStyle = {
155157
color: this.state.todos.buttonColour,
156158
};
157159
return (

examples/todo-frontend-react-typescript-catch-and-release/src/api/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* tslint:disable */
2-
/* eslint-disable */
2+
33
/**
44
* Todo
55
* Sample todo-api

0 commit comments

Comments
 (0)