The Wayback Machine - https://web.archive.org/web/20201112224427/https://github.com/square/eslint-plugin-square
Skip to content
master
Go to file
Code

README.md

eslint-plugin-square

npm version CI

This plugin contains lint rule definitions and configurations for ESLint specific to Square's needs. It serves mainly to consolidate Square's web frontend linting setup in one place.

Requirements

Usage

Install via yarn (or npm):

yarn add --dev eslint-plugin-square

Edit your .eslintrc.js configuration file to extend one of the available configurations from this plugin:

module.exports = {
  plugins: ['square'],
  extends: ['plugin:square/ember'], // Or other configuration.
};

Configurations

Name Description
base Rules and configuration for any JavaScript-based project. Includes recommended and optional rules from eslint, prettier, eslint-plugin-eslint-comments, eslint-plugin-import, eslint-plugin-unicorn, and more.
🔥 ember Ember.js-specific additions on top of base. Includes recommended and optional rules from eslint-plugin-ember, kebab-case filename enforcement with eslint-plugin-filenames, and more.
react React-specific additions on top of base.
typescript TypeScript-specific additions on top of base. Use with @typescript-eslint/parser.

Rules enabled by these configurations should meet the following criteria:

  • They make sense in a wide variety of codebases (and have been tested in a variety of Square's applications).
  • They are generally acceptable and desirable (in terms of enforcing best practices, consistency, avoiding bugs) to most developers.
  • There is a practical migration path (autofixers, codemod, find-and-replace, manual fixes) for enabling them in most applications.

Custom rules

Rule Category Config Fixable?
no-restricted-files JavaScript
require-await-function JavaScript 🔥 🔧
no-handlebar-interpolation Ember
no-modifying-immutable-properties Ember 🔧
no-translation-key-interpolation Ember 🔥
no-missing-tests Testing
no-test-return-value Testing 🔥
use-call-count-test-assert Testing 🔥 🔧
no-assert-ok-find Ember Testing 🔥
use-ember-find Ember Testing 🔥 🔧

Note that we prefer to upstream our custom lint rules to third-party eslint plugins whenever possible. The rules that still remain here are typically here because:

  • We haven't found the appropriate eslint plugin to upstream them to.
  • We haven't found the time to upstream them.
  • They are specific to Square in some way / not generic enough.

License

Copyright 2020 Square Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

About

An eslint plugin containing custom JavaScript, Ember, React, TypeScript rules and configurations tailored to Square's needs.

Topics

Resources

License

Packages

No packages published
You can’t perform that action at this time.