js-conventions
Skill57 starsChanged 9 months agoMITView on GitHub
Apply Metarhia JavaScript style. Use when writing or editing .js, .mjs, .ts files (with certain corrections for typescript), formatting code, or when the user asks about code style or linting.
In this repository6 other files it gives its agents.
- data-structuresSkill
- error-handlingSkill
- js-data-structuresSkill
- js-gofSkill
- metautil-data-structuresSkill
- npm-publishSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
45 rules. About 0 are common, 21 are distinctive, and 24 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈21
Distinctive · estimate
This author's own choices. Worth a look.
24
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 8
Use following conventions for JavaScript and TypeScript code.
- Very specific: line 12
Add to dev dependencies in package.json if not added:
- Very specific: line 15
Add scripts in package.json if not added:
- Very specific: line 18
Before and after code analysis with AI run npm run lint and npm t
- Very specific: line 19
Use npm run fix if errors/warnings detected to auto-fix when possible
- Distinctive: line 23
Use single quotes and semicolons
- Distinctive: line 24
Keep max line length 80 (ignore URLs)
- Distinctive: line 25
Use trailing commas in multiline arrays, objects, and params
- Distinctive: line 26
Keep one empty line between semantic blocks
- Distinctive: line 27
Follow Prettier and eslint-config-metarhia for spacing, braces, and indentation
- Very specific: line 31
Use camelCase for variables and parameters
- Very specific: line 32
Use UpperCamelCase for classes and types
- Very specific: line 33
Use UPPER_SNAKE_CASE for constants
- Very specific: line 34
Use new with capitalized constructor names
- Very specific: line 35
Use error in catch blocks, not err
- Very specific: line 36
Use short names (e, i) only in short one-line callbacks
- Very specific: line 37
Use descriptive names in multiline callbacks (event, index, item)
- Very specific: line 38
Use boolean prefixes: is, has, can, should
- Distinctive: line 39
Use singular names for entities and plural names for collections
- Very specific: line 40
Use verb names for functions and handlers (parse, create, handle, on)
- Very specific: line 45
Prefer const, minimize let, never use var
- Distinctive: line 46
Prefer arrow functions (except prototype/class methods)
- Very specific: line 47
Do not mutate input parameters.
- Distinctive: line 48
Keep functions small and single-purpose
- Very specific: line 50
Prefer explicit loops (for, for..of) in hot paths
- Distinctive: line 51
Use array methods when they improve readability
- Very specific: line 52
Use === and !== only
- Distinctive: line 53
Keep return types consistent
- Distinctive: line 54
Avoid nested ternaries and deep callback nesting
- Very specific: line 57
Use iteration methods like .map, .filter, .reduce if it is good for code semantic
- Distinctive: line 62
Keep object shapes stable: same keys, types, and key order
- Distinctive: line 64
Use shape mutations only for metaprogramming
- Very specific: line 65
Use null for empty reference types.
- Distinctive: line 66
Avoid array destructuring in assignments and loops.
- Distinctive: line 67
Keep hot functions monomorphic: stable arg count, types, and return types
- Distinctive: line 68
Avoid reading the same property from many unrelated object shapes
- Distinctive: line 69
Prefer string or number literals for status/codes.
- Distinctive: line 70
Keep objects that share a property to the same shape.
- Very specific: line 71
Prefer fixed property access (obj.x) over dynamic keys (obj[key])
- Distinctive: line 72
Keep arrays dense, avoid holes and mixed element kinds
- Very specific: line 76
Keep try/catch, spread/rest away from hot loops
- Very specific: line 77
Use Map for dynamic key dictionaries, plain objects for fixed schemas
- Very specific: line 78
Use Set for big and dynamic collections, prefer arrays for short and stable
- Very specific: line 79
Use Object.create(null) for pure dictionaries
- Distinctive: line 80
Use typed arrays for numeric and binary workloads
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
JavaScript Code Style
Use following conventions for JavaScript and TypeScript code.
Preparations
- Add to dev dependencies in package.json if not added:
- eslint-config-metarhia
- eslint, prettier
- Add scripts in package.json if not added:
- "lint": "eslint . && prettier --check "/*.js" "/.json" "**/.md" "*/.ts""
- "fix": "eslint . --fix && prettier --write "/*.js" "/.json" "**/.md" "*/.ts""
- Before and after code analysis with AI run
npm run lintandnpm t - Use
npm run fixif errors/warnings detected to auto-fix when possible
Formatting
- Use single quotes and semicolons
- Keep max line length 80 (ignore URLs)
- Use trailing commas in multiline arrays, objects, and params
- Keep one empty line between semantic blocks
- Follow Prettier and eslint-config-metarhia for spacing, braces, and indentation
Naming
- Use
camelCasefor variables and parameters - Use
UpperCamelCasefor classes and types - Use
UPPER_SNAKE_CASEfor constants - Use
newwith capitalized constructor names - Use
errorin catch blocks, noterr - Use short names (
e,i) only in short one-line callbacks - Use descriptive names in multiline callbacks (
event,index,item) - Use boolean prefixes:
is,has,can,should - Use singular names for entities and plural names for collections
- Use verb names for functions and handlers (
parse,create,handle,on) - Include units in numeric names (
timeoutMs,sizeBytes) except options
Best practices
- Prefer
const, minimizelet, never usevar - Prefer arrow functions (except prototype/class methods)
- Do not mutate input parameters; avoid
arguments - Keep functions small and single-purpose
- Decompose long expressions into intermediate variables
- Prefer explicit loops (
for,for..of) in hot paths - Use array methods when they improve readability
- Use
===and!==only - Keep return types consistent
- Avoid nested ternaries and deep callback nesting
- Self-documented and self-descriptive code: do not add obvious comments, code should be clear without comments
- Use iteration methods like
.map,.filter,.reduceif it is good for code semantic - Try to avoid
.forEachif callback operates with outer context
Optimizations
- Keep object shapes stable: same keys, types, and key order
- Change shape only in constructors and creational patterns; avoid mix-ins
- Use shape mutations only for metaprogramming
- Use
nullfor empty reference types; useundefinedfor empty primitives - Avoid array destructuring in assignments and loops; object destructuring is ok
- Keep hot functions monomorphic: stable arg count, types, and return types
- Avoid reading the same property from many unrelated object shapes
- Prefer string or number literals for status/codes; avoid mixing primitives with objects in one variable
- Keep objects that share a property to the same shape; avoid polymorphic hotspots
- Prefer fixed property access (
obj.x) over dynamic keys (obj[key]) - Keep arrays dense, avoid holes and mixed element kinds
- Initialize object fields in constructor/factory once and in one order
- Set field to
nullorundefined; avoiddelete - Move reusable callbacks outside loops
- Keep
try/catch, spread/rest away from hot loops - Use
Mapfor dynamic key dictionaries, plain objects for fixed schemas - Use
Setfor big and dynamic collections, prefer arrays for short and stable - Use
Object.create(null)for pure dictionaries - Use typed arrays for numeric and binary workloads
- Reduce GC pressure: reuse arrays, objects, and buffers when safe
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.

