Skip to content

Commit

Permalink
feat(eslint): enforce blank line before return and after directives (
Browse files Browse the repository at this point in the history
  • Loading branch information
lesha1201 authored Dec 7, 2023
1 parent eca3022 commit 8e7511f
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 1 deletion.
4 changes: 3 additions & 1 deletion eslint/configs/_base.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const commentsRules = require('../rules/comments');
const importRules = require('../rules/import');
const standardRules = require('../rules/standard');
const stylisticRules = require('../rules/stylistic');
const unicornRules = require('../rules/unicorn');

// See: https://github.com/eslint/eslint/issues/3458
Expand All @@ -19,11 +20,12 @@ module.exports = {
'plugin:unicorn/recommended',
'plugin:prettier/recommended',
],
plugins: ['simple-import-sort'],
plugins: ['@stylistic', 'simple-import-sort'],
// Report unused `eslint-disable` comments.
reportUnusedDisableDirectives: true,
rules: {
...standardRules,
...stylisticRules,
...commentsRules,
...importRules,
...unicornRules,
Expand Down
16 changes: 16 additions & 0 deletions eslint/rules/stylistic.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module.exports = {
/**
* This rule requires or disallows blank lines between the given 2 kinds of
* statements. Properly blank lines help developers to understand the code.
*
* 🔧 Fixable - https://eslint.style/rules/js/padding-line-between-statements
*/
'@stylistic/padding-line-between-statements': [
'warn',
// Blank line before `return`
{ blankLine: 'always', next: 'return', prev: '*' },
// Blank line after all directives (e.g. `use strict`)
{ blankLine: 'always', next: '*', prev: 'directive' },
{ blankLine: 'any', next: 'directive', prev: 'directive' },
],
};
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"@babel/core": "^7.23.3",
"@babel/eslint-parser": "^7.23.3",
"@rushstack/eslint-patch": "^1.6.0",
"@stylistic/eslint-plugin": "^1.4.1",
"@typescript-eslint/eslint-plugin": "^6.12.0",
"eslint-config-prettier": "^9.0.0",
"eslint-import-resolver-typescript": "^3.6.1",
Expand Down
58 changes: 58 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8e7511f

Please sign in to comment.