Primeiro commit do projeto Angular
This commit is contained in:
+56
@@ -0,0 +1,56 @@
|
||||
<% if (frontmatter) { %><%= frontmatter %>
|
||||
<% } %>
|
||||
You are an expert in TypeScript, Angular, and scalable web application development. You write functional, maintainable, performant, and accessible code following Angular and TypeScript best practices.
|
||||
|
||||
## TypeScript Best Practices
|
||||
|
||||
- Use strict type checking
|
||||
- Prefer type inference when the type is obvious
|
||||
- Avoid the `any` type; use `unknown` when type is uncertain
|
||||
|
||||
## Angular Best Practices
|
||||
|
||||
- Always use standalone components over NgModules
|
||||
- Must NOT set `standalone: true` inside Angular decorators. It's the default in Angular v20+.
|
||||
- Use signals for state management
|
||||
- Implement lazy loading for feature routes
|
||||
- Do NOT use the `@HostBinding` and `@HostListener` decorators. Put host bindings inside the `host` object of the `@Component` or `@Directive` decorator instead
|
||||
- Use `NgOptimizedImage` for all static images.
|
||||
- `NgOptimizedImage` does not work for inline base64 images.
|
||||
|
||||
## Accessibility Requirements
|
||||
|
||||
- It MUST pass all AXE checks.
|
||||
- It MUST follow all WCAG AA minimums, including focus management, color contrast, and ARIA attributes.
|
||||
|
||||
### Components
|
||||
|
||||
- Keep components small and focused on a single responsibility
|
||||
- Use `input()` and `output()` functions instead of decorators
|
||||
- Use `computed()` for derived state
|
||||
- Set `changeDetection: ChangeDetectionStrategy.OnPush` in `@Component` decorator
|
||||
- Prefer inline templates for small components
|
||||
- Prefer Reactive forms instead of Template-driven ones
|
||||
- Do NOT use `ngClass`, use `class` bindings instead
|
||||
- Do NOT use `ngStyle`, use `style` bindings instead
|
||||
- When using external templates/styles, use paths relative to the component TS file.
|
||||
|
||||
## State Management
|
||||
|
||||
- Use signals for local component state
|
||||
- Use `computed()` for derived state
|
||||
- Keep state transformations pure and predictable
|
||||
- Do NOT use `mutate` on signals, use `update` or `set` instead
|
||||
|
||||
## Templates
|
||||
|
||||
- Keep templates simple and avoid complex logic
|
||||
- Use native control flow (`@if`, `@for`, `@switch`) instead of `*ngIf`, `*ngFor`, `*ngSwitch`
|
||||
- Use the async pipe to handle observables
|
||||
- Do not assume globals like (`new Date()`) are available.
|
||||
|
||||
## Services
|
||||
|
||||
- Design services around a single responsibility
|
||||
- Use the `providedIn: 'root'` option for singleton services
|
||||
- Use the `inject()` function instead of constructor injection
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright Google LLC All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.dev/license
|
||||
*/
|
||||
import { Rule } from '@angular-devkit/schematics';
|
||||
import { Schema as ConfigOptions } from './schema';
|
||||
export default function ({ tool }: ConfigOptions): Rule;
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
"use strict";
|
||||
/**
|
||||
* @license
|
||||
* Copyright Google LLC All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.dev/license
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = default_1;
|
||||
const schematics_1 = require("@angular-devkit/schematics");
|
||||
const schema_1 = require("./schema");
|
||||
const AI_TOOLS = {
|
||||
agents: {
|
||||
rulesName: 'AGENTS.md',
|
||||
directory: '.',
|
||||
},
|
||||
gemini: {
|
||||
rulesName: 'GEMINI.md',
|
||||
directory: '.gemini',
|
||||
},
|
||||
claude: {
|
||||
rulesName: 'CLAUDE.md',
|
||||
directory: '.claude',
|
||||
},
|
||||
copilot: {
|
||||
rulesName: 'copilot-instructions.md',
|
||||
directory: '.github',
|
||||
},
|
||||
windsurf: {
|
||||
rulesName: 'guidelines.md',
|
||||
directory: '.windsurf/rules',
|
||||
},
|
||||
jetbrains: {
|
||||
rulesName: 'guidelines.md',
|
||||
directory: '.junie',
|
||||
},
|
||||
// Cursor file has a front matter section.
|
||||
cursor: {
|
||||
rulesName: 'cursor.mdc',
|
||||
directory: '.cursor/rules',
|
||||
frontmatter: `---\ncontext: true\npriority: high\nscope: project\n---`,
|
||||
},
|
||||
};
|
||||
function default_1({ tool }) {
|
||||
return (tree, context) => {
|
||||
if (!tool) {
|
||||
return (0, schematics_1.noop)();
|
||||
}
|
||||
const rules = tool
|
||||
.filter((tool) => tool !== schema_1.Tool.None)
|
||||
.map((selectedTool) => {
|
||||
const { rulesName, directory, frontmatter } = AI_TOOLS[selectedTool];
|
||||
const path = `${directory}/${rulesName}`;
|
||||
if (tree.exists(path)) {
|
||||
const toolName = schematics_1.strings.classify(selectedTool);
|
||||
context.logger.warn(`Skipping configuration file for '${toolName}' at '${path}' because it already exists.\n` +
|
||||
'This is to prevent overwriting a potentially customized file. ' +
|
||||
'If you want to regenerate it with Angular recommended defaults, please delete the existing file and re-run the command.\n' +
|
||||
'You can review the latest recommendations at https://angular.dev/ai/develop-with-ai.');
|
||||
return (0, schematics_1.noop)();
|
||||
}
|
||||
return (0, schematics_1.mergeWith)((0, schematics_1.apply)((0, schematics_1.url)('./files'), [
|
||||
(0, schematics_1.applyTemplates)({
|
||||
...schematics_1.strings,
|
||||
rulesName,
|
||||
frontmatter,
|
||||
}),
|
||||
(0, schematics_1.move)(directory),
|
||||
]));
|
||||
});
|
||||
return (0, schematics_1.chain)(rules);
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=index.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAsDH,4BAsCC;AA1FD,2DAUoC;AACpC,qCAAyD;AAEzD,MAAM,QAAQ,GAA2D;IACvE,MAAM,EAAE;QACN,SAAS,EAAE,WAAW;QACtB,SAAS,EAAE,GAAG;KACf;IACD,MAAM,EAAE;QACN,SAAS,EAAE,WAAW;QACtB,SAAS,EAAE,SAAS;KACrB;IACD,MAAM,EAAE;QACN,SAAS,EAAE,WAAW;QACtB,SAAS,EAAE,SAAS;KACrB;IACD,OAAO,EAAE;QACP,SAAS,EAAE,yBAAyB;QACpC,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S;oBACT,WAAW;iBACZ,CAAC;gBACF,IAAA,iBAAI,EAAC,SAAS,CAAC;aAChB,CAAC,CACH,CAAC;QACJ,CAAC,CAAC,CAAC;QAEL,OAAO,IAAA,kBAAK,EAAC,KAAK,CAAC,CAAC;IACtB,CAAC,CAAC;AACJ,CAAC"}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* Generates AI configuration files for Angular projects. This schematic creates
|
||||
* configuration files that help AI tools follow Angular best practices, improving the
|
||||
* quality of AI-generated code and suggestions.
|
||||
*/
|
||||
export type Schema = {
|
||||
/**
|
||||
* Specifies which AI tools to generate configuration files for. These file are used to
|
||||
* improve the outputs of AI tools by following the best practices.
|
||||
*/
|
||||
tool?: Tool[];
|
||||
};
|
||||
export declare enum Tool {
|
||||
Agents = "agents",
|
||||
Claude = "claude",
|
||||
Copilot = "copilot",
|
||||
Cursor = "cursor",
|
||||
Gemini = "gemini",
|
||||
Jetbrains = "jetbrains",
|
||||
None = "none",
|
||||
Windsurf = "windsurf"
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
// THIS FILE IS AUTOMATICALLY GENERATED. TO UPDATE THIS FILE YOU NEED TO CHANGE THE
|
||||
// CORRESPONDING JSON SCHEMA FILE, THEN RUN devkit-admin build (or bazel build ...).
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Tool = void 0;
|
||||
var Tool;
|
||||
(function (Tool) {
|
||||
Tool["Agents"] = "agents";
|
||||
Tool["Claude"] = "claude";
|
||||
Tool["Copilot"] = "copilot";
|
||||
Tool["Cursor"] = "cursor";
|
||||
Tool["Gemini"] = "gemini";
|
||||
Tool["Jetbrains"] = "jetbrains";
|
||||
Tool["None"] = "none";
|
||||
Tool["Windsurf"] = "windsurf";
|
||||
})(Tool || (exports.Tool = Tool = {}));
|
||||
//# sourceMappingURL=schema.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"schema.js","sourceRoot":"","sources":["schema.ts"],"names":[],"mappings":";AACA,mFAAmF;AACnF,oFAAoF;;;AAepF,IAAY,IASX;AATD,WAAY,IAAI;IACZ,yBAAiB,CAAA;IACjB,yBAAiB,CAAA;IACjB,2BAAmB,CAAA;IACnB,yBAAiB,CAAA;IACjB,yBAAiB,CAAA;IACjB,+BAAuB,CAAA;IACvB,qBAAa,CAAA;IACb,6BAAqB,CAAA;AACzB,CAAC,EATW,IAAI,oBAAJ,IAAI,QASf"}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema",
|
||||
"$id": "SchematicsAngularAIConfig",
|
||||
"title": "Angular AI Config File Options Schema",
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"description": "Generates AI configuration files for Angular projects. This schematic creates configuration files that help AI tools follow Angular best practices, improving the quality of AI-generated code and suggestions.",
|
||||
"properties": {
|
||||
"tool": {
|
||||
"type": "array",
|
||||
"uniqueItems": true,
|
||||
"default": ["none"],
|
||||
"x-prompt": {
|
||||
"message": "Which AI tools do you want to configure with Angular best practices? https://angular.dev/ai/develop-with-ai",
|
||||
"type": "list",
|
||||
"items": [
|
||||
{
|
||||
"value": "none",
|
||||
"label": "None"
|
||||
},
|
||||
{
|
||||
"value": "agents",
|
||||
"label": "Agents.md [ https://agents.md/ ]"
|
||||
},
|
||||
{
|
||||
"value": "claude",
|
||||
"label": "Claude [ https://docs.anthropic.com/en/docs/claude-code/memory ]"
|
||||
},
|
||||
{
|
||||
"value": "cursor",
|
||||
"label": "Cursor [ https://docs.cursor.com/en/context/rules ]"
|
||||
},
|
||||
{
|
||||
"value": "gemini",
|
||||
"label": "Gemini [ https://ai.google.dev/gemini-api/docs ]"
|
||||
},
|
||||
{
|
||||
"value": "copilot",
|
||||
"label": "GitHub Copilot [ https://code.visualstudio.com/docs/copilot/copilot-customization ]"
|
||||
},
|
||||
{
|
||||
"value": "jetbrains",
|
||||
"label": "JetBrains AI [ https://www.jetbrains.com/help/junie/customize-guidelines.html ]"
|
||||
},
|
||||
{
|
||||
"value": "windsurf",
|
||||
"label": "Windsurf [ https://docs.windsurf.com/windsurf/cascade/memories#rules ]"
|
||||
}
|
||||
]
|
||||
},
|
||||
"description": "Specifies which AI tools to generate configuration files for. These file are used to improve the outputs of AI tools by following the best practices.",
|
||||
"items": {
|
||||
"type": "string",
|
||||
"enum": ["none", "gemini", "copilot", "claude", "cursor", "jetbrains", "windsurf", "agents"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user