Skip to content

Commit 14c152f

Browse files
committed
chore(*): added linting and formatting to CI
1 parent 62398c5 commit 14c152f

File tree

6 files changed

+136
-5
lines changed

6 files changed

+136
-5
lines changed

.github/workflows/test.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,27 @@ on:
99
- "**"
1010

1111
jobs:
12+
lint:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
- name: Setup node
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version: '20'
21+
check-latest: true
22+
- name: Setup pnpm
23+
uses: pnpm/action-setup@v4
24+
with:
25+
version: latest
26+
- name: Install dependencies
27+
run: pnpm install
28+
- name: Run ESLint on core packages
29+
run: pnpm --filter=@firebase-ui/core run lint && pnpm --filter=@firebase-ui/react run lint && pnpm --filter=@firebase-ui/translations run lint && pnpm --filter=@firebase-ui/styles run lint
30+
- name: Check Prettier formatting
31+
run: pnpm format:check
32+
1233
test:
1334
runs-on: ubuntu-latest
1435
steps:

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ releases/
1313
# Generated files
1414
*.min.js
1515
*.min.css
16+
packages/styles/dist.css
1617

1718
# Logs
1819
*.log

eslint.config.js

Lines changed: 110 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,30 @@
1616

1717
import js from "@eslint/js";
1818
import prettier from "eslint-config-prettier";
19+
import tseslint from "@typescript-eslint/eslint-plugin";
20+
import tsparser from "@typescript-eslint/parser";
21+
import react from "eslint-plugin-react";
22+
import reactHooks from "eslint-plugin-react-hooks";
1923

2024
export default [
2125
{ ignores: ["**/dist/**", "**/node_modules/**", "**/releases/**", "**/.angular/**"] },
2226
js.configs.recommended,
2327
prettier,
28+
// More lenient rules for examples
2429
{
25-
files: ["**/*.{js,jsx,ts,tsx}"],
30+
files: ["examples/**/*.{js,jsx,ts,tsx}"],
31+
rules: {
32+
"no-unused-vars": "warn",
33+
"no-console": "off",
34+
"@typescript-eslint/no-unused-vars": "warn",
35+
"@typescript-eslint/no-explicit-any": "off",
36+
"prefer-destructuring": "warn",
37+
"prefer-template": "warn",
38+
"prefer-arrow-callback": "warn",
39+
},
40+
},
41+
{
42+
files: ["**/*.{js,jsx}"],
2643
languageOptions: {
2744
ecmaVersion: 2022,
2845
sourceType: "module",
@@ -31,6 +48,16 @@ export default [
3148
jsx: true,
3249
},
3350
},
51+
globals: {
52+
window: "readonly",
53+
console: "readonly",
54+
document: "readonly",
55+
process: "readonly",
56+
module: "readonly",
57+
require: "readonly",
58+
__dirname: "readonly",
59+
global: "readonly",
60+
},
3461
},
3562
rules: {
3663
// Core JavaScript rules
@@ -59,4 +86,86 @@ export default [
5986
"no-useless-concat": "error",
6087
},
6188
},
89+
{
90+
files: ["**/*.{ts,tsx}"],
91+
languageOptions: {
92+
ecmaVersion: 2022,
93+
sourceType: "module",
94+
parser: tsparser,
95+
parserOptions: {
96+
ecmaFeatures: {
97+
jsx: true,
98+
},
99+
},
100+
globals: {
101+
window: "readonly",
102+
console: "readonly",
103+
document: "readonly",
104+
process: "readonly",
105+
module: "readonly",
106+
require: "readonly",
107+
__dirname: "readonly",
108+
global: "readonly",
109+
describe: "readonly",
110+
it: "readonly",
111+
expect: "readonly",
112+
beforeEach: "readonly",
113+
afterEach: "readonly",
114+
beforeAll: "readonly",
115+
afterAll: "readonly",
116+
vi: "readonly",
117+
React: "readonly",
118+
},
119+
},
120+
plugins: {
121+
"@typescript-eslint": tseslint,
122+
react,
123+
"react-hooks": reactHooks,
124+
},
125+
settings: {
126+
react: {
127+
version: "detect",
128+
},
129+
},
130+
rules: {
131+
// Core JavaScript rules
132+
"no-unused-vars": "off", // Turn off base rule
133+
"no-undef": "off", // Turn off base rule - TypeScript handles this better
134+
"no-console": "warn",
135+
"prefer-const": "error",
136+
"no-var": "error",
137+
138+
// Security and best practices
139+
"no-debugger": "error",
140+
"no-eval": "error",
141+
"no-implied-eval": "error",
142+
"no-new-func": "error",
143+
"no-script-url": "error",
144+
"no-with": "error",
145+
146+
// Modern JavaScript preferences
147+
"prefer-arrow-callback": "error",
148+
"prefer-template": "error",
149+
"prefer-destructuring": ["error", { object: true, array: false }],
150+
151+
// Code quality
152+
eqeqeq: ["error", "always"],
153+
"no-duplicate-imports": "error",
154+
"no-useless-return": "error",
155+
"no-useless-concat": "error",
156+
157+
// TypeScript rules
158+
"@typescript-eslint/no-unused-vars": [
159+
"error",
160+
{ varsIgnorePattern: "^_", argsIgnorePattern: "^_", caughtErrorsIgnorePattern: "^_" },
161+
],
162+
"@typescript-eslint/no-explicit-any": "warn",
163+
164+
// React rules
165+
"react/prop-types": "off",
166+
"react/react-in-jsx-scope": "off",
167+
"react/jsx-uses-react": "off",
168+
"react/jsx-uses-vars": "error",
169+
},
170+
},
62171
];

packages/styles/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ The packages also exports themes which overrides the CSS variables with preset c
2828
```css
2929
@import "tailwindcss";
3030
@import "@firebase-ui/styles/tailwind";
31-
@import "@firebase-ui/styles/themes/brualist"
31+
@import "@firebase-ui/styles/themes/brualist";
3232
```
3333

3434
## Building

packages/styles/src/index.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,14 @@ describe("ButtonVariant type", () => {
4848
it("should accept valid variant values", () => {
4949
const primaryVariant: ButtonVariant = "primary";
5050
const secondaryVariant: ButtonVariant = "secondary";
51-
51+
5252
expect(primaryVariant).toBe("primary");
5353
expect(secondaryVariant).toBe("secondary");
5454
});
5555

5656
it("should work with buttonVariant function", () => {
5757
const variants: ButtonVariant[] = ["primary", "secondary"];
58-
58+
5959
variants.forEach((variant) => {
6060
const result = buttonVariant({ variant });
6161
expect(typeof result).toBe("string");

packages/styles/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ export const buttonVariant = cva({
1313
},
1414
});
1515

16-
export type ButtonVariant = VariantProps<typeof buttonVariant>['variant'];
16+
export type ButtonVariant = VariantProps<typeof buttonVariant>["variant"];

0 commit comments

Comments
 (0)