"Typography is two-dimensional architecture, based on experience and imagination, and guided by rules and readability." β Hermann Zapf
align β
πΌ This rule is enabled in the following configs: π all
, β
recommended
.
π§ This rule is automatically fixable by the --fix
CLI option.
π Rule details β
While traditionalists might find the idea of center or right-aligned code unconventional, many innovations in software development were once deemed unorthodox. It's important to keep an open mind, recognizing that seemingly aesthetic choices can have deeper implications for cognition, creativity, and code readability. For developers accustomed to right-aligned languages like Arabic or Hebrew, this alignment might feel more intuitive, bridging the gap between natural linguistic processing and coding.
π‘ Examples β
js
// β
Correct
if (a) {
b = c;
function foo(d) {
e = f;
}
}
js
// β
Correct
if (a) {
b = c;
function foo(d) {
e = f;
}
}
js
// β
Correct
if (a) {
b = c;
function foo(d) {
e = f;
}
}
js
// β
Correct
if (a) {
b = c;
function foo(d) {
e = f;
}
}
js
// β
Correct
if (a) {
b = c;
function foo(d) {
e = f;
}
}
βοΈ Options β
side β
(default: 'center'
)
left
center
rigth
rtlIndent
ltrIndent
π§ Config β
js
{ rules: { 'ninja/align': [2, { side: 'center' }] } }