diff --git a/config/lint/eslint.config.mjs b/config/lint/eslint.config.mjs index aab6e63..be09869 100644 --- a/config/lint/eslint.config.mjs +++ b/config/lint/eslint.config.mjs @@ -32,6 +32,9 @@ const style = { '@stylistic/keyword-spacing': ['error', { 'before': true, 'after': true }], '@stylistic/lines-between-class-members': ['error', 'always'], '@stylistic/new-parens': ['error', 'always'], + '@stylistic/newline-per-chained-call': ['error', { + 'ignoreChainWithDepth': 2 + }], '@stylistic/no-extra-parens': ['error', 'all'], '@stylistic/no-extra-semi': 'error', '@stylistic/no-floating-decimal': 'error', @@ -50,6 +53,209 @@ const style = { '@stylistic/object-property-newline': 'error', '@stylistic/operator-linebreak': ['error', 'before'], '@stylistic/one-var-declaration-per-line': 'error', + '@stylistic/padded-blocks': ['error', { + 'blocks': 'never', + 'classes': 'always', + 'switches': 'never', + }], + + // Padding lines. The most in-depth part of this config + // ['block', 'block-like', 'break', 'cjs-export', 'cjs-import', 'class', 'const', 'continue', 'debugger', 'directive', 'do', 'empty', 'export', 'expression', 'for', 'function', 'if', 'iife', 'import', 'let', 'return', 'switch', 'throw', 'try', 'var', 'while', 'with'] + '@stylistic/padding-line-between-statements': ['error', + // Variables, Constants + { + 'blankLine': 'never', + 'prev': 'var', + 'next': 'var' + }, + { + 'blankLine': 'never', + 'prev': 'let', + 'next': 'let' + }, + { + 'blankLine': 'never', + 'prev': 'const', + 'next': 'const' + }, + { + 'blankLine': 'always', + 'prev': 'var', + 'next': ['block', 'block-like', 'break', 'cjs-export', 'cjs-import', 'class', 'const', 'continue', 'debugger', 'directive', 'do', 'empty', 'export', 'expression', 'for', 'function', 'if', 'iife', 'import', 'let', 'return', 'switch', 'throw', 'try', 'var', 'with'] + }, + { + 'blankLine': 'always', + 'prev': 'let', + 'next': ['block', 'block-like', 'break', 'cjs-export', 'cjs-import', 'class', 'const', 'continue', 'debugger', 'directive', 'do', 'empty', 'export', 'expression', 'for', 'function', 'if', 'iife', 'import', 'return', 'switch', 'throw', 'try', 'var', 'while', 'with'] + }, + { + 'blankLine': 'always', + 'prev': 'const', + 'next': ['block', 'block-like', 'break', 'cjs-export', 'cjs-import', 'class', 'continue', 'debugger', 'directive', 'do', 'empty', 'export', 'expression', 'for', 'function', 'if', 'iife', 'import', 'let', 'return', 'switch', 'throw', 'try', 'var', 'while', 'with'] + }, + // Import + { + 'blankLine': 'never', + 'prev': 'import', + 'next': 'import' + }, + { + 'blankLine': 'never', + 'prev': 'cjs-import', + 'next': 'cjs-import' + }, + { + 'blankLine': 'always', + 'prev': ['block', 'block-like', 'break', 'cjs-export', 'class', 'const', 'continue', 'debugger', 'directive', 'do', 'empty', 'export', 'expression', 'for', 'function', 'if', 'iife', 'let', 'return', 'switch', 'throw', 'try', 'var', 'while', 'with'], + 'next': 'cjs-import' + }, + { + 'blankLine': 'always', + 'prev': 'cjs-import', + 'next': ['block', 'block-like', 'break', 'cjs-export', 'class', 'const', 'continue', 'debugger', 'directive', 'do', 'empty', 'export', 'expression', 'for', 'function', 'if', 'iife', 'let', 'return', 'switch', 'throw', 'try', 'var', 'while', 'with'] + }, + { + 'blankLine': 'always', + 'prev': ['block', 'block-like', 'break', 'cjs-export', 'class', 'const', 'continue', 'debugger', 'directive', 'do', 'empty', 'export', 'expression', 'for', 'function', 'if', 'iife', 'let', 'return', 'switch', 'throw', 'try', 'var', 'while', 'with'], + 'next': 'import' + }, + { + 'blankLine': 'always', + 'prev': 'import', + 'next': ['block', 'block-like', 'break', 'cjs-export', 'class', 'const', 'continue', 'debugger', 'directive', 'do', 'empty', 'export', 'expression', 'for', 'function', 'if', 'iife', 'let', 'return', 'switch', 'throw', 'try', 'var', 'while', 'with'] + }, + // If + { + 'blankLine': 'always', + 'prev': '*', + 'next': 'if' + }, + { + 'blankLine': 'always', + 'prev': 'if', + 'next': '*' + }, + // For + { + 'blankLine': 'always', + 'prev': '*', + 'next': 'for' + }, + { + 'blankLine': 'always', + 'prev': 'for', + 'next': '*' + }, + // While + { + 'blankLine': 'always', + 'prev': '*', + 'next': 'while' + }, + { + 'blankLine': 'always', + 'prev': 'while', + 'next': '*' + }, + // Functions + { + 'blankLine': 'always', + 'prev': '*', + 'next': 'function' + }, + { + 'blankLine': 'always', + 'prev': 'function', + 'next': '*' + }, + // Block Statements + { + 'blankLine': 'always', + 'prev': '*', + 'next': 'block-like' + }, + { + 'blankLine': 'always', + 'prev': 'block-like', + 'next': '*' + }, + // Switch + { + 'blankLine': 'always', + 'prev': '*', + 'next': 'switch' + }, + { + 'blankLine': 'always', + 'prev': 'switch', + 'next': '*' + }, + // Try-Catch + { + 'blankLine': 'always', + 'prev': '*', + 'next': 'try' + }, + { + 'blankLine': 'always', + 'prev': 'try', + 'next': '*' + }, + // Throw + { + 'blankLine': 'always', + 'prev': '*', + 'next': 'throw' + }, + { + 'blankLine': 'always', + 'prev': 'throw', + 'next': '*' + }, + // Return + { + 'blankLine': 'never', + 'prev': 'return', + 'next': '*' + }, + { + 'blankLine': 'always', + 'prev': '*', + 'next': 'return' + }, + // Export + { + 'blankLine': 'always', + 'prev': '*', + 'next': 'export' + }, + { + 'blankLine': 'always', + 'prev': 'export', + 'next': '*' + }, + { + 'blankLine': 'always', + 'prev': '*', + 'next': 'cjs-export' + }, + { + 'blankLine': 'always', + 'prev': 'cjs-export', + 'next': '*' + }, + // Classes + { + 'blankLine': 'always', + 'prev': '*', + 'next': 'class' + }, + { + 'blankLine': 'always', + 'prev': 'class', + 'next': '*' + }, + ], '@stylistic/quote-props': ['error', 'always'], '@stylistic/quotes': ['error', 'single'], '@stylistic/rest-spread-spacing': ['error', 'never'],