Skip to content

Commit 3828b00

Browse files
authored
chore(*): added linting and formatting to CI
2 parents baa0fee + 7ff60e2 commit 3828b00

File tree

18 files changed

+1369
-97
lines changed

18 files changed

+1369
-97
lines changed

.github/workflows/test.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,29 @@ 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/*" run lint
30+
- name: Run ESLint on example apps
31+
run: pnpm --filter="angular-example" --filter="nextjs" --filter="react" run lint
32+
- name: Check Prettier formatting
33+
run: pnpm format:check
34+
1235
test:
1336
runs-on: ubuntu-latest
1437
steps:

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ dist-ssr
1515
# Angular
1616
.angular
1717

18+
# Next.js
19+
.next
20+
1821
# Coverage
1922
coverage
2023

.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: 95 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,47 +16,119 @@
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";
1921

2022
export default [
21-
{ ignores: ["**/dist/**", "**/node_modules/**", "**/releases/**", "**/.angular/**"] },
23+
{
24+
ignores: [
25+
"dist/**",
26+
"node_modules/**",
27+
"releases/**",
28+
"*.tgz",
29+
"**/dist/**",
30+
"**/node_modules/**",
31+
"**/build/**",
32+
"**/.next/**",
33+
"**/coverage/**",
34+
"**/.angular/**",
35+
"**/cache/**",
36+
"**/.cache/**",
37+
],
38+
},
2239
js.configs.recommended,
2340
prettier,
2441
{
25-
files: ["**/*.{js,jsx,ts,tsx}"],
42+
files: ["**/*.{js,jsx}"],
2643
languageOptions: {
2744
ecmaVersion: 2022,
2845
sourceType: "module",
46+
globals: {
47+
window: "readonly",
48+
console: "readonly",
49+
document: "readonly",
50+
process: "readonly",
51+
Buffer: "readonly",
52+
__dirname: "readonly",
53+
__filename: "readonly",
54+
global: "readonly",
55+
module: "readonly",
56+
require: "readonly",
57+
exports: "readonly",
58+
setImmediate: "readonly",
59+
clearImmediate: "readonly",
60+
URL: "readonly",
61+
clearInterval: "readonly",
62+
clearTimeout: "readonly",
63+
setTimeout: "readonly",
64+
setInterval: "readonly",
65+
},
66+
},
67+
rules: {
68+
"no-unused-vars": "off",
69+
"no-console": "warn",
70+
"prefer-const": "error",
71+
"no-var": "error",
72+
"no-undef": "off",
73+
},
74+
},
75+
{
76+
files: ["**/*.{ts,tsx}"],
77+
languageOptions: {
78+
ecmaVersion: 2022,
79+
sourceType: "module",
80+
parser: tsparser,
2981
parserOptions: {
3082
ecmaFeatures: {
3183
jsx: true,
3284
},
3385
},
86+
globals: {
87+
window: "readonly",
88+
console: "readonly",
89+
document: "readonly",
90+
process: "readonly",
91+
Buffer: "readonly",
92+
__dirname: "readonly",
93+
__filename: "readonly",
94+
global: "readonly",
95+
module: "readonly",
96+
require: "readonly",
97+
exports: "readonly",
98+
setImmediate: "readonly",
99+
clearImmediate: "readonly",
100+
URL: "readonly",
101+
clearInterval: "readonly",
102+
clearTimeout: "readonly",
103+
setTimeout: "readonly",
104+
setInterval: "readonly",
105+
React: "readonly",
106+
describe: "readonly",
107+
it: "readonly",
108+
expect: "readonly",
109+
beforeEach: "readonly",
110+
afterEach: "readonly",
111+
beforeAll: "readonly",
112+
afterAll: "readonly",
113+
vi: "readonly",
114+
test: "readonly",
115+
jest: "readonly",
116+
},
117+
},
118+
plugins: {
119+
"@typescript-eslint": tseslint,
34120
},
35121
rules: {
36-
// Core JavaScript rules
37-
"no-unused-vars": ["error", { varsIgnorePattern: "^_", argsIgnorePattern: "^_" }],
122+
"no-unused-vars": "off",
123+
"no-undef": "off",
38124
"no-console": "warn",
39125
"prefer-const": "error",
40126
"no-var": "error",
41-
42-
// Security and best practices
43-
"no-debugger": "error",
44-
"no-eval": "error",
45-
"no-implied-eval": "error",
46-
"no-new-func": "error",
47-
"no-script-url": "error",
48-
"no-with": "error",
49-
50-
// Modern JavaScript preferences
51-
"prefer-arrow-callback": "error",
52-
"prefer-template": "error",
53-
"prefer-destructuring": ["error", { object: true, array: false }],
54-
55-
// Code quality
56-
eqeqeq: ["error", "always"],
57-
"no-duplicate-imports": "error",
58-
"no-useless-return": "error",
59-
"no-useless-concat": "error",
127+
"@typescript-eslint/no-unused-vars": [
128+
"error",
129+
{ varsIgnorePattern: "^_", argsIgnorePattern: "^_", caughtErrorsIgnorePattern: "^_" },
130+
],
131+
"@typescript-eslint/no-explicit-any": "warn",
60132
},
61133
},
62134
];

examples/angular/angular.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
},
7070
"extract-i18n": {
7171
"builder": "@angular/build:extract-i18n"
72-
},
72+
}
7373
}
7474
},
7575
"angular": {
@@ -92,7 +92,7 @@
9292
}
9393
},
9494
"defaultConfiguration": "production"
95-
},
95+
}
9696
}
9797
}
9898
},

examples/angular/eslint.config.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
import js from "@eslint/js";
1818
import prettier from "eslint-config-prettier";
19+
import typescript from "@typescript-eslint/eslint-plugin";
20+
import typescriptParser from "@typescript-eslint/parser";
1921

2022
export default [
2123
{ ignores: ["dist/**", "node_modules/**", ".angular/**"] },
@@ -26,13 +28,18 @@ export default [
2628
languageOptions: {
2729
ecmaVersion: 2022,
2830
sourceType: "module",
31+
parser: typescriptParser,
2932
parserOptions: {
3033
project: "./tsconfig.json",
3134
},
3235
},
36+
plugins: {
37+
"@typescript-eslint": typescript,
38+
},
3339
rules: {
34-
"no-unused-vars": ["error", { varsIgnorePattern: "^_", argsIgnorePattern: "^_" }],
35-
"no-console": "warn",
40+
"no-unused-vars": "off", // Use TypeScript version instead
41+
"no-console": "off", // Allow console in examples
42+
"no-undef": "off", // TypeScript handles this
3643
"prefer-const": "error",
3744
"no-var": "error",
3845
"@typescript-eslint/no-explicit-any": "warn",

examples/angular/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "angular-example",
33
"version": "0.0.0",
4+
"type": "module",
45
"scripts": {
56
"ng": "ng",
67
"start": "ng serve",
@@ -52,6 +53,8 @@
5253
"@types/express": "^4.17.17",
5354
"@types/node": "^20.19.0",
5455
"eslint": "^9.22.0",
56+
"@typescript-eslint/eslint-plugin": "^8.43.0",
57+
"@typescript-eslint/parser": "^8.43.0",
5558
"eslint-config-prettier": "^9.1.0",
5659
"firebase": "^11",
5760
"vitest": "^3.2.0",
@@ -64,4 +67,4 @@
6467
"prettier": "^3.1.1",
6568
"typescript": "~5.9.2"
6669
}
67-
}
70+
}

examples/angular/src/test-setup.ts

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,13 @@ import "zone.js";
2121
import "zone.js/testing";
2222

2323
// Import Angular testing utilities
24-
import { getTestBed, TestBed } from "@angular/core/testing";
25-
import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from "@angular/platform-browser-dynamic/testing";
24+
import { TestBed } from "@angular/core/testing";
2625

2726
// Ensure Zone.js testing environment is properly configured
2827
beforeEach(() => {
2928
// Reset Zone.js state before each test
3029
if (typeof Zone !== "undefined") {
31-
Zone.current.fork({}).run(() => {
30+
Zone.current.fork({ name: "test-zone" }).run(() => {
3231
// Run each test in a fresh zone
3332
});
3433
}
@@ -41,13 +40,6 @@ import * as matchers from "@testing-library/jest-dom/matchers";
4140
// Extend Vitest's expect with jest-dom matchers
4241
expect.extend(matchers);
4342

44-
// Initialize the testing environment with Zone.js support
45-
if (!TestBed.platform) {
46-
TestBed.initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting(), {
47-
teardown: { destroyAfterEach: false },
48-
});
49-
}
50-
5143
// Reset TestBed after each test to prevent configuration conflicts
5244
afterEach(() => {
5345
TestBed.resetTestingModule();
@@ -60,11 +52,11 @@ declare global {
6052
}
6153

6254
// Define global test utilities
63-
globalThis.spyOn = (obj: any, method: string) => {
55+
(globalThis as any).spyOn = (obj: any, method: string) => {
6456
const spy = vi.spyOn(obj, method);
6557
// Add Jasmine-compatible methods
66-
spy.and = {
67-
callFake: (fn: Function) => {
58+
(spy as any).and = {
59+
callFake: (fn: (...args: any[]) => any) => {
6860
spy.mockImplementation(fn);
6961
return spy;
7062
},
@@ -77,7 +69,7 @@ globalThis.spyOn = (obj: any, method: string) => {
7769
return spy;
7870
},
7971
};
80-
spy.calls = {
72+
(spy as any).calls = {
8173
reset: () => spy.mockClear(),
8274
all: () => spy.mock.calls,
8375
count: () => spy.mock.calls.length,
@@ -86,6 +78,6 @@ globalThis.spyOn = (obj: any, method: string) => {
8678
};
8779
return spy;
8880
};
89-
globalThis.pending = (reason?: string) => {
81+
(globalThis as any).pending = (reason?: string) => {
9082
throw new Error(`Test pending: ${reason || "No reason provided"}`);
9183
};

examples/nextjs/.eslintrc.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extends": ["next/core-web-vitals"],
3+
"parser": "@typescript-eslint/parser",
4+
"plugins": ["@typescript-eslint"],
5+
"rules": {
6+
"@typescript-eslint/no-explicit-any": "warn",
7+
"no-console": "off"
8+
}
9+
}

examples/nextjs/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@
2727
"@types/node": "^20",
2828
"@types/react": "^19",
2929
"@types/react-dom": "^19",
30+
"eslint": "^9.22.0",
31+
"eslint-config-next": "^15.1.7",
32+
"@typescript-eslint/eslint-plugin": "^8.43.0",
33+
"@typescript-eslint/parser": "^8.43.0",
3034
"postcss": "^8.5.2",
3135
"postcss-load-config": "^6.0.1",
3236
"prettier": "^3.1.1",

0 commit comments

Comments
 (0)