You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|[contracts](./packages/contracts)|[](https://badge.fury.io/js/@graphprotocol%2Fcontracts)| Contracts enabling the open and permissionless decentralized network known as The Graph protocol. |
39
-
|[data-edge](./packages/data-edge)|- | Data edge testing and utilities for The Graph protocol. |
39
+
|[data-edge](./packages/data-edge)|[](https://badge.fury.io/js/@graphprotocol%2Fdata-edge)| Data edge testing and utilities for The Graph protocol. |
40
40
|[hardhat-graph-protocol](./packages/hardhat-graph-protocol)|[](https://badge.fury.io/js/hardhat-graph-protocol)| A Hardhat plugin that extends the runtime environment with functionality for The Graph protocol. |
41
41
|[horizon](./packages/horizon)|[](https://badge.fury.io/js/@graphprotocol%2Fhorizon)| Contracts for Graph Horizon, the next iteration of The Graph protocol. |
42
42
|[interfaces](./packages/interfaces)|[](https://badge.fury.io/js/@graphprotocol%2Finterfaces)| Contract interfaces for The Graph protocol contracts. |
43
+
|[issuance](./packages/issuance)|[](https://badge.fury.io/js/@graphprotocol%2Fissuance)| Smart contracts for The Graph's token issuance functionality |
43
44
|[subgraph-service](./packages/subgraph-service)|[](https://badge.fury.io/js/@graphprotocol%2Fsubgraph-service)| Contracts for the Subgraph data service in Graph Horizon. |
44
45
|[token-distribution](./packages/token-distribution)|[](https://badge.fury.io/js/@graphprotocol%2Ftoken-distribution)| Contracts managing token locks for network participants. |
45
46
|[toolshed](./packages/toolshed)|[](https://badge.fury.io/js/@graphprotocol%2Ftoolshed)| A collection of tools and utilities for the Graph Protocol TypeScript components. |
@@ -67,6 +68,52 @@ $ pnpm install
67
68
68
69
# Build projects
69
70
$ pnpm build
71
+
72
+
# Run tests
73
+
$ pnpm test
74
+
```
75
+
76
+
### Script Patterns
77
+
78
+
This monorepo follows consistent script patterns across all packages to ensure reliable builds and tests:
79
+
80
+
#### Build Scripts
81
+
82
+
-**`pnpm build`** (root) - Builds all packages by calling `build:self` on each
83
+
-**`pnpm build`** (package) - Builds dependencies first, then the package itself
84
+
-**`pnpm build:self`** - Builds only the current package (no dependencies)
85
+
-**`pnpm build:dep`** - Builds workspace dependencies needed by the current package
86
+
87
+
#### Test Scripts
88
+
89
+
-**`pnpm test`** (root) - Builds everything once, then runs `test:self` on all packages
90
+
-**`pnpm test`** (package) - Builds dependencies first, then runs tests
91
+
-**`pnpm test:self`** - Runs only the package's tests (no building)
92
+
-**`pnpm test:coverage`** (root) - Builds everything once, then runs `test:coverage:self` on all packages
93
+
-**`pnpm test:coverage`** (package) - Builds dependencies first, then runs coverage
94
+
-**`pnpm test:coverage:self`** - Runs only the package's coverage tests (no building)
95
+
96
+
#### Key Benefits
97
+
98
+
-**Efficiency**: Root `pnpm test` builds once, then tests all packages
99
+
-**Reliability**: Individual package tests always ensure dependencies are built
100
+
-**Consistency**: Same patterns work at any level (root or package)
101
+
-**Child Package Support**: Packages with child packages delegate testing appropriately
102
+
103
+
#### Examples
104
+
105
+
```bash
106
+
# Build everything from root
107
+
pnpm build
108
+
109
+
# Test everything from root (builds once, tests all)
110
+
pnpm test
111
+
112
+
# Test a specific package (builds its dependencies, then tests)
113
+
cd packages/horizon && pnpm test
114
+
115
+
# Test without building (assumes dependencies already built)
116
+
cd packages/horizon && pnpm test:self
70
117
```
71
118
72
119
### Versioning and publishing packages
@@ -118,6 +165,158 @@ pnpm publish --recursive
118
165
119
166
Alternatively, there is a GitHub action that can be manually triggered to publish a package.
120
167
168
+
## Linting Configuration
169
+
170
+
This monorepo uses a comprehensive linting setup with multiple tools to ensure code quality and consistency across all packages.
171
+
172
+
### Linting Tools Overview
173
+
174
+
-**ESLint**: JavaScript/TypeScript code quality and style enforcement
175
+
-**Prettier**: Code formatting for JavaScript, TypeScript, JSON, Markdown, YAML, and Solidity
176
+
-**Solhint**: Solidity-specific linting for smart contracts
177
+
-**Markdownlint**: Markdown formatting and style consistency
178
+
-**YAML Lint**: YAML file validation and formatting
179
+
180
+
### Configuration Architecture
181
+
182
+
The linting configuration follows a hierarchical structure where packages inherit from root-level configurations:
183
+
184
+
#### ESLint Configuration
185
+
186
+
-**Root Configuration**: `eslint.config.mjs` - Modern flat config format
-**Root Configuration**: `.solhint.json` - Base Solidity linting rules extending `solhint:recommended`
209
+
-**Direct Command**: `npx solhint 'contracts/**/*.sol'` (add `--fix` for auto-fixing)
210
+
-**List Applied Rules**: `npx solhint list-rules`
211
+
-**TODO Comment Checking**: `scripts/check-todos.sh` - Blocks commits and linting if TODO/FIXME/XXX/HACK comments are found in changed Solidity files
212
+
-**Package Inheritance**: Packages can extend the root config with package-specific rules
213
+
-**Configuration Inheritance Limitation**: Solhint has a limitation where nested `extends` don't work properly. When a local config extends a parent config that itself extends `solhint:recommended`, the built-in ruleset is ignored.
-**Custom Script**: `scripts/lint-staged-run.sh` filters out generated files that shouldn't be linted
270
+
-**File Type Handling**:
271
+
-`.{js,ts,cjs,mjs,jsx,tsx}`: ESLint + Prettier
272
+
-`.sol`: TODO check + Solhint + Prettier
273
+
-`.md`: Markdownlint + Prettier
274
+
-`.json`: Prettier only
275
+
-`.{yml,yaml}`: YAML lint + Prettier
276
+
277
+
**Usage**: `pnpm lint:staged` is particularly useful when you want to check what linting changes will be applied to your staged files before actually committing.
278
+
279
+
### TODO Comment Enforcement
280
+
281
+
The repository enforces TODO comment resolution to maintain code quality:
282
+
283
+
-**Scope**: Applies only to Solidity (`.sol`) files
284
+
-**Detection**: Finds TODO, FIXME, XXX, and HACK comments (case-insensitive)
285
+
-**Triggers**:
286
+
-**Pre-commit**: Blocks commits if TODO comments exist in files being committed
287
+
-**Regular linting**: Flags TODO comments in locally changed, staged, or untracked Solidity files
288
+
-**Script**: `scripts/check-todos.sh` (must be run from repository root)
289
+
-**Bypass**: Use `git commit --no-verify` to bypass (not recommended for production)
290
+
291
+
### Key Design Principles
292
+
293
+
1.**Hierarchical Configuration**: Root configurations provide base rules, packages can extend as needed
294
+
2.**Tool-Specific Inheritance**: ESLint searches up automatically, Prettier requires explicit inheritance
295
+
3.**Generated File Exclusion**: Multiple layers of exclusion for autogenerated content
296
+
4.**Consistent Formatting**: Prettier ensures consistent code formatting across all file types
297
+
5.**Fail-Fast Linting**: Pre-commit hooks catch issues before they enter the repository
-**ESLint not finding config**: ESLint searches up parent directories automatically - no local config needed
312
+
-**Prettier not working**: Packages need a `prettier.config.cjs` that inherits from root config
313
+
-**Solhint missing rules**: If extending a parent config, use array format: `["solhint:recommended", "./../../.solhint.json"]` to ensure all rules are loaded
314
+
-**Solhint inheritance not working**: Nested extends don't work - parent config's `solhint:recommended` won't be inherited with simple string extends
315
+
-**Solhint rule reference**: Use `npx solhint list-rules` to see all available rules and their descriptions
316
+
-**Generated files being linted**: Check ignore patterns in `.prettierignore`, `.markdownlintignore`, and ESLint config
317
+
-**Preview lint changes before commit**: Use `pnpm lint:staged` to see what changes will be applied to staged files
318
+
-**Commit blocked by linting**: Fix the linting issues or use `git commit --no-verify` to bypass (not recommended)
0 commit comments