Skip to content
Back to skills

Code Style Node

ASecurity

How TypeScript and JavaScript are written in a Node project, with or without a framework. Use when writing, generating or reviewing TS or JS code, or when setting up or changing Prettier, ESLint, import order, tsconfig.json, type checks, ES modules, file names or naming, or when CI fails on a format, lint or type check. It encodes: Prettier as the only formatter with the framework's plugin, ESLint flat config with typescript-eslint, the framework's plugin, sorted imports and eslint-config-pre...

  • 2 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 3, 2026
ai-agentsjavascripttypescriptgojavac#vueangularnodeapi

Works with

  • terminal
  • cli
  • api

Security analysis

A100/100

Scanned December 3, 2026

npx -y skills add JorgeCostaMacia/code-harness --skill code-style-node --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Code Style Node?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Code Style Node
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/jorgecostamacia-code-style-node/badge)](https://www.skillsdirectory.com/skills/jorgecostamacia-code-style-node)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: code-style-node
description: >-
  How TypeScript and JavaScript are written in a Node project, with or
  without a framework. Use when writing, generating or reviewing TS or JS
  code, or when setting up or changing Prettier, ESLint, import order,
  tsconfig.json, type checks, ES modules, file names or naming, or when CI
  fails on a format, lint or type check. It encodes: Prettier as the only
  formatter with the framework's plugin, ESLint flat config with
  typescript-eslint, the framework's plugin, sorted imports and
  eslint-config-prettier last, no eslint-disable without its reason on the
  same line, strict TypeScript with the strictest flags,
  tsc --noEmit or the framework's own check, ES modules only, the rules for
  TypeScript that Node runs directly, and the framework's naming.
---

# TypeScript and JavaScript style

The style is **enforced, not suggested**: Prettier decides the layout, ESLint the code rules and the import order, and the type check the types. CI fails on any of them. Ask the person before you edit a CI workflow, the `.claude` settings or any of these gates, and never weaken a gate on your own: fix what makes it fail. The sections below spell out what the tools do not decide.

## Formatting: Prettier only

Prettier is the only formatter. It is a devDependency, configured in `.prettierrc` with the same options in every Node repository. A framework that needs a plugin adds it, and its skill says how:

```json
{
  "printWidth": 120,
  "singleQuote": true,
  "proseWrap": "never"
}
```

- `printWidth: 120` is the same width as C#. When a framework's own skill or defaults set another width, the project still uses 120.
- `proseWrap: "never"` keeps one paragraph per line in every `.md` file. Prettier joins a hand-wrapped paragraph, and the check stops it from coming back.
- A framework's plugin and its override for the framework's files come from the framework's own skill or defaults.
- Add a `format` script (`prettier --write .`) and a `format:check` script (`prettier --check .`). CI runs `format:check`. Put generated files (the build output, the lockfile) in `.prettierignore`.

## Linting: ESLint flat config

ESLint checks the code and sorts the imports. It never checks the layout. Configure it in `eslint.config.js`, in this order:

```js
import js from '@eslint/js';
import eslintConfigPrettier from 'eslint-config-prettier/flat';
import simpleImportSort from 'eslint-plugin-simple-import-sort';
import { defineConfig, globalIgnores } from 'eslint/config';
import tseslint from 'typescript-eslint';

export default defineConfig(
  globalIgnores(['dist/']),
  js.configs.recommended,
  tseslint.configs.recommended,
  {
    plugins: { 'simple-import-sort': simpleImportSort },
    rules: {
      'simple-import-sort/imports': 'error',
      'simple-import-sort/exports': 'error',
    },
  },
  eslintConfigPrettier,
);
```

- `@eslint/js` recommended, then `typescript-eslint` recommended. A framework adds its plugin after them (`eslint-plugin-vue`, `angular-eslint`), and its generated folders to `globalIgnores`; its skill says which.
- Where the project can afford it, use `tseslint.configs.recommendedTypeChecked` with `languageOptions.parserOptions.projectService: true`. The type-aware rules catch more, but each lint run first builds the project with TypeScript.
- `eslint-plugin-simple-import-sort` sorts imports and exports. `eslint --fix` applies the order, so nobody sorts by hand.
- `eslint-config-prettier` goes last. It only turns rules off: every rule that would fight Prettier over the layout.
- Do not add a plugin for unused imports. `noUnusedLocals` and `noUnusedParameters` in `tsconfig.json` already catch them.
- Add a `lint` script (`eslint .`). CI runs it.
- An `eslint-disable` comment names the rule and carries its reason on the same line: `// eslint-disable-next-line no-console -- the CLI prints to the terminal`. Never write a bare `eslint-disable`, or one for a whole file. Do not turn a rule off in the config to silence one place.

## Types

- `tsconfig.json` has `strict: true`, plus the strictest flags: `noUncheckedIndexedAccess`, `noImplicitOverride`, `noFallthroughCasesInSwitch`, `verbatimModuleSyntax`, `noUnusedLocals` and `noUnusedParameters`. When the framework has strict presets, extend the strictest one and add only the flags that it lacks. The framework's skill names the preset.
- `verbatimModuleSyntax` makes a type import `import type`. A tool that strips types then never keeps a value import that only held types.
- The type check runs in CI: `tsc --noEmit`, or the framework's own check when `tsc` cannot read the framework's files. It exits with an error code on a type error.
- **Pin `typescript` to `^6`** while `typescript-eslint` or the framework's check needs the TypeScript API. TypeScript 7, the native compiler, ships no API, so those tools do not run on it yet. Move to 7 when they support it.
- TypeScript 6 loads no global types by default (`types` is `[]`). In a Node project, set `"types": ["node"]` and add `@types/node`.
- No `any`. Use `unknown` and narrow it.
- A `// @ts-expect-error` carries its reason on the same line. Never write `// @ts-ignore`: it stays silent when the error goes away.

## ES modules

- The project is ESM: `"type": "module"` in `package.json`, `import` and `export`, never `require` or `module.exports`.
- Import Node's own modules with the `node:` prefix (`node:fs`, `node:path`), so a package with the same name cannot take their place.

## TypeScript that Node runs directly

Node strips the types of a `.ts` file and runs it without a build (scripts, config files, tools). It does not read `tsconfig.json`. So, for every file that Node runs directly:

- Write the extension in each relative import: `import { slugify } from './slugify.ts'`. Node does not guess it.
- Use relative paths, not `tsconfig` `paths` aliases: Node fails on them. Use `#` subpath imports from `package.json` when you need an alias.
- Write only syntax that Node can erase: no `enum`, no `namespace` with values, no parameter properties, no `import x = require()`. Turn on `erasableSyntaxOnly`, so the type check finds that syntax first. Turn on `rewriteRelativeImportExtensions` too, so a relative import with its `.ts` extension passes the type check.

## Names

Follow the framework's own naming convention for files and symbols. ESLint and Prettier do not decide file names, so the framework's skill says them.

## Comments

A comment says what the code cannot: a constraint, why the obvious approach failed, what breaks if this changes. No commented-out code.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.