{"id":14978375,"url":"https://github.com/square/eslint-plugin-square","last_synced_at":"2025-03-23T12:08:56.269Z","repository":{"id":36990484,"uuid":"243838452","full_name":"square/eslint-plugin-square","owner":"square","description":"An ESLint plugin containing custom JavaScript, Ember, React, TypeScript rules and configurations tailored to Square's needs.","archived":false,"fork":false,"pushed_at":"2024-09-23T00:45:08.000Z","size":3881,"stargazers_count":22,"open_issues_count":10,"forks_count":15,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-21T21:51:35.955Z","etag":null,"topics":["ember","emberjs","eslint","eslint-plugin","javascript","linting","react","typescript"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/square.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-02-28T19:23:32.000Z","updated_at":"2024-11-16T05:59:03.000Z","dependencies_parsed_at":"2024-08-27T17:18:46.900Z","dependency_job_id":"7b2908b6-664a-40d6-af94-2bb466addf77","html_url":"https://github.com/square/eslint-plugin-square","commit_stats":{"total_commits":720,"total_committers":18,"mean_commits":40.0,"dds":0.5861111111111111,"last_synced_commit":"f550511c40e9b756ec3cf70a9f9b5f98219d3be6"},"previous_names":[],"tags_count":44,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/square%2Feslint-plugin-square","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/square%2Feslint-plugin-square/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/square%2Feslint-plugin-square/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/square%2Feslint-plugin-square/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/square","download_url":"https://codeload.github.com/square/eslint-plugin-square/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244982042,"owners_count":20542300,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ember","emberjs","eslint","eslint-plugin","javascript","linting","react","typescript"],"created_at":"2024-09-24T13:57:29.997Z","updated_at":"2025-03-23T12:08:56.247Z","avatar_url":"https://github.com/square.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# eslint-plugin-square\n\n[![npm version](https://badge.fury.io/js/eslint-plugin-square.svg)](https://badge.fury.io/js/eslint-plugin-square)\n![CI](https://github.com/square/eslint-plugin-square/workflows/CI/badge.svg)\n\nThis plugin contains lint rule definitions and configurations for [ESLint](http://eslint.org) 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.\n\n## Requirements\n\n- [ESLint](https://eslint.org/) `\u003e= 8.18.0`\n- [Node.js](https://nodejs.org/) `^18.0.0 || \u003e=20.0.0`\n\n## Usage\n\nInstall alongside ESLint via yarn (or npm):\n\n```sh\nyarn add --dev eslint eslint-plugin-square npm-run-all\n```\n\nIf you're creating a new ESLint configuration, refer to ESLint's [documentation](https://eslint.org/docs/latest/use/configure/configuration-files) 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`.\n\nOnce you have an ESLint configuration file, add this plugin to your `extends` property:\n\n```js\nmodule.exports = {\n  extends: ['plugin:square/base'], // Or other configuration.\n};\n```\n\nAdd the relevant lint scripts in `package.json` with [npm-run-all](https://github.com/mysticatea/npm-run-all) and include detection for [unused disable directives](https://eslint.org/docs/latest/user-guide/command-line-interface#--report-unused-disable-directives):\n\n```json\n{\n  \"scripts\": {\n    \"lint\": \"npm-run-all --continue-on-error --aggregate-output --parallel lint:*\",\n    \"lint:js\": \"eslint --report-unused-disable-directives --cache .\"\n  }\n}\n```\n\nConfigure linting to run:\n\n- With the ESLint extension for your IDE\n- In your precommit hook (see [lint-staged](https://github.com/okonet/lint-staged) and [husky](https://github.com/typicode/husky))\n- As a build check during CI (in case IDE warnings or the precommit hook are bypassed)\n\nFix violations using:\n\n- Lint rule autofixers (`eslint --fix`)\n- Lint rule suggestions (a fixer option provided by some rules on highlighted violations in IDEs)\n- Codemods (sometimes provided for larger codebase transformations)\n- Find-and-replace (with RegExp if necessary)\n- Manual fixes\n\nSometimes, you may not want to fix certain violations, for reasons such as:\n\n- Some code is too risky to change\n- A rule may have too many violations and fixing is too tedious / manual\n- A rule may have false positives and flag legitimate code\n- A rule may not apply in all circumstances (such as a rule that is only useful for test code)\n- You may prefer to follow different conventions/styles in your codebase\n- You may want to follow-up later to address a specific rule in its own PR\n\nIf you prefer not to adopt a specific rule, you can disable it:\n\n- Globally (in the global configuration file)\n- In specific directories (in an override in the global configuration file)\n- In specific files or on specific lines using comments (`// eslint-disable-line no-empty-function`)\n\n## Configurations\n\n|     | Name | Description |\n| --- | --- | --- |\n| ✅ | [base](lib/config/base.js) | 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. |\n| 🔥 | [ember](lib/config/ember.js) | [Ember.js](https://www.emberjs.com/)-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. |\n| ⚛️ | [react](lib/config/react.js) | [React](https://reactjs.org/)-specific additions on top of `base`. Includes recommended rules from [eslint-plugin-jsx-a11y], [eslint-plugin-react], and [eslint-plugin-react-hooks]. |\n| 🔒 | [strict](lib/config/strict.js) | A variety of stricter lint rules on top of `base`. |\n| ⌨️ | [typescript](lib/config/typescript.js) | [TypeScript](https://www.typescriptlang.org/)-specific additions on top of `base`. Use with [@typescript-eslint/parser]. |\n\nRules enabled by these configurations should meet the following criteria:\n\n- They make sense in a wide variety of codebases (and have been tested in a variety of Square's applications).\n- They are generally acceptable and desirable (in terms of enforcing best practices, consistency, avoiding bugs) to most developers.\n- There is a practical migration path (autofixers, codemod, find-and-replace, manual fixes) for enabling them in most applications.\n\n## Custom rules\n\n\u003c!-- begin auto-generated rules list --\u003e\n\n💼 [Configurations](https://github.com/square/eslint-plugin-square/blob/master/README.md#configurations) enabled in.\\\n🔥 Set in the `ember` [configuration](https://github.com/square/eslint-plugin-square/blob/master/README.md#configurations).\\\n🔒 Set in the `strict` [configuration](https://github.com/square/eslint-plugin-square/blob/master/README.md#configurations).\\\n🔧 Automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/user-guide/command-line-interface#--fix).\\\n💡 Manually fixable by [editor suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).\n\n| Name                                                                               | Description                                                                              | 💼    | 🔧 | 💡 |\n| :--------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------------- | :---- | :- | :- |\n| [no-assert-ok-find](docs/rules/no-assert-ok-find.md)                               | disallow usage of `assert.ok(find(...))` as it will always pass                          | 🔥    |    | 💡 |\n| [no-handlebar-interpolation](docs/rules/no-handlebar-interpolation.md)             | disallow unsafe HTML in strings/hbs/translations                                         |       |    |    |\n| [no-missing-tests](docs/rules/no-missing-tests.md)                                 | disallow files without a corresponding test file                                         |       |    |    |\n| [no-restricted-files](docs/rules/no-restricted-files.md)                           | disallow files with a path matching a specific regexp                                    |       |    |    |\n| [no-test-return-value](docs/rules/no-test-return-value.md)                         | disallow test functions with a return value                                              | 🔥    |    | 💡 |\n| [no-translation-key-interpolation](docs/rules/no-translation-key-interpolation.md) | disallow string interpolation in translation keys                                        | 🔥    |    |    |\n| [require-await-function](docs/rules/require-await-function.md)                     | enforce using `await` with calls to specified functions                                  | 🔥    | 🔧 |    |\n| [use-call-count-test-assert](docs/rules/use-call-count-test-assert.md)             | enforce using `assert.equal(...callCount, ...);` instead of `assert.ok(...calledOnce);`  | 🔥 🔒 | 🔧 |    |\n| [use-ember-find](docs/rules/use-ember-find.md)                                     | require use of Ember's `find` helper instead of `jQuery` for selecting elements in tests | 🔥    | 🔧 |    |\n\n\u003c!-- end auto-generated rules list --\u003e\n\nNote 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:\n\n- We haven't found the appropriate ESLint plugin to upstream them to.\n- We haven't found the time to upstream them.\n- They are specific to Square in some way / not generic enough.\n\nIf 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](https://astexplorer.net/) while writing it.\n\nLint rule ideas often come from:\n\n- A source of frequent \"nit\" comments in PRs\n- Common issues that newcomers stumble on\n- Code that indicates a bug, mistake, or bad practice\n- Inconsistencies throughout the codebase\n- Outdated / obsolete / legacy code\n\n[eslint]: https://eslint.org/\n[eslint-plugin-ember]: https://github.com/ember-cli/eslint-plugin-ember\n[eslint-plugin-eslint-comments]: https://github.com/mysticatea/eslint-plugin-eslint-comments\n[eslint-plugin-filenames]: https://github.com/selaux/eslint-plugin-filenames\n[eslint-plugin-import]: https://github.com/benmosher/eslint-plugin-import\n[eslint-plugin-jsx-a11y]: https://github.com/jsx-eslint/eslint-plugin-jsx-a11y\n[eslint-plugin-react]: https://github.com/jsx-eslint/eslint-plugin-react\n[eslint-plugin-react-hooks]: https://github.com/facebook/react/tree/main/packages/eslint-plugin-react-hooks\n[eslint-plugin-unicorn]: https://github.com/sindresorhus/eslint-plugin-unicorn\n[prettier]: https://prettier.io/\n[@typescript-eslint/parser]: https://github.com/typescript-eslint/typescript-eslint/tree/main/packages/parser\n\n## Related\n\nConsider adding other linters not included by plugin:\n\n- [check-dependency-version-consistency](https://github.com/bmish/check-dependency-version-consistency) for monorepos\n- [commitlint](https://github.com/conventional-changelog/commitlint)\n- [ember-template-lint](https://github.com/ember-template-lint/ember-template-lint) for handlebars files\n- [eslint-plugin-markdown](https://github.com/eslint/eslint-plugin-markdown) for markdown code samples\n- [eslint-plugin-node](https://github.com/mysticatea/eslint-plugin-node) for Node files\n- [markdownlint-cli](https://github.com/igorshubovych/markdownlint-cli) for markdown documentation formatting\n- [npm-package-json-lint](https://github.com/tclindner/npm-package-json-lint) for package.json\n- [stylelint](https://github.com/stylelint/stylelint) for CSS files\n\n## License\n\n```plaintext\nCopyright 2020 Square Inc.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsquare%2Feslint-plugin-square","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsquare%2Feslint-plugin-square","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsquare%2Feslint-plugin-square/lists"}