Detalhes do pacote

eslint-config-scratch

scratchfoundation31.3kBSD-3-Clause11.0.28

Shareable ESLint config for Scratch

eslint, eslintconfig, prettier, scratch

readme (leia-me)

Scratch ESLint config

eslint-config-scratch defines eslint and prettier rules for Scratch Javascript and TypeScript projects. Generally speaking, this configuration uses prettier for code style and formatting and eslint to flag potential mistakes and encourage code that's easier to read and understand.

Quick Start

Install the config along with its peer dependencies, eslint and prettier:

npm install -D eslint-config-scratch eslint@^9 prettier@^3

Add eslint.config.mjs to your project root.

For a TypeScript project, you can add languageOptions to enable type checking:

// myProjectRoot/eslint.config.mjs
import { eslintConfigScratch } from 'eslint-config-scratch'

export default eslintConfigScratch.config(eslintConfigScratch.recommended, {
  languageOptions: {
    parserOptions: {
      projectService: true,
      tsconfigRootDir: import.meta.dirname,
    },
  },
})

For a JavaScript project, it might look like this:

// myProjectRoot/eslint.config.mjs
import { eslintConfigScratch } from 'eslint-config-scratch'

export default eslintConfigScratch.recommended

The function eslintConfigScratch.config is a re-export of the config function from typescript-eslint, and helps with merging and extending configurations.

Add prettier.config.mjs to your project root as well:

// myProjectRoot/prettier.config.mjs
import { prettierConfigScratch } from 'eslint-config-scratch'

export default prettierConfigScratch.recommended

Finally, add scripts like these to your package.json:

"scripts": {
  "format": "prettier --write . && eslint --fix",
  "lint": "eslint && prettier --check .",
}

Basic Configuration

The eslintConfigScratch.config is a re-export of the config function from typescript-eslint. Full documentation is available here: https://typescript-eslint.io/packages/typescript-eslint#config.

The config function can be used to add or override rules, plugins, and other configuration options. For example:

// myProjectRoot/eslint.config.mjs
import { eslintConfigScratch } from 'eslint-config-scratch'
import { globalIgnores } from 'eslint/config'
import globals from 'globals'

export default eslintConfigScratch.config(
  eslintConfigScratch.recommended,
  {
    languageOptions: {
      globals: {
        ...globals.node,
        MY_CUSTOM_GLOBAL: 'readonly',
      },
      parserOptions: {
        projectService: true,
        tsconfigRootDir: import.meta.dirname,
      },
    },
  },
  // Ignore all files in the dist directory
  globalIgnores(['dist/**/*']),
)

Granular Configuration

The eslintConfigScratch object contains granular configurations as well:

  • recommendedTypeFree: A configuration suitable for contexts without type information, such as a JavaScript project.
  • recommendedTypeChecked: A configuration suitable for contexts with type information, such as a TypeScript project. You must provide extra configuration to parserOptions to enable type checking. See here: https://typescript-eslint.io/getting-started/typed-linting/

The recommended configuration is a combination of the two, and should be suitable for most projects. Features requiring type information are enabled for TypeScript files, and features that don't require type information are enabled for all files.

Legacy Styles

Scratch used very different styling rules in eslint-config-scratch@^9 and below. If you need to use those rules, you can use these legacy configurations:

  • eslintConfigScratch.legacy.base: Legacy base configuration, not configured for any particular environment
  • eslintConfigScratch.legacy.es6: Legacy rules for targeting Scratch's supported web browsers
  • eslintConfigScratch.legacy.node: Legacy rules for targeting Node.js
  • eslintConfigScratch.legacy.react: Legacy rules for targeting Scratch's supported web browsers with React

New projects should not use these rule sets. They may disappear in the future. Scratch did not use Prettier at this time, so there is no legacy Prettier configuration.

Legacy Scratch projects usually extend more than one of these at a time, and potentially a different set per subdirectory. To do that in this new flat configuration format:

// scratch-gui/eslint.config.mjs
import { eslintConfigScratch } from 'eslint-config-scratch'
import { globalIgnores } from 'eslint/config'
import globals from 'globals'

export default eslintConfigScratch.config(
  eslintConfigScratch.legacy.base,
  eslintConfigScratch.legacy.es6,
  {
    files: ['src/**/*.js', 'src/**/*.jsx'],
    extends: [eslintConfigScratch.legacy.react],
    languageOptions: {
      globals: globals.browser,
    },
    rules: {
      // ...customized rules for `src/`...
    },
    // ...other settings for `src/`...
  },
  // ...settings for `test/`, etc...
  globalIgnores(['dist/**/*']),
)

Committing

This project uses semantic release to ensure version bumps follow semver so that projects using the config don't break unexpectedly.

In order to automatically determine the type of version bump necessary, semantic release expects commit messages to be formatted following conventional-changelog.

<type>(<scope>): <subject>
<BLANK LINE>
<body>
<BLANK LINE>
<footer>

subject and body are your familiar commit subject and body. footer is where you would include BREAKING CHANGE and ISSUES FIXED sections if applicable.

type is one of:

  • fix: A bug fix Causes a patch release (0.0.x)
  • feat: A new feature Causes a minor release (0.x.0)
  • docs: Documentation only changes
  • style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
  • refactor: A code change that neither fixes a bug nor adds a feature
  • perf: A code change that improves performance May or may not cause a minor release. It's not clear.
  • test: Adding missing tests or correcting existing tests
  • ci: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
  • chore: Other changes that don't modify src or test files
  • revert: Reverts a previous commit

Use the commitizen CLI to make commits formatted in this way:

npm install -g commitizen
npm install

Now you're ready to make commits using git cz.

Breaking changes

If you're committing a change that makes the linter more strict, or will otherwise require changes to existing code, ensure your commit specifies a breaking change. In your commit body, prefix the changes with "BREAKING CHANGE: " This will cause a major version bump so downstream projects must choose to upgrade the config and will not break the build unexpectedly.

changelog (log de mudanças)

Changelog

All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines.

11.0.28 (2025-06-28)

Bug Fixes

  • deps: update dependency prettier to v3.6.1 (#269) (5a913eb)

11.0.27 (2025-06-27)

Bug Fixes

  • deps: update dependency typescript-eslint to v8.35.0 (#268) (f4ebfe4)

11.0.26 (2025-06-26)

Bug Fixes

  • deps: update dependency prettier to v3.6.0 (#267) (fa45481)

11.0.25 (2025-06-24)

Bug Fixes

  • deps: update dependency eslint-plugin-import to v2.32.0 (#266) (c0dc462)

11.0.24 (2025-06-24)

Bug Fixes

  • deps: update dependency @eslint/markdown to v6.6.0 (#265) (7e8a86c)

11.0.23 (2025-06-19)

Bug Fixes

  • deps: update dependency typescript-eslint to v8.34.1 (#263) (5506a01)

11.0.22 (2025-06-18)

Bug Fixes

  • deps: update dependency eslint-plugin-formatjs to v5.4.0 (#262) (bad669b)

11.0.21 (2025-06-17)

Bug Fixes

  • deps: update eslint monorepo to v9.29.0 (#261) (9dcaf95)

11.0.20 (2025-06-14)

Bug Fixes

  • deps: update dependency eslint-plugin-jsdoc to v50.8.0 (#259) (ba30051)

11.0.19 (2025-06-13)

Bug Fixes

  • deps: update dependency typescript-eslint to v8.34.0 (#258) (5a4f87f)

11.0.18 (2025-06-08)

Bug Fixes

  • deps: update dependency @eslint/markdown to v6.5.0 (#256) (db05445)

11.0.17 (2025-06-07)

Bug Fixes

  • deps: update dependency typescript-eslint to v8.33.1 (#254) (2d8abf2)

11.0.16 (2025-06-07)

Bug Fixes

  • deps: update dependency @babel/eslint-parser to v7.27.5 (#253) (8f46094)

11.0.15 (2025-06-05)

Bug Fixes

  • deps: update dependency eslint-plugin-jsdoc to v50.7.1 (#251) (a284b60)

11.0.14 (2025-06-04)

Bug Fixes

  • deps: update dependency eslint-plugin-jsdoc to v50.7.0 (#250) (e362541)

11.0.13 (2025-06-03)

Bug Fixes

  • deps: update eslint monorepo to v9.28.0 (#249) (8a58474)

11.0.12 (2025-05-30)

Bug Fixes

  • deps: update dependency typescript-eslint to v8.33.0 (#248) (4bb9ab1)

11.0.11 (2025-05-28)

Bug Fixes

  • deps: update dependency globals to v16.2.0 (#247) (eb4af3e)

11.0.10 (2025-05-22)

Bug Fixes

  • deps: update dependency eslint-plugin-html to v8.1.3 (#244) (26dc23b)

11.0.9 (2025-05-20)

Bug Fixes

  • deps: update eslint monorepo to v9.27.0 (#243) (9b40f09)

11.0.8 (2025-05-17)

Bug Fixes

  • deps: update dependency eslint-plugin-jsdoc to v50.6.17 (#241) (d606bd0)

11.0.7 (2025-05-16)

Bug Fixes

  • deps: update dependency typescript-eslint to v8.32.1 (#240) (bcfb5b9)

11.0.6 (2025-05-14)

Bug Fixes

  • deps: update dependency eslint-plugin-jsdoc to v50.6.14 (#239) (469abc6)

11.0.5 (2025-05-12)

Bug Fixes

  • deps: update dependency eslint-config-prettier to v10.1.5 (#238) (a5e67e8)

11.0.4 (2025-05-10)

Bug Fixes

  • deps: update dependency globals to v16.1.0 (#236) (4a75d5f)

11.0.3 (2025-05-10)

Bug Fixes

  • deps: update dependency eslint-config-prettier to v10.1.3 (#235) (5b6c16e)

11.0.2 (2025-05-09)

Bug Fixes

  • deps: update dependency typescript-eslint to v8.32.0 (#234) (7ae7ba9)

11.0.1 (2025-05-06)

Bug Fixes

  • deps: update eslint monorepo to v9.26.0 (#232) (81ab334)

11.0.0 (2025-05-05)

Bug Fixes

  • be more careful about ext => rule mapping (d010853)
  • disable jsdoc/require-jsdoc (7d7b277)
  • don't try to check types in JS (329b4de)
  • fix linting for code blocks inside Markdown (152673f)
  • re-enable jsdoc checks (40c86c9)
  • refactor!: simplify and flatten configurations (a7dda10)

Features

  • better type help, esp. with makeEslintConfig (497bd28)

BREAKING CHANGES

  • Configurations are now returned as objects, like most shared ESLint configurations. The make*Config functions are no more. Also, everything is now exported through one file.

10.0.14 (2025-05-03)

Bug Fixes

  • deps: update dependency @babel/eslint-parser to v7.27.1 (#230) (cb5cbe2)

10.0.13 (2025-05-01)

Bug Fixes

  • deps: update dependency typescript-eslint to v8.31.1 (#229) (1eaf5da)

10.0.12 (2025-04-28)

Bug Fixes

  • deps: update dependency eslint-plugin-jsdoc to v50.6.11 (#227) (dae3867)

10.0.11 (2025-04-26)

Bug Fixes

  • deps: update dependency eslint-plugin-jsdoc to v50.6.10 (#226) (f4e570d)

10.0.10 (2025-04-25)

Bug Fixes

  • deps: update dependency typescript-eslint to v8.31.0 (#225) (dc3a2c1)

10.0.9 (2025-04-25)

Bug Fixes

  • deps: update eslint monorepo to v9.25.1 (#224) (733b10c)

10.0.8 (2025-04-21)

Bug Fixes

  • deps: update eslint monorepo to v9.25.0 (#223) (9aee248)

10.0.7 (2025-04-18)

Bug Fixes

  • deps: update dependency typescript-eslint to v8.30.1 (#222) (54fe3f3)

10.0.6 (2025-04-15)

Bug Fixes

  • deps: update dependency @eslint-community/eslint-plugin-eslint-comments to v4.5.0 (#221) (c9593ef)

10.0.5 (2025-04-13)

Bug Fixes

  • deps: update dependency eslint-config-prettier to v10.1.2 (#220) (0e1a175)

10.0.4 (2025-04-12)

Bug Fixes

  • deps: update dependency typescript-eslint to v8.29.1 (#219) (de54ce3)

10.0.3 (2025-04-08)

Bug Fixes

  • deps: update eslint monorepo to v9.24.0 (#218) (16deebf)

10.0.2 (2025-04-07)

Bug Fixes

  • deps: update dependency eslint-plugin-react to v7.37.5 (#217) (2162790)

10.0.1 (2025-04-03)

Bug Fixes

  • deps: update dependency typescript-eslint to v8.29.0 (#216) (ef09db4)

10.0.0 (2025-03-31)

  • chore!: major version bump for next-gen style rules (3687676)

BREAKING CHANGES

  • There have been several major style changes since v9.0.9, and they were accidentally released as v9.1.0 at first. This commit is meant to force a bump to v10.

9.1.0 (2025-03-31)

Features

  • enable linting MD and HTML files (a95140a)

9.0.9 (2024-09-11)

Bug Fixes

  • deps: update dependency scratch-semantic-release-config to v1.0.16 (190ff6a)

9.0.8 (2024-02-24)

Bug Fixes

  • deps: update dependency scratch-semantic-release-config to v1.0.14 (f24087d)

9.0.7 (2024-02-22)

Bug Fixes

  • deps: update dependency scratch-semantic-release-config to v1.0.13 (5e5c2f4)

9.0.6 (2024-02-22)

Bug Fixes

  • deps: update dependency scratch-semantic-release-config to v1.0.12 (df25de6)

9.0.5 (2024-02-22)

Bug Fixes

  • deps: update dependency scratch-semantic-release-config to v1.0.11 (a8dd4a9)

9.0.4 (2024-02-21)

Bug Fixes

  • deps: update dependency scratch-semantic-release-config to v1.0.10 (7d54925)

9.0.3 (2023-07-01)

Bug Fixes

  • deps: update dependency scratch-semantic-release-config to v1.0.8 (0edb9d4)

9.0.2 (2023-03-27)

Bug Fixes

  • deps: update dependency scratch-semantic-release-config to v1.0.7 (ac7f20c)

9.0.1 (2023-03-23)

Bug Fixes

  • deps: update dependency scratch-semantic-release-config to v1.0.6 (82b06e0)

9.0.0 (2022-10-13)

Bug Fixes

  • deps: fix eslint-plugin-react dep conflict (cacb72c)

BREAKING CHANGES

  • deps: now requires eslint@^8