Skip to content

nolawnchairs/eslint-plugin

Repository files navigation

@nolawnchairs/eslint-plugin

This is a collection of custom ESLint rules for personal projects.

Installation

npm install -D @nolawnchairs/eslint-plugin

Configuration

To use only the rules provided by this plugin, you can add the following to your ESLint configuration file:

module.exports = {
  plugins: ['@nolawnchairs'],
  rules: {
    '@nolawnchairs/import-order': ['error', { /* options */ }]
  }
}

Extending

This plugin also provides my personal ESLint configuration, which you can extend in your own ESLint configuration file:

module.exports = {
  extends: ['plugin:@nolawnchairs/application']
}

Configs

  • application - ESLint configuration designed for applications.
  • library - ESLint configuration designed for libraries.

Rules

Rule Description
@nolawnchairs/first-newline Enforces having exactly one newline at the beginning of a file before the first import.
@nolawnchairs/import-order Enforces a standardized, opinionated order for import statements.
@nolawnchairs/no-iife Disallows immediately invoked function expressions (IIFE).
@nolawnchairs/no-import-gaps Enforces the absence of newlines between import statements.
@nolawnchairs/prefer-aliased Enforce internal application imports to be aliased with a token instead of relative paths. Only recommended for applications and not libraries.

Formatting

Prettier is terrible, and has untenable defaults, so we rely on VSCode's language settings and ESLint to share formatting responsibilities.

To enable the VSCode default formatter for JS, TS and React code, ensure the following VSCode settings:

  "[javascript]": {
    "editor.tabSize": 2,
    "editor.detectIndentation": false,
    "editor.formatOnSave": true,
    "editor.defaultFormatter": "vscode.typescript-language-features"
  },
  "[typescript]": {
    "editor.tabSize": 2,
    "editor.detectIndentation": false,
    "editor.formatOnSave": true,
    "editor.defaultFormatter": "vscode.typescript-language-features"
  },
  "[typescriptreact]": {
    "editor.tabSize": 2,
    "editor.detectIndentation": false,
    "editor.formatOnSave": true,
    "editor.defaultFormatter": "vscode.typescript-language-features"
  },

The detectIndentation setting is disabled because when enabled, the indentation is set based on the file contents.

About

An ESLint plugin for my personal projects

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published