
Security News
MCP Community Begins Work on Official MCP Metaregistry
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
eslint-plugin-square
Advanced tools
Linting plugin containing Square's custom lint rules and configuration for JavaScript and related technologies.
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. It is generally not recommended for public usage outside of Square.
Install alongside ESLint via yarn (or npm):
yarn add --dev eslint eslint-plugin-square npm-run-all
If you're creating a new ESLint configuration, refer to ESLint's documentation to determine the correct file format for your project. For example, ESM projects with "type": "module"
in their package.json should use an .eslintrc.cjs
file format instead of .eslintrc.js
.
Once you have an ESLint configuration file, add this plugin to your extends
property:
module.exports = {
extends: ['plugin:square/base'], // Or other configuration.
};
Add the relevant lint scripts in package.json
with npm-run-all and include detection for unused disable directives:
{
"scripts": {
"lint": "npm-run-all --continue-on-error --aggregate-output --parallel lint:*",
"lint:js": "eslint --report-unused-disable-directives --cache ."
}
}
Configure linting to run:
Fix violations using:
eslint --fix
)Sometimes, you may not want to fix certain violations, for reasons such as:
If you prefer not to adopt a specific rule, you can disable it:
// eslint-disable-line no-empty-function
)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 . Includes recommended rules from eslint-plugin-jsx-a11y, eslint-plugin-react, and eslint-plugin-react-hooks. |
🔒 | strict | A variety of stricter lint rules 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:
💼 Configurations enabled in.
🔥 Set in the ember
configuration.
🔒 Set in the strict
configuration.
🔧 Automatically fixable by the --fix
CLI option.
💡 Manually fixable by editor suggestions.
Name | Description | 💼 | 🔧 | 💡 |
---|---|---|---|---|
no-assert-ok-find | disallow usage of assert.ok(find(...)) as it will always pass | 🔥 | 💡 | |
no-handlebar-interpolation | disallow unsafe HTML in strings/hbs/translations | |||
no-missing-tests | disallow files without a corresponding test file | |||
no-restricted-files | disallow files with a path matching a specific regexp | |||
no-test-return-value | disallow test functions with a return value | 🔥 | 💡 | |
no-translation-key-interpolation | disallow string interpolation in translation keys | 🔥 | ||
require-await-function | enforce using await with calls to specified functions | 🔥 | 🔧 | |
use-call-count-test-assert | enforce using assert.equal(...callCount, ...); instead of assert.ok(...calledOnce); | 🔥 🔒 | 🔧 | |
use-ember-find | require use of Ember's find helper instead of jQuery for selecting elements in tests | 🔥 | 🔧 |
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:
If you do need to write a custom lint rule here because you can't find an existing lint rule to use or other ESLint plugin to contribute to, be sure to consult astexplorer.net while writing it.
Lint rule ideas often come from:
Consider adding other linters not included by plugin:
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.
v26.0.0 (2023-10-20)
FAQs
Linting plugin containing Square's custom lint rules and configuration for JavaScript and related technologies.
The npm package eslint-plugin-square receives a total of 462 weekly downloads. As such, eslint-plugin-square popularity was classified as not popular.
We found that eslint-plugin-square demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 19 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
Research
Security News
Socket uncovers an npm Trojan stealing crypto wallets and BullX credentials via obfuscated code and Telegram exfiltration.
Research
Security News
Malicious npm packages posing as developer tools target macOS Cursor IDE users, stealing credentials and modifying files to gain persistent backdoor access.