javascript-runtime
Skill9 starsChanged 8 months agoMITView on GitHub
JavaScript toolchain configuration and best practices. Use when setting up ESLint, Prettier, Vitest, npm scripts, Node.js conventions or JavaScript project standards.
- Reads credentials
- Installs packages
In this repository21 other files it gives its agents.
- aws-apiSkill
- aws-architectureSkill
- aws-cdkSkill
- aws-cloudfrontSkill
- aws-cost-operationsSkill
- aws-diagramsSkill
- aws-dynamodbSkill
- aws-ec2Skill
- aws-lambda-pythonSkill
- aws-lambda-typescriptSkill
- aws-observabilitySkill
- aws-rdsSkill
- aws-s3Skill
- aws-securitySkill
- aws-serverlessSkill
- aws-terraformSkill
- aws-testingSkill
- find-skillsSkill
- orbit-bootstrapSkill
- python-runtimeSkill
- typescript-runtimeSkill
The file
Files
JavaScript Runtime
Skill para configurar y mantener toolchains JavaScript modernos: ESLint, Prettier, Vitest, scripts npm, convenciones Node.js, gestión de dependencias y estándares de proyecto.
Principios fundamentales
- Node.js 20+ como runtime mínimo (LTS activo).
- ESM (
"type": "module") como formato de módulos por defecto en proyectos nuevos. - ESLint + Prettier como estándar de linting y formato. Sin excepciones.
- Vitest como test runner (rápido, compatible con Jest API, ESM nativo).
package-lock.jsonsiempre commiteado.npm cien CI,npm installen desarrollo.
Estructura de proyecto recomendada
proyecto/
├── src/
│ ├── handlers/ # Entry points (Lambda handlers, API routes)
│ ├── services/ # Lógica de negocio
│ ├── repositories/ # Acceso a datos
│ ├── utils/ # Utilidades compartidas
│ └── index.js # Export principal
├── tests/
│ ├── unit/
│ └── integration/
├── .eslintrc.cjs
├── .prettierrc
├── vitest.config.js
├── package.json
└── README.mdpackage.json recomendado
{
"name": "mi-proyecto",
"version": "1.0.0",
"type": "module",
"engines": { "node": ">=20.0.0" },
"scripts": {
"lint": "eslint src/ tests/",
"lint:fix": "eslint src/ tests/ --fix",
"format": "prettier --write .",
"format:check": "prettier --check .",
"test": "vitest run",
"test:watch": "vitest",
"test:coverage": "vitest run --coverage",
"typecheck": "tsc --noEmit"
},
"devDependencies": {
"eslint": "^9.0.0",
"@eslint/js": "^9.0.0",
"prettier": "^3.3.0",
"vitest": "^2.0.0",
"@vitest/coverage-v8": "^2.0.0"
}
}ESLint (flat config, v9+)
// eslint.config.js
import js from '@eslint/js';
export default [
js.configs.recommended,
{
rules: {
'no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
'no-console': ['warn', { allow: ['warn', 'error'] }],
'prefer-const': 'error',
'no-var': 'error',
'eqeqeq': ['error', 'always'],
'curly': ['error', 'all'],
'no-throw-literal': 'error',
},
},
{
ignores: ['dist/', 'node_modules/', 'coverage/'],
},
];Prettier
// .prettierrc
{
"semi": true,
"singleQuote": true,
"trailingComma": "all",
"printWidth": 100,
"tabWidth": 2,
"arrowParens": "always",
"endOfLine": "lf"
}Vitest
// vitest.config.js
import { defineConfig } from 'vitest/config';
export default defineConfig({
test: {
globals: true,
environment: 'node',
include: ['tests/**/*.test.js'],
coverage: {
provider: 'v8',
reporter: ['text', 'lcov'],
include: ['src/**/*.js'],
exclude: ['src/**/index.js'],
thresholds: {
statements: 80,
branches: 80,
functions: 80,
lines: 80,
},
},
},
});Patrones de test
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { OrderService } from '../src/services/order.js';
describe('OrderService', () => {
const mockRepo = { save: vi.fn(), findById: vi.fn() };
beforeEach(() => vi.clearAllMocks());
it('should create order with valid data', async () => {
mockRepo.save.mockResolvedValue(undefined);
const service = new OrderService(mockRepo);
const result = await service.create({ item: 'laptop', quantity: 1 });
expect(result).toHaveProperty('id');
expect(mockRepo.save).toHaveBeenCalledOnce();
});
it('should throw on invalid quantity', async () => {
const service = new OrderService(mockRepo);
await expect(service.create({ item: 'laptop', quantity: -1 }))
.rejects.toThrow('quantity must be positive');
});
});Convenciones Node.js
Manejo de errores
// Errores custom con código
class AppError extends Error {
constructor(code, message, statusCode = 400) {
super(message);
this.name = 'AppError';
this.code = code;
this.statusCode = statusCode;
}
}
// Nunca silenciar errores
try {
await riskyOperation();
} catch (error) {
logger.error('Operation failed', { error: error.message, stack: error.stack });
throw new AppError('OPERATION_FAILED', 'Could not complete operation', 500);
}Async/await (nunca callbacks)
// ✅ Correcto
const data = await fetchData();
const results = await Promise.all(items.map((item) => processItem(item)));
// ❌ Incorrecto
fetchData((err, data) => { /* callback hell */ });Variables de entorno
// Validar al inicio, no en cada uso
const config = {
tableName: requireEnv('TABLE_NAME'),
stage: requireEnv('STAGE'),
logLevel: process.env.LOG_LEVEL ?? 'INFO',
};
function requireEnv(name) {
const value = process.env[name];
if (!value) { throw new Error(`Missing required env var: ${name}`); }
return value;
}Gestión de dependencias
# Instalar dependencias (desarrollo)
npm install
# Instalar dependencias (CI - reproducible)
npm ci
# Agregar dependencia de producción
npm install zod
# Agregar dependencia de desarrollo
npm install --save-dev vitest
# Auditar vulnerabilidades
npm audit
# Actualizar dependencias (minor/patch)
npm updateReglas de dependencias
package-lock.jsonsiempre commiteado.npm cien CI/CD (instala exactamente lo del lockfile).npm auditen CI para detectar vulnerabilidades.- Separar
dependencies(producción) dedevDependencies(desarrollo/test). - Revisar dependencias nuevas antes de instalar (tamaño, mantenimiento, licencia).
.gitignore
node_modules/
dist/
coverage/
.env
.env.local
*.logAnti-patrones a evitar
- ❌
varen lugar deconst/let. - ❌ Callbacks en lugar de async/await.
- ❌
==en lugar de===. - ❌
console.logpara logging en producción (usar logger estructurado). - ❌ No validar variables de entorno al inicio.
- ❌
require()en proyectos ESM (usarimport). - ❌ Dependencias sin lockfile commiteado.
- ❌
npm installen CI (usarnpm ci). - ❌ No tener ESLint ni Prettier configurados.
- ❌ Tests sin assertions.
- ❌ Ignorar
npm auditwarnings.
Checklist de proyecto JavaScript
- Node.js 20+ como runtime.
"type": "module"en package.json.- ESLint v9+ con flat config.
- Prettier configurado.
- Vitest con coverage mínimo 80%.
package-lock.jsoncommiteado.- Scripts: lint, format, test, test:coverage.
- Variables de entorno validadas al inicio.
- Async/await en lugar de callbacks.
.gitignorecon node_modules, dist, coverage.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

