create-content-sdk-app 2.0.0-canary.8 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.MD +202 -202
- package/dist/initializers/angular/args.js +2 -0
- package/dist/initializers/angular/index.js +30 -0
- package/dist/initializers/angular/prompts.js +20 -0
- package/dist/templates/angular/.postcssrc.json +5 -0
- package/dist/templates/angular/.vscode/extensions.json +4 -0
- package/dist/templates/angular/README.md +3 -0
- package/dist/templates/angular/angular.json +79 -0
- package/dist/templates/angular/package.json +58 -0
- package/dist/templates/angular/public/favicon.ico +0 -0
- package/dist/templates/angular/src/app/app.config.server.ts +12 -0
- package/dist/templates/angular/src/app/app.config.ts +31 -0
- package/dist/templates/angular/src/app/app.css +0 -0
- package/dist/templates/angular/src/app/app.html +1 -0
- package/dist/templates/angular/src/app/app.routes.server.ts +15 -0
- package/dist/templates/angular/src/app/app.routes.ts +28 -0
- package/dist/templates/angular/src/app/app.ts +12 -0
- package/dist/templates/angular/src/app/loaders/error.loader.ts +12 -0
- package/dist/templates/angular/src/app/loaders/index.ts +14 -0
- package/dist/templates/angular/src/app/loaders/not-found.loader.ts +12 -0
- package/dist/templates/angular/src/app/loaders/page.loader.ts +15 -0
- package/dist/templates/angular/src/app/loaders/stub-utils.ts +83 -0
- package/dist/templates/angular/src/app/pages/error.component.ts +124 -0
- package/dist/templates/angular/src/app/pages/not-found.component.ts +85 -0
- package/dist/templates/angular/src/app/pages/page.component.ts +58 -0
- package/dist/templates/angular/src/app/shared/layout.component.ts +106 -0
- package/dist/templates/angular/src/index.html +13 -0
- package/dist/templates/angular/src/main.server.ts +8 -0
- package/dist/templates/angular/src/main.ts +6 -0
- package/dist/templates/angular/src/server.ts +65 -0
- package/dist/templates/angular/src/styles.css +3 -0
- package/dist/templates/angular/tsconfig.json +38 -0
- package/dist/templates/angular/tsconfig.spec.json +10 -0
- package/dist/templates/nextjs/.cursor/rules/general.mdc +81 -81
- package/dist/templates/nextjs/.cursor/rules/javascript.mdc +112 -112
- package/dist/templates/nextjs/.cursor/rules/project-setup.mdc +100 -100
- package/dist/templates/nextjs/.cursor/rules/sitecore.mdc +150 -150
- package/dist/templates/nextjs/.env.container.example +27 -27
- package/dist/templates/nextjs/.env.remote.example +51 -51
- package/dist/templates/nextjs/.gitattributes +11 -11
- package/dist/templates/nextjs/.prettierrc +8 -8
- package/dist/templates/nextjs/.vscode/extensions.json +8 -8
- package/dist/templates/nextjs/.vscode/launch.json +15 -15
- package/dist/templates/nextjs/.windsurfrules +186 -186
- package/dist/templates/nextjs/LICENSE.txt +202 -202
- package/dist/templates/nextjs/LLMs.txt +179 -179
- package/dist/templates/nextjs/eslint.config.mjs +81 -81
- package/dist/templates/nextjs/gitignore +28 -28
- package/dist/templates/nextjs/package.json +68 -68
- package/dist/templates/nextjs/sitecore.config.ts.example +40 -40
- package/dist/templates/nextjs/tsconfig.json +40 -40
- package/dist/templates/nextjs-app-router/.cursor/rules/app-router-setup.mdc +116 -116
- package/dist/templates/nextjs-app-router/.cursor/rules/general.mdc +80 -80
- package/dist/templates/nextjs-app-router/.cursor/rules/javascript.mdc +112 -112
- package/dist/templates/nextjs-app-router/.cursor/rules/sitecore.mdc +174 -174
- package/dist/templates/nextjs-app-router/.env.container.example +27 -27
- package/dist/templates/nextjs-app-router/.env.remote.example +51 -51
- package/dist/templates/nextjs-app-router/.gitattributes +11 -11
- package/dist/templates/nextjs-app-router/.windsurfrules +290 -290
- package/dist/templates/nextjs-app-router/LLMs.txt +236 -236
- package/dist/templates/nextjs-app-router/eslint.config.mjs +29 -29
- package/dist/templates/nextjs-app-router/gitignore +31 -31
- package/dist/templates/nextjs-app-router/package.json +54 -54
- package/dist/templates/nextjs-app-router/postcss.config.mjs +5 -5
- package/dist/templates/nextjs-app-router/sitecore.config.ts.example +40 -40
- package/dist/templates/nextjs-app-router/src/app/globals.css +1 -1
- package/dist/templates/nextjs-app-router/tsconfig.json +48 -48
- package/package.json +2 -2
|
@@ -1,179 +1,179 @@
|
|
|
1
|
-
# Claude/Windsurf Guidance for Sitecore Content SDK Next.js Project
|
|
2
|
-
|
|
3
|
-
## Project Context
|
|
4
|
-
This is a Sitecore Content SDK application built with Next.js, TypeScript, and React. The project integrates with Sitecore XM Cloud for headless content management and follows modern web development best practices.
|
|
5
|
-
|
|
6
|
-
## Architecture Overview
|
|
7
|
-
- **Framework**: Next.js with Page Router
|
|
8
|
-
- **Language**: TypeScript with strict mode enabled
|
|
9
|
-
- **CMS**: Sitecore XM Cloud (headless)
|
|
10
|
-
- **SDK**: @sitecore-content-sdk for API integration
|
|
11
|
-
- **Styling**: CSS Modules or Tailwind CSS
|
|
12
|
-
- **State Management**: React Query/SWR for server state
|
|
13
|
-
|
|
14
|
-
## Development Principles
|
|
15
|
-
|
|
16
|
-
### Code Organization
|
|
17
|
-
- Use modular, feature-based architecture
|
|
18
|
-
- Separate concerns: components, utilities, types, hooks
|
|
19
|
-
- Follow Next.js Page Router conventions
|
|
20
|
-
- Implement proper error boundaries and loading states
|
|
21
|
-
|
|
22
|
-
### TypeScript Standards
|
|
23
|
-
- Enable strict mode and strict null checks
|
|
24
|
-
- Use proper type definitions for Sitecore fields and components
|
|
25
|
-
- Prefer type assertions over `any` type
|
|
26
|
-
- Implement discriminated unions for complex state management
|
|
27
|
-
|
|
28
|
-
### React Patterns
|
|
29
|
-
- Server Components for data fetching and static content
|
|
30
|
-
- Client Components only when interactivity is required
|
|
31
|
-
- Use React.memo for expensive components
|
|
32
|
-
- Implement proper dependency arrays in hooks
|
|
33
|
-
|
|
34
|
-
## Sitecore Integration Patterns
|
|
35
|
-
|
|
36
|
-
### Content Fetching
|
|
37
|
-
- Use SitecoreClient for all API calls
|
|
38
|
-
- Implement proper error handling with custom error classes
|
|
39
|
-
- Cache responses using React Query or SWR
|
|
40
|
-
- Handle preview vs. published content scenarios
|
|
41
|
-
|
|
42
|
-
### Component Development
|
|
43
|
-
- Always use Sitecore field components (Text, RichText, Image)
|
|
44
|
-
- Validate field existence before rendering
|
|
45
|
-
- Handle missing or empty fields gracefully
|
|
46
|
-
- Export components with proper TypeScript interfaces
|
|
47
|
-
|
|
48
|
-
### Field Handling
|
|
49
|
-
```typescript
|
|
50
|
-
interface ComponentProps {
|
|
51
|
-
fields: {
|
|
52
|
-
title: Field;
|
|
53
|
-
content: Field;
|
|
54
|
-
image: Field;
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// Always validate fields
|
|
59
|
-
<Text field={fields?.title} tag="h1" />
|
|
60
|
-
<RichText field={fields?.content} />
|
|
61
|
-
<Image field={fields?.image} />
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
## Performance Best Practices
|
|
65
|
-
|
|
66
|
-
### Optimization Strategies
|
|
67
|
-
- Use Next.js Image component for optimized images
|
|
68
|
-
- Implement proper loading states and error boundaries
|
|
69
|
-
- Cache expensive operations and API responses
|
|
70
|
-
- Lazy-load non-critical components and modules
|
|
71
|
-
- Leverage server-side rendering for better performance
|
|
72
|
-
|
|
73
|
-
### Memory Management
|
|
74
|
-
- Clean up subscriptions and event listeners
|
|
75
|
-
- Use useCallback and useMemo appropriately
|
|
76
|
-
- Avoid memory leaks in useEffect hooks
|
|
77
|
-
- Implement proper cleanup in custom hooks
|
|
78
|
-
|
|
79
|
-
## Security Guidelines
|
|
80
|
-
|
|
81
|
-
### Input Validation
|
|
82
|
-
- Sanitize all user inputs before processing
|
|
83
|
-
- Validate data at application boundaries
|
|
84
|
-
- Use type guards for runtime type checking
|
|
85
|
-
- Escape content when rendering to prevent XSS
|
|
86
|
-
|
|
87
|
-
### API Security
|
|
88
|
-
- Use HTTPS for all Sitecore connections
|
|
89
|
-
- Never expose API keys in client-side code
|
|
90
|
-
- Implement proper authentication and authorization
|
|
91
|
-
- Validate all data received from external sources
|
|
92
|
-
|
|
93
|
-
## Code Quality Standards
|
|
94
|
-
|
|
95
|
-
### Naming Conventions
|
|
96
|
-
- Variables/Functions: camelCase (getUserData, isLoading)
|
|
97
|
-
- Components: PascalCase (SitecoreComponent, PageLayout)
|
|
98
|
-
- Constants: UPPER_SNAKE_CASE (API_ENDPOINT, MAX_RETRIES)
|
|
99
|
-
- Types/Interfaces: PascalCase (ContentItem, LayoutProps)
|
|
100
|
-
|
|
101
|
-
### Error Handling
|
|
102
|
-
- Create custom error classes for different error types
|
|
103
|
-
- Implement proper error boundaries in React components
|
|
104
|
-
- Log errors appropriately for debugging
|
|
105
|
-
- Provide fallback content when components fail
|
|
106
|
-
|
|
107
|
-
### Testing Approach
|
|
108
|
-
- Write testable code with minimal dependencies
|
|
109
|
-
- Mock external services and Sitecore APIs
|
|
110
|
-
- Test component behavior, not implementation details
|
|
111
|
-
- Include tests for error scenarios and edge cases
|
|
112
|
-
|
|
113
|
-
## Development Workflow
|
|
114
|
-
|
|
115
|
-
### Environment Setup
|
|
116
|
-
1. Install dependencies: `npm install`
|
|
117
|
-
2. Configure environment variables (copy .env.example to .env.local)
|
|
118
|
-
3. Set up Sitecore API credentials
|
|
119
|
-
4. Start development server: `npm run dev`
|
|
120
|
-
|
|
121
|
-
### Build Process
|
|
122
|
-
- Use `npm run build` for production builds
|
|
123
|
-
- Enable TypeScript strict mode
|
|
124
|
-
- Run linting and type checking before commits
|
|
125
|
-
|
|
126
|
-
## Common Patterns and Examples
|
|
127
|
-
|
|
128
|
-
### Sitecore Component Structure
|
|
129
|
-
```typescript
|
|
130
|
-
interface HeroProps {
|
|
131
|
-
fields: {
|
|
132
|
-
title: Field;
|
|
133
|
-
subtitle: Field;
|
|
134
|
-
backgroundImage: Field;
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
export default function Hero({ fields }: HeroProps) {
|
|
139
|
-
return (
|
|
140
|
-
<section className="hero">
|
|
141
|
-
<Text field={fields?.title} tag="h1" />
|
|
142
|
-
<Text field={fields?.subtitle} tag="p" />
|
|
143
|
-
<Image field={fields?.backgroundImage} />
|
|
144
|
-
</section>
|
|
145
|
-
);
|
|
146
|
-
}
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
### API Integration
|
|
150
|
-
```typescript
|
|
151
|
-
import { SitecoreClient } from '@sitecore-content-sdk/nextjs/client';
|
|
152
|
-
import scConfig from 'sitecore.config';
|
|
153
|
-
|
|
154
|
-
const client = new SitecoreClient({
|
|
155
|
-
...scConfig,
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
async function fetchPageData(path: string) {
|
|
159
|
-
try {
|
|
160
|
-
const response = await client.getPage(path);
|
|
161
|
-
return response?.layout;
|
|
162
|
-
} catch (error) {
|
|
163
|
-
throw new SitecoreFetchError(`Failed to fetch page: ${path}`, error);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
## Best Practices Summary
|
|
169
|
-
|
|
170
|
-
1. **Always validate Sitecore fields** before rendering
|
|
171
|
-
2. **Use proper TypeScript types** for all components and functions
|
|
172
|
-
3. **Implement error boundaries** for robust error handling
|
|
173
|
-
4. **Cache API responses** to improve performance
|
|
174
|
-
5. **Follow Next.js conventions** for routing and data fetching
|
|
175
|
-
6. **Write testable code** with proper separation of concerns
|
|
176
|
-
7. **Use Sitecore field components** instead of manual rendering
|
|
177
|
-
8. **Implement proper loading states** for better UX
|
|
178
|
-
9. **Follow security best practices** for input validation
|
|
179
|
-
10. **Document public APIs** and complex functionality
|
|
1
|
+
# Claude/Windsurf Guidance for Sitecore Content SDK Next.js Project
|
|
2
|
+
|
|
3
|
+
## Project Context
|
|
4
|
+
This is a Sitecore Content SDK application built with Next.js, TypeScript, and React. The project integrates with Sitecore XM Cloud for headless content management and follows modern web development best practices.
|
|
5
|
+
|
|
6
|
+
## Architecture Overview
|
|
7
|
+
- **Framework**: Next.js with Page Router
|
|
8
|
+
- **Language**: TypeScript with strict mode enabled
|
|
9
|
+
- **CMS**: Sitecore XM Cloud (headless)
|
|
10
|
+
- **SDK**: @sitecore-content-sdk for API integration
|
|
11
|
+
- **Styling**: CSS Modules or Tailwind CSS
|
|
12
|
+
- **State Management**: React Query/SWR for server state
|
|
13
|
+
|
|
14
|
+
## Development Principles
|
|
15
|
+
|
|
16
|
+
### Code Organization
|
|
17
|
+
- Use modular, feature-based architecture
|
|
18
|
+
- Separate concerns: components, utilities, types, hooks
|
|
19
|
+
- Follow Next.js Page Router conventions
|
|
20
|
+
- Implement proper error boundaries and loading states
|
|
21
|
+
|
|
22
|
+
### TypeScript Standards
|
|
23
|
+
- Enable strict mode and strict null checks
|
|
24
|
+
- Use proper type definitions for Sitecore fields and components
|
|
25
|
+
- Prefer type assertions over `any` type
|
|
26
|
+
- Implement discriminated unions for complex state management
|
|
27
|
+
|
|
28
|
+
### React Patterns
|
|
29
|
+
- Server Components for data fetching and static content
|
|
30
|
+
- Client Components only when interactivity is required
|
|
31
|
+
- Use React.memo for expensive components
|
|
32
|
+
- Implement proper dependency arrays in hooks
|
|
33
|
+
|
|
34
|
+
## Sitecore Integration Patterns
|
|
35
|
+
|
|
36
|
+
### Content Fetching
|
|
37
|
+
- Use SitecoreClient for all API calls
|
|
38
|
+
- Implement proper error handling with custom error classes
|
|
39
|
+
- Cache responses using React Query or SWR
|
|
40
|
+
- Handle preview vs. published content scenarios
|
|
41
|
+
|
|
42
|
+
### Component Development
|
|
43
|
+
- Always use Sitecore field components (Text, RichText, Image)
|
|
44
|
+
- Validate field existence before rendering
|
|
45
|
+
- Handle missing or empty fields gracefully
|
|
46
|
+
- Export components with proper TypeScript interfaces
|
|
47
|
+
|
|
48
|
+
### Field Handling
|
|
49
|
+
```typescript
|
|
50
|
+
interface ComponentProps {
|
|
51
|
+
fields: {
|
|
52
|
+
title: Field;
|
|
53
|
+
content: Field;
|
|
54
|
+
image: Field;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Always validate fields
|
|
59
|
+
<Text field={fields?.title} tag="h1" />
|
|
60
|
+
<RichText field={fields?.content} />
|
|
61
|
+
<Image field={fields?.image} />
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Performance Best Practices
|
|
65
|
+
|
|
66
|
+
### Optimization Strategies
|
|
67
|
+
- Use Next.js Image component for optimized images
|
|
68
|
+
- Implement proper loading states and error boundaries
|
|
69
|
+
- Cache expensive operations and API responses
|
|
70
|
+
- Lazy-load non-critical components and modules
|
|
71
|
+
- Leverage server-side rendering for better performance
|
|
72
|
+
|
|
73
|
+
### Memory Management
|
|
74
|
+
- Clean up subscriptions and event listeners
|
|
75
|
+
- Use useCallback and useMemo appropriately
|
|
76
|
+
- Avoid memory leaks in useEffect hooks
|
|
77
|
+
- Implement proper cleanup in custom hooks
|
|
78
|
+
|
|
79
|
+
## Security Guidelines
|
|
80
|
+
|
|
81
|
+
### Input Validation
|
|
82
|
+
- Sanitize all user inputs before processing
|
|
83
|
+
- Validate data at application boundaries
|
|
84
|
+
- Use type guards for runtime type checking
|
|
85
|
+
- Escape content when rendering to prevent XSS
|
|
86
|
+
|
|
87
|
+
### API Security
|
|
88
|
+
- Use HTTPS for all Sitecore connections
|
|
89
|
+
- Never expose API keys in client-side code
|
|
90
|
+
- Implement proper authentication and authorization
|
|
91
|
+
- Validate all data received from external sources
|
|
92
|
+
|
|
93
|
+
## Code Quality Standards
|
|
94
|
+
|
|
95
|
+
### Naming Conventions
|
|
96
|
+
- Variables/Functions: camelCase (getUserData, isLoading)
|
|
97
|
+
- Components: PascalCase (SitecoreComponent, PageLayout)
|
|
98
|
+
- Constants: UPPER_SNAKE_CASE (API_ENDPOINT, MAX_RETRIES)
|
|
99
|
+
- Types/Interfaces: PascalCase (ContentItem, LayoutProps)
|
|
100
|
+
|
|
101
|
+
### Error Handling
|
|
102
|
+
- Create custom error classes for different error types
|
|
103
|
+
- Implement proper error boundaries in React components
|
|
104
|
+
- Log errors appropriately for debugging
|
|
105
|
+
- Provide fallback content when components fail
|
|
106
|
+
|
|
107
|
+
### Testing Approach
|
|
108
|
+
- Write testable code with minimal dependencies
|
|
109
|
+
- Mock external services and Sitecore APIs
|
|
110
|
+
- Test component behavior, not implementation details
|
|
111
|
+
- Include tests for error scenarios and edge cases
|
|
112
|
+
|
|
113
|
+
## Development Workflow
|
|
114
|
+
|
|
115
|
+
### Environment Setup
|
|
116
|
+
1. Install dependencies: `npm install`
|
|
117
|
+
2. Configure environment variables (copy .env.example to .env.local)
|
|
118
|
+
3. Set up Sitecore API credentials
|
|
119
|
+
4. Start development server: `npm run dev`
|
|
120
|
+
|
|
121
|
+
### Build Process
|
|
122
|
+
- Use `npm run build` for production builds
|
|
123
|
+
- Enable TypeScript strict mode
|
|
124
|
+
- Run linting and type checking before commits
|
|
125
|
+
|
|
126
|
+
## Common Patterns and Examples
|
|
127
|
+
|
|
128
|
+
### Sitecore Component Structure
|
|
129
|
+
```typescript
|
|
130
|
+
interface HeroProps {
|
|
131
|
+
fields: {
|
|
132
|
+
title: Field;
|
|
133
|
+
subtitle: Field;
|
|
134
|
+
backgroundImage: Field;
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export default function Hero({ fields }: HeroProps) {
|
|
139
|
+
return (
|
|
140
|
+
<section className="hero">
|
|
141
|
+
<Text field={fields?.title} tag="h1" />
|
|
142
|
+
<Text field={fields?.subtitle} tag="p" />
|
|
143
|
+
<Image field={fields?.backgroundImage} />
|
|
144
|
+
</section>
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### API Integration
|
|
150
|
+
```typescript
|
|
151
|
+
import { SitecoreClient } from '@sitecore-content-sdk/nextjs/client';
|
|
152
|
+
import scConfig from 'sitecore.config';
|
|
153
|
+
|
|
154
|
+
const client = new SitecoreClient({
|
|
155
|
+
...scConfig,
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
async function fetchPageData(path: string) {
|
|
159
|
+
try {
|
|
160
|
+
const response = await client.getPage(path);
|
|
161
|
+
return response?.layout;
|
|
162
|
+
} catch (error) {
|
|
163
|
+
throw new SitecoreFetchError(`Failed to fetch page: ${path}`, error);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## Best Practices Summary
|
|
169
|
+
|
|
170
|
+
1. **Always validate Sitecore fields** before rendering
|
|
171
|
+
2. **Use proper TypeScript types** for all components and functions
|
|
172
|
+
3. **Implement error boundaries** for robust error handling
|
|
173
|
+
4. **Cache API responses** to improve performance
|
|
174
|
+
5. **Follow Next.js conventions** for routing and data fetching
|
|
175
|
+
6. **Write testable code** with proper separation of concerns
|
|
176
|
+
7. **Use Sitecore field components** instead of manual rendering
|
|
177
|
+
8. **Implement proper loading states** for better UX
|
|
178
|
+
9. **Follow security best practices** for input validation
|
|
179
|
+
10. **Document public APIs** and complex functionality
|
|
@@ -1,81 +1,81 @@
|
|
|
1
|
-
// packages/create-content-sdk-app/src/templates/nextjs/eslint.config.mjs
|
|
2
|
-
import { defineConfig } from 'eslint/config'
|
|
3
|
-
import js from '@eslint/js'
|
|
4
|
-
import * as nextEslintPlugin from '@next/eslint-plugin-next'
|
|
5
|
-
import tsParser from '@typescript-eslint/parser'
|
|
6
|
-
import * as tsEslintPlugin from '@typescript-eslint/eslint-plugin'
|
|
7
|
-
import * as importEslintPlugin from 'eslint-plugin-import'
|
|
8
|
-
import * as reactHooksEslintPlugin from 'eslint-plugin-react-hooks'
|
|
9
|
-
import globals from 'globals'
|
|
10
|
-
|
|
11
|
-
// Normalize ESM/CJS shapes to plugin objects
|
|
12
|
-
const nextPlugin = nextEslintPlugin.default ?? nextEslintPlugin
|
|
13
|
-
const tsPlugin = tsEslintPlugin.default ?? tsEslintPlugin
|
|
14
|
-
const importPlugin = importEslintPlugin.default ?? importEslintPlugin
|
|
15
|
-
const reactHooksPlugin = reactHooksEslintPlugin.default ?? reactHooksEslintPlugin
|
|
16
|
-
|
|
17
|
-
export default defineConfig([
|
|
18
|
-
// ignores
|
|
19
|
-
{ ignores: ['node_modules/**', '.next/**', 'dist/**', 'build/**', 'coverage/**'] },
|
|
20
|
-
|
|
21
|
-
// core ESLint recommended
|
|
22
|
-
js.configs.recommended,
|
|
23
|
-
|
|
24
|
-
// register plugins (applies to all files)
|
|
25
|
-
{
|
|
26
|
-
plugins: {
|
|
27
|
-
'@next/next': nextPlugin,
|
|
28
|
-
'@typescript-eslint': tsPlugin,
|
|
29
|
-
import: importPlugin,
|
|
30
|
-
'react-hooks': reactHooksPlugin,
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
|
|
34
|
-
// project rules
|
|
35
|
-
{
|
|
36
|
-
files: ['**/*.{js,jsx,ts,tsx}'],
|
|
37
|
-
languageOptions: {
|
|
38
|
-
parser: tsParser,
|
|
39
|
-
parserOptions: {
|
|
40
|
-
ecmaVersion: 2021,
|
|
41
|
-
sourceType: 'module',
|
|
42
|
-
ecmaFeatures: { jsx: true },
|
|
43
|
-
},
|
|
44
|
-
globals: {
|
|
45
|
-
...(globals.node ?? {}),
|
|
46
|
-
...(globals.browser ?? {}),
|
|
47
|
-
...(globals.es2021 ?? {}), // guarded to avoid "Cannot convert undefined or null to object"
|
|
48
|
-
URL: 'readonly',
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
settings: {
|
|
52
|
-
'import/resolver': { typescript: {} },
|
|
53
|
-
},
|
|
54
|
-
rules: {
|
|
55
|
-
// Next.js
|
|
56
|
-
...(nextPlugin.configs?.recommended?.rules ?? {}),
|
|
57
|
-
...(nextPlugin.configs?.['core-web-vitals']?.rules ?? {}),
|
|
58
|
-
'@next/next/no-html-link-for-pages': 'off',
|
|
59
|
-
'@next/next/no-img-element': 'off',
|
|
60
|
-
'@next/next/no-sync-scripts': 'off',
|
|
61
|
-
'@next/next/no-assign-module-variable': 'off',
|
|
62
|
-
|
|
63
|
-
// TypeScript
|
|
64
|
-
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
|
|
65
|
-
'no-unused-vars': 'off',
|
|
66
|
-
'no-undef': 'off',
|
|
67
|
-
|
|
68
|
-
// Plugins
|
|
69
|
-
'import/no-anonymous-default-export': 'error',
|
|
70
|
-
'react-hooks/exhaustive-deps': 'warn',
|
|
71
|
-
'react-hooks/rules-of-hooks': 'error',
|
|
72
|
-
|
|
73
|
-
// Preferences
|
|
74
|
-
'prefer-const': 'error',
|
|
75
|
-
'no-var': 'error',
|
|
76
|
-
|
|
77
|
-
// Temporary: ignore escapes in strings/regex to align with new-starter components
|
|
78
|
-
'no-useless-escape': 'off',
|
|
79
|
-
},
|
|
80
|
-
},
|
|
81
|
-
])
|
|
1
|
+
// packages/create-content-sdk-app/src/templates/nextjs/eslint.config.mjs
|
|
2
|
+
import { defineConfig } from 'eslint/config'
|
|
3
|
+
import js from '@eslint/js'
|
|
4
|
+
import * as nextEslintPlugin from '@next/eslint-plugin-next'
|
|
5
|
+
import tsParser from '@typescript-eslint/parser'
|
|
6
|
+
import * as tsEslintPlugin from '@typescript-eslint/eslint-plugin'
|
|
7
|
+
import * as importEslintPlugin from 'eslint-plugin-import'
|
|
8
|
+
import * as reactHooksEslintPlugin from 'eslint-plugin-react-hooks'
|
|
9
|
+
import globals from 'globals'
|
|
10
|
+
|
|
11
|
+
// Normalize ESM/CJS shapes to plugin objects
|
|
12
|
+
const nextPlugin = nextEslintPlugin.default ?? nextEslintPlugin
|
|
13
|
+
const tsPlugin = tsEslintPlugin.default ?? tsEslintPlugin
|
|
14
|
+
const importPlugin = importEslintPlugin.default ?? importEslintPlugin
|
|
15
|
+
const reactHooksPlugin = reactHooksEslintPlugin.default ?? reactHooksEslintPlugin
|
|
16
|
+
|
|
17
|
+
export default defineConfig([
|
|
18
|
+
// ignores
|
|
19
|
+
{ ignores: ['node_modules/**', '.next/**', 'dist/**', 'build/**', 'coverage/**'] },
|
|
20
|
+
|
|
21
|
+
// core ESLint recommended
|
|
22
|
+
js.configs.recommended,
|
|
23
|
+
|
|
24
|
+
// register plugins (applies to all files)
|
|
25
|
+
{
|
|
26
|
+
plugins: {
|
|
27
|
+
'@next/next': nextPlugin,
|
|
28
|
+
'@typescript-eslint': tsPlugin,
|
|
29
|
+
import: importPlugin,
|
|
30
|
+
'react-hooks': reactHooksPlugin,
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
// project rules
|
|
35
|
+
{
|
|
36
|
+
files: ['**/*.{js,jsx,ts,tsx}'],
|
|
37
|
+
languageOptions: {
|
|
38
|
+
parser: tsParser,
|
|
39
|
+
parserOptions: {
|
|
40
|
+
ecmaVersion: 2021,
|
|
41
|
+
sourceType: 'module',
|
|
42
|
+
ecmaFeatures: { jsx: true },
|
|
43
|
+
},
|
|
44
|
+
globals: {
|
|
45
|
+
...(globals.node ?? {}),
|
|
46
|
+
...(globals.browser ?? {}),
|
|
47
|
+
...(globals.es2021 ?? {}), // guarded to avoid "Cannot convert undefined or null to object"
|
|
48
|
+
URL: 'readonly',
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
settings: {
|
|
52
|
+
'import/resolver': { typescript: {} },
|
|
53
|
+
},
|
|
54
|
+
rules: {
|
|
55
|
+
// Next.js
|
|
56
|
+
...(nextPlugin.configs?.recommended?.rules ?? {}),
|
|
57
|
+
...(nextPlugin.configs?.['core-web-vitals']?.rules ?? {}),
|
|
58
|
+
'@next/next/no-html-link-for-pages': 'off',
|
|
59
|
+
'@next/next/no-img-element': 'off',
|
|
60
|
+
'@next/next/no-sync-scripts': 'off',
|
|
61
|
+
'@next/next/no-assign-module-variable': 'off',
|
|
62
|
+
|
|
63
|
+
// TypeScript
|
|
64
|
+
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
|
|
65
|
+
'no-unused-vars': 'off',
|
|
66
|
+
'no-undef': 'off',
|
|
67
|
+
|
|
68
|
+
// Plugins
|
|
69
|
+
'import/no-anonymous-default-export': 'error',
|
|
70
|
+
'react-hooks/exhaustive-deps': 'warn',
|
|
71
|
+
'react-hooks/rules-of-hooks': 'error',
|
|
72
|
+
|
|
73
|
+
// Preferences
|
|
74
|
+
'prefer-const': 'error',
|
|
75
|
+
'no-var': 'error',
|
|
76
|
+
|
|
77
|
+
// Temporary: ignore escapes in strings/regex to align with new-starter components
|
|
78
|
+
'no-useless-escape': 'off',
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
])
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
# See https://help.github.com/ignore-files/ for more about ignoring files.
|
|
2
|
-
|
|
3
|
-
# dependencies
|
|
4
|
-
/node_modules
|
|
5
|
-
|
|
6
|
-
# next.js
|
|
7
|
-
/.next*/
|
|
8
|
-
/out/
|
|
9
|
-
|
|
10
|
-
# misc
|
|
11
|
-
.DS_Store
|
|
12
|
-
|
|
13
|
-
# local env files
|
|
14
|
-
.env.local
|
|
15
|
-
.env.*.local
|
|
16
|
-
.env
|
|
17
|
-
|
|
18
|
-
# Log files
|
|
19
|
-
*.log*
|
|
20
|
-
|
|
21
|
-
# vercel
|
|
22
|
-
.vercel
|
|
23
|
-
|
|
24
|
-
# sitecore temp files
|
|
25
|
-
.sitecore/*
|
|
26
|
-
# except for component-map
|
|
27
|
-
!.sitecore/component-map.ts
|
|
28
|
-
!.sitecore/import-map.ts
|
|
1
|
+
# See https://help.github.com/ignore-files/ for more about ignoring files.
|
|
2
|
+
|
|
3
|
+
# dependencies
|
|
4
|
+
/node_modules
|
|
5
|
+
|
|
6
|
+
# next.js
|
|
7
|
+
/.next*/
|
|
8
|
+
/out/
|
|
9
|
+
|
|
10
|
+
# misc
|
|
11
|
+
.DS_Store
|
|
12
|
+
|
|
13
|
+
# local env files
|
|
14
|
+
.env.local
|
|
15
|
+
.env.*.local
|
|
16
|
+
.env
|
|
17
|
+
|
|
18
|
+
# Log files
|
|
19
|
+
*.log*
|
|
20
|
+
|
|
21
|
+
# vercel
|
|
22
|
+
.vercel
|
|
23
|
+
|
|
24
|
+
# sitecore temp files
|
|
25
|
+
.sitecore/*
|
|
26
|
+
# except for component-map
|
|
27
|
+
!.sitecore/component-map.ts
|
|
28
|
+
!.sitecore/import-map.ts
|