Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(eslint): enforce blank line before return and after directives #54

Merged
merged 1 commit into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.