Pureline JavaScript
const-first, semicolons, braces, async/await.
Pureline JavaScript is explicit where the language permits sloppiness: blocks always with braces, semicolons always, `const` as the default, and linear control flow through async/await.
Profile rules
Braces Are Mandatory
Every control-flow body gets a block, even for a single statement.
if (!user) return; while (queue.length) process(queue.shift()); if (!user) {
return;
} Use Semicolons
Pureline JavaScript uses semicolons consistently and does not rely on automatic semicolon insertion.
const session = createSession(user)
session.start() const total = base + tax
[fee, tip].forEach(add) const session = createSession(user);
session.start(); `const` First
const is the default. Use let only for actual reassignment. Do not use var.
var user = loadUser(); let session = createSession(user);
session.start(); const user = loadUser(); let count = 0;
count++; Prefer `async` / `await`
Avoid promise chains when async/await produces clearer control flow.
function loadUser(id) {
return fetch(`/users/${id}`)
.then(response => response.ok ? response.json() : null);
} async function loadUser(id) {
const response = await fetch(`/users/${id}`);
if (!response.ok) {
return null;
}
return response.json();
} Arrow Functions Are Contextual
Normal named logic may use regular functions. Arrow functions are well suited for local callbacks, but are not the default for everything.
const createSession = (user) => {
const session = new Session(user);
session.start();
return session;
}; function createSession(user) {
return new Session(user);
} users.filter(user => user.active()); Destructuring Must Improve Clarity
Destructuring is good when it shows intent. Large objects are not destructured merely because the language allows it.
const { id, name, email, role, createdAt, updatedAt, settings: { theme, locale } } = user; const { id, name } = user; Folder Density
A JavaScript feature/source folder may contain at most **10 production source modules** by default.
Barrel files such as index.js, tests, generated files, and metadata-only files do not count.
If the folder exceeds the limit, split it by responsibility rather than by arbitrary file count.
session/
index.js
state/
transport/
storage/ Core rules in the JavaScript checker
In addition to the profile rules, the JavaScript checker verifies these rules from the Pureline Core: