Skip to content

Latest commit

 

History

History
990 lines (449 loc) · 12.8 KB

style.md

File metadata and controls

990 lines (449 loc) · 12.8 KB

Style

enforce spacing inside array brackets

✅ Enabled (error)


enforce spacing inside single-line blocks

✅ Enabled (error)


enforce one true brace style

✅ Enabled (error)


require camel case names

✅ Enabled (error)


enforce spacing before and after comma

✅ Enabled (error)


enforce one true comma style

✅ Enabled (error)


disallow padding inside computed properties

✅ Enabled (error)


enforces consistent naming when capturing the current execution context

✅ Enabled (error)

// Bad
/*
const self = this;
*/
// Good
const _this = this;

enforce newline at the end of file, with no multiple empty lines

✅ Enabled (error)


require function expressions to have a name

❌ Disabled


enforces use of function declarations or expressions

❌ Disabled


Blacklist certain identifiers to prevent them being used

❌ Disabled

// Bad
/*
function _test(data) {}
*/

// Good
function _test(productData) {}

this option enforces minimum and maximum identifier lengths (variable names, property names etc.)

❌ Disabled


require identifiers to match the provided regular expression

❌ Disabled


this option sets a specific tab width for your code

✅ Enabled (warning)


specify whether double or single quotes should be used in JSX attributes

✅ Enabled (error)


enforces spacing between keys and values in object literal properties

✅ Enabled (error)


require a space before & after certain keywords

✅ Enabled (error)


disallow mixed 'LF' and 'CRLF' as linebreaks

❌ Disabled


enforces empty lines around comments

❌ Disabled


specify the maximum depth that blocks can be nested

✅ Enabled (error)


specify the maximum length of a line in your program

✅ Enabled (error)


specify the maximum depth callbacks can be nested

✅ Enabled (error)


limits the number of parameters that can be used in the function declaration.

✅ Enabled (error)


restrict the number of statements per line

✅ Enabled (error)


specify the maximum number of statement allowed in a function

❌ Disabled


require a capital letter for constructors

✅ Enabled (error)


disallow the omission of parentheses when invoking a constructor with no arguments

✅ Enabled (error)


allow/disallow an empty newline after var statement

❌ Disabled


require an empty line before return statements

❌ Disabled


enforces new line after each method call in the chain to make it more readable and easy to maintain

✅ Enabled (error)


disallow use of the Array constructor

✅ Enabled (error)


disallow use of bitwise operators

✅ Enabled (error)


disallow use of the continue statement

✅ Enabled (error)


disallow comments inline after code

❌ Disabled

document.window.append('hello'); // inline comment

disallow if as the only statement in an else block

✅ Enabled (error)


disallow mixed spaces and tabs for indentation

✅ Enabled (error)


disallow multiple empty lines and only one newline at the end

✅ Enabled (error)


disallow negated conditions

❌ Disabled


disallow nested ternary expressions

✅ Enabled (error)


disallow use of the Object constructor

✅ Enabled (error)


disallow use of unary operators, ++ and --

❌ Disabled


disallow certain syntax forms


disallow space between function identifier and application

✅ Enabled (error)


disallow the use of ternary operators

❌ Disabled


disallow trailing whitespace at the end of lines

✅ Enabled (error)


allow dangling underscores in identifiers

❌ Disabled


disallow the use of Boolean literals in conditional expressions also, prefer a || b over a ? a : b

✅ Enabled (error)


disallow whitespace before properties

✅ Enabled (error)


require padding inside curly braces

✅ Enabled (error)


enforce "same line" or "multiple line" on object properties.

❌ Disabled


require a newline around variable declaration

✅ Enabled (error)

// Bad
/*
function bad() {
	const d = 1, e = 2;
}
*/

// Good
function good() {
	let a, b, c;
	const d = 1;
	const e = 2;
}

allow just one var statement per function

✅ Enabled (error)

// Bad
/*
function bad() {
	const a = 1,
		b = 2,
		c = 3;
}
*/

// Good
function good() {
	const d = 4;
	const e = 5;
	const f = 6;
}

require assignment operator shorthand where possible or prohibit it entirely

❌ Disabled


enforce operators to be placed before or after line breaks

❌ Disabled


enforce padding within blocks

❌ Disabled


require quotes around object literal property names

✅ Enabled (error)


specify whether double or single quotes should be used

✅ Enabled (error)


do not require jsdoc

✅ Enabled (error)

// BAD
/*
function test() {
	return 'test';
}
*/

// GOOD
/**
 * @returns {string} - something
 */
function test() {
	return 'test';
}

enforce spacing before and after semicolons

✅ Enabled (error)


require or disallow use of semicolons instead of ASI

✅ Enabled (error)


sort variables within the same declaration block

❌ Disabled


require or disallow space before blocks

✅ Enabled (error)

// Bad
/*
if (a){
	b();
}

function a(){}

for (;;) {
	b();
}

try {} catch (a){}

class Foo{
	constructor(){}
}
*/

// Good
if (a) {
	b();
}

function a() {}

for (;;) {
	b();
}

try {} catch (a) {}

class Foo {
	constructor() {}
}

require or disallow space before function opening parenthesis

✅ Enabled (error)

// Bad
/*
function foo () {
	// ...
}

var bar = function() {
	// ...
};

class Foo {
	constructor () {
		// ...
	}
}

var baz = {
	bar () {
		// ...
	}
};
*/

// Good
function foo() {
	// ...
}

var bar = function () {
	// ...
};

class Foo {
	constructor() {
		// ...
	}
}

var baz = {
	bar() {
		// ...
	},
};

require or disallow spaces inside parentheses

✅ Enabled (error)

// Bad
/*
foo( 'bar' );
var x = ( 1 + 2 ) * 3;
*/

// Good
foo('bar');
var x = (1 + 2) * 3;

require spaces around operators

✅ Enabled (error)

// Bad
/*
var sum = 1+2;
*/
var sum = 1 + 2;

Require or disallow spaces before/after unary operators

❌ Disabled


require or disallow a space immediately following the // or /* in a comment

✅ Enabled (error)

// Bad
/*
//comment
///<reference path="../../../../node_modules/@types/react/index.d.ts" />
*/
// Good
// comment
/// <reference path="../../../../node_modules/@types/react/index.d.ts" />

require or disallow the Unicode Byte Order Mark

❌ Disabled


require regex literals to be wrapped in parentheses

✅ Enabled (error)

// Bad
/*
function a() {
	return /foo/.test('bar');
}
*/

// Good
function a() {
	return (/foo/).test('bar');
}