eslint-config-scratch 9.0.9 → 10.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/deploy.yml +27 -21
- package/.github/workflows/signature-assistant.yml +31 -0
- package/.nvmrc +1 -0
- package/.prettierignore +1 -0
- package/CHANGELOG.md +26 -0
- package/LICENSE +3 -1
- package/README.md +173 -59
- package/commitlint.config.mjs +10 -0
- package/eslint.config.mjs +4 -0
- package/lib/eslint.mjs +274 -0
- package/lib/index.mjs +4 -0
- package/lib/legacy/index.mjs +192 -0
- package/lib/legacy/node.mjs +19 -0
- package/lib/legacy/react.mjs +100 -0
- package/lib/legacy/web.mjs +50 -0
- package/lib/prettier.mjs +31 -0
- package/package.json +39 -17
- package/prettier.config.mjs +3 -0
- package/release.config.js +8 -8
- package/renovate.json5 +2 -4
- package/commitlint.config.js +0 -4
- package/es6.js +0 -36
- package/index.js +0 -145
- package/node.js +0 -13
- package/react.js +0 -62
|
@@ -2,29 +2,35 @@ name: Build eslint-config-scratch
|
|
|
2
2
|
|
|
3
3
|
on:
|
|
4
4
|
push:
|
|
5
|
-
permissions:
|
|
5
|
+
permissions:
|
|
6
6
|
contents: write # publish a GitHub release
|
|
7
7
|
pages: write # deploy to GitHub Pages
|
|
8
8
|
issues: write # comment on released issues
|
|
9
9
|
pull-requests: write # comment on released pull requests
|
|
10
10
|
jobs:
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
11
|
+
build-eslint:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
|
|
15
|
+
- uses: wagoid/commitlint-github-action@b948419dd99f3fd78a6548d48f94e3df7f6bf3ed # v6
|
|
16
|
+
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4
|
|
17
|
+
with:
|
|
18
|
+
cache: 'npm'
|
|
19
|
+
node-version-file: '.nvmrc'
|
|
20
|
+
- name: Info
|
|
21
|
+
run: |
|
|
22
|
+
cat <<EOF
|
|
23
|
+
Node version: $(node --version)
|
|
24
|
+
NPM version: $(npm --version)
|
|
25
|
+
github.event.pull_request.head.label: ${{ github.event.pull_request.head.label }}
|
|
26
|
+
github.head_ref: ${{ github.head_ref }}
|
|
27
|
+
github.ref: ${{ github.ref }}
|
|
28
|
+
github.workflow: ${{ github.workflow }}
|
|
29
|
+
EOF
|
|
30
|
+
- run: npm ci
|
|
31
|
+
- run: npm test
|
|
32
|
+
- name: Semantic Release
|
|
33
|
+
env:
|
|
34
|
+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
35
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
36
|
+
run: npx --no -- semantic-release
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
name: 'Signature Assistant'
|
|
2
|
+
on:
|
|
3
|
+
issue_comment:
|
|
4
|
+
types: [created]
|
|
5
|
+
pull_request_target:
|
|
6
|
+
types: [opened, closed, synchronize]
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
actions: write
|
|
10
|
+
contents: read
|
|
11
|
+
pull-requests: write
|
|
12
|
+
statuses: write
|
|
13
|
+
|
|
14
|
+
jobs:
|
|
15
|
+
CLA-Assistant:
|
|
16
|
+
runs-on: ubuntu-latest
|
|
17
|
+
steps:
|
|
18
|
+
- name: 'CLA Assistant'
|
|
19
|
+
if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request_target'
|
|
20
|
+
uses: contributor-assistant/github-action@ca4a40a7d1004f18d9960b404b97e5f30a505a08 # v2.6.1
|
|
21
|
+
env:
|
|
22
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
23
|
+
# the below token should have repo scope and must be manually added by you in the repository's secrets
|
|
24
|
+
PERSONAL_ACCESS_TOKEN: ${{ secrets.GHA_AGREEMENTS_PAT }}
|
|
25
|
+
with:
|
|
26
|
+
remote-organization-name: 'scratchfoundation'
|
|
27
|
+
remote-repository-name: 'scratch-agreements'
|
|
28
|
+
path-to-signatures: 'signatures/version1/cla.json'
|
|
29
|
+
path-to-document: 'https://github.com/scratchfoundation/scratch-agreements/blob/main/CLA.md'
|
|
30
|
+
branch: 'main'
|
|
31
|
+
allowlist: semantic-release-bot,*[bot]
|
package/.nvmrc
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
22
|
package/.prettierignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/CHANGELOG.md
|
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,32 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See
|
|
4
4
|
[Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [10.0.1](https://github.com/scratchfoundation/eslint-config-scratch/compare/v10.0.0...v10.0.1) (2025-04-03)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **deps:** update dependency typescript-eslint to v8.29.0 ([#216](https://github.com/scratchfoundation/eslint-config-scratch/issues/216)) ([ef09db4](https://github.com/scratchfoundation/eslint-config-scratch/commit/ef09db4bc4d2771d4e625ec788ea914a5a284d90))
|
|
12
|
+
|
|
13
|
+
# [10.0.0](https://github.com/scratchfoundation/eslint-config-scratch/compare/v9.1.0...v10.0.0) (2025-03-31)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
* chore!: major version bump for next-gen style rules ([3687676](https://github.com/scratchfoundation/eslint-config-scratch/commit/368767667304775ef75e5c440cf9958f94e0b0a1))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### BREAKING CHANGES
|
|
20
|
+
|
|
21
|
+
* There have been several major style changes since
|
|
22
|
+
v9.0.9, and they were accidentally released as v9.1.0 at first. This
|
|
23
|
+
commit is meant to force a bump to v10.
|
|
24
|
+
|
|
25
|
+
# [9.1.0](https://github.com/scratchfoundation/eslint-config-scratch/compare/v9.0.9...v9.1.0) (2025-03-31)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### Features
|
|
29
|
+
|
|
30
|
+
* enable linting MD and HTML files ([a95140a](https://github.com/scratchfoundation/eslint-config-scratch/commit/a95140a52cffca0614d13751fe5cf9594d045b75))
|
|
31
|
+
|
|
6
32
|
## [9.0.9](https://github.com/scratchfoundation/eslint-config-scratch/compare/v9.0.8...v9.0.9) (2024-09-11)
|
|
7
33
|
|
|
8
34
|
|
package/LICENSE
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Scratch Foundation
|
|
2
4
|
All rights reserved.
|
|
3
5
|
|
|
4
6
|
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
package/README.md
CHANGED
|
@@ -1,69 +1,180 @@
|
|
|
1
1
|
# Scratch ESLint config
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`eslint-config-scratch` defines `eslint` and `prettier` rules for Scratch Javascript and TypeScript projects.
|
|
4
|
+
Generally speaking, this configuration uses `prettier` for code style and formatting and `eslint` to flag potential
|
|
5
|
+
mistakes and encourage code that's easier to read and understand.
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
## Quick Start
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
Install the config along with its peer dependencies, eslint and babel-eslint.
|
|
9
|
+
Install the config along with its peer dependencies, `eslint` and `prettier`:
|
|
10
10
|
|
|
11
11
|
```bash
|
|
12
|
-
npm install -
|
|
12
|
+
npm install -D eslint-config-scratch eslint@^9 prettier@^3
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
Add `eslint.config.mjs` to your project root (pick the `export` line appropriate for your project):
|
|
16
16
|
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
```js
|
|
18
|
+
// myProjectRoot/eslint.config.mjs
|
|
19
|
+
import { makeEslintConfig } from 'eslint-config-scratch'
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
* `scratch/react`: Rules for React projects
|
|
27
|
-
|
|
28
|
-
Usually web projects have a mix of node and web environment files. To lint both
|
|
29
|
-
with the appropriate rules, set up a base `.eslintrc.js` with the rules for node
|
|
30
|
-
and then override the node configuration in `src` (where web code usually lives).
|
|
31
|
-
E.g., with a file structure like this:
|
|
32
|
-
```
|
|
33
|
-
scratch-project
|
|
34
|
-
- .eslintrc.js
|
|
35
|
-
- package.json
|
|
36
|
-
- src
|
|
37
|
-
- .eslintrc.js
|
|
38
|
-
- index.js
|
|
21
|
+
// for a TypeScript project:
|
|
22
|
+
export default makeEslintConfig({ globals: 'browser', tsconfigRootDir: import.meta.dirname })
|
|
23
|
+
|
|
24
|
+
// for plain JavaScript:
|
|
25
|
+
export default makeEslintConfig({ globals: 'browser' })
|
|
39
26
|
```
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
module.exports = {
|
|
49
|
-
root: true,
|
|
50
|
-
extends: ['scratch', 'scratch/es6', 'scratch/react'],
|
|
51
|
-
env: {
|
|
52
|
-
browser: true
|
|
53
|
-
}
|
|
54
|
-
};
|
|
27
|
+
|
|
28
|
+
Add `prettier.config.mjs` to your project root as well:
|
|
29
|
+
|
|
30
|
+
```js
|
|
31
|
+
// myProjectRoot/prettier.config.mjs
|
|
32
|
+
import { makePrettierConfig } from 'eslint-config-scratch'
|
|
33
|
+
|
|
34
|
+
export default makePrettierConfig()
|
|
55
35
|
```
|
|
56
|
-
This will set up all the files in the project for linting as Node.js by default,
|
|
57
|
-
except for those in `src/`, which will be linted as ES6 and React files.
|
|
58
36
|
|
|
59
|
-
|
|
37
|
+
Finally, add scripts like these to your `package.json`:
|
|
38
|
+
|
|
60
39
|
```json
|
|
61
40
|
"scripts": {
|
|
62
|
-
|
|
41
|
+
"format": "prettier --write . && eslint --fix",
|
|
42
|
+
"lint": "eslint && prettier --check .",
|
|
63
43
|
}
|
|
64
44
|
```
|
|
65
45
|
|
|
46
|
+
## Basic Configuration
|
|
47
|
+
|
|
48
|
+
The `makeEslintConfig` function takes options to adjust the ESLint configuration object for your project. Most
|
|
49
|
+
projects should start with something like this:
|
|
50
|
+
|
|
51
|
+
```mjs
|
|
52
|
+
// myProjectRoot/eslint.config.mjs
|
|
53
|
+
import { makeEslintConfig } from 'eslint-config-scratch'
|
|
54
|
+
|
|
55
|
+
export default makeEslintConfig({
|
|
56
|
+
// Optional: specify global variables available in your environment
|
|
57
|
+
globals: 'browser',
|
|
58
|
+
|
|
59
|
+
// Optional: enables rules that use type info, some of which work in JS too
|
|
60
|
+
tsconfigRootDir: import.meta.dirname,
|
|
61
|
+
})
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
If you have no `tsconfig.json` (or `jsconfig.json`) in your project, you can skip the `tsconfigRootDir` option. Rules
|
|
65
|
+
that require type information will be disabled or replaced with less strict alternatives that work without type info.
|
|
66
|
+
|
|
67
|
+
### Globals
|
|
68
|
+
|
|
69
|
+
The `globals` property is optional. If present, it can take several forms:
|
|
70
|
+
|
|
71
|
+
- a string, interpreted as a key in the `globals` object exported by the `globals` package.
|
|
72
|
+
- Examples: `'browser'`, `'node'`, `'es2021'`, `'jest'`, etc.
|
|
73
|
+
- an object, set up as described in the "Specifying Globals" section of the [ESLint documentation](https://eslint.org/docs/latest/use/configure/language-options#using-configuration-files)
|
|
74
|
+
- Example: `{ myGlobal: 'readonly', anotherGlobal: 'writable' }`
|
|
75
|
+
- an array of zero or more of any mixture of the above
|
|
76
|
+
|
|
77
|
+
```mjs
|
|
78
|
+
// myProjectRoot/eslint.config.mjs
|
|
79
|
+
import { makeEslintConfig } from 'eslint-config-scratch'
|
|
80
|
+
|
|
81
|
+
export default makeEslintConfig({
|
|
82
|
+
// Optional: enables rules that use type info, some of which work in JS too
|
|
83
|
+
tsconfigRootDir: import.meta.dirname,
|
|
84
|
+
|
|
85
|
+
// Optional: specify global variables available in your environment
|
|
86
|
+
// Warning: this is a very silly configuration
|
|
87
|
+
globals: [
|
|
88
|
+
'shared-node-browser',
|
|
89
|
+
{
|
|
90
|
+
fun: 'readonly',
|
|
91
|
+
thing: false,
|
|
92
|
+
},
|
|
93
|
+
'es2021',
|
|
94
|
+
{
|
|
95
|
+
whyNot: 'writable',
|
|
96
|
+
},
|
|
97
|
+
],
|
|
98
|
+
})
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Further Customization
|
|
102
|
+
|
|
103
|
+
The return value of the `makeEslintConfig` function is a standard ESLint configuration array. This means you can
|
|
104
|
+
customize your configuration further like this:
|
|
105
|
+
|
|
106
|
+
```mjs
|
|
107
|
+
// myProjectRoot/eslint.config.mjs
|
|
108
|
+
import { makeEslintConfig } from 'eslint-config-scratch'
|
|
109
|
+
|
|
110
|
+
export default [
|
|
111
|
+
...makeEslintConfig({
|
|
112
|
+
// Optional: enables rules that use type info, some of which work in JS too
|
|
113
|
+
tsconfigRootDir: import.meta.dirname,
|
|
114
|
+
|
|
115
|
+
// Optional: specify global variables available in your environment
|
|
116
|
+
globals: 'browser',
|
|
117
|
+
}),
|
|
118
|
+
// Add custom rules or overrides here
|
|
119
|
+
{
|
|
120
|
+
files: ['*.test.js'],
|
|
121
|
+
rules: {
|
|
122
|
+
'no-console': 'off', // Allow console logs in test files
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
]
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
All ESLint configuration options are available this way. You can use this to handle globals yourself if the simplified
|
|
129
|
+
`globals` configuration from above doesn't meet your needs:
|
|
130
|
+
|
|
131
|
+
```mjs
|
|
132
|
+
// myProjectRoot/eslint.config.mjs
|
|
133
|
+
import { makeEslintConfig } from 'eslint-config-scratch'
|
|
134
|
+
import globals from 'globals'
|
|
135
|
+
|
|
136
|
+
export default [
|
|
137
|
+
...makeEslintConfig({
|
|
138
|
+
// Optional: enables rules that use type info, some of which work in JS too
|
|
139
|
+
tsconfigRootDir: import.meta.dirname,
|
|
140
|
+
}),
|
|
141
|
+
{
|
|
142
|
+
files: ['src/main/**.js'],
|
|
143
|
+
languageOptions: {
|
|
144
|
+
globals: globals.node,
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
files: ['src/renderer/**.js'],
|
|
149
|
+
languageOptions: {
|
|
150
|
+
globals: {
|
|
151
|
+
...globals.browser,
|
|
152
|
+
MY_CUSTOM_GLOBAL: 'readonly',
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
]
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
Of course, another option would be to place a different `eslint.config.mjs` file in each subdirectory. If you have
|
|
160
|
+
multiple `tsconfig.json` or `jsconfig.json` files in your project, it likely makes sense to have an
|
|
161
|
+
`eslint.config.mjs` file beside each one.
|
|
162
|
+
|
|
163
|
+
## Legacy Styles
|
|
164
|
+
|
|
165
|
+
Scratch used very different styling rules in `eslint-config-scratch@^9` and below. If you need to use those rules, you
|
|
166
|
+
can use the rule sets under `legacy/`:
|
|
167
|
+
|
|
168
|
+
- `eslint-config-scratch/legacy`: Legacy base configuration, not configured for any particular environment
|
|
169
|
+
- `eslint-config-scratch/legacy/es6`: Legacy rules for targeting Scratch's supported web browsers
|
|
170
|
+
- `eslint-config-scratch/legacy/node`: Legacy rules for targeting Node.js
|
|
171
|
+
- `eslint-config-scratch/legacy/react`: Legacy rules for targeting Scratch's supported web browsers with React
|
|
172
|
+
|
|
173
|
+
New projects should not use these rule sets. They may disappear in the future. Scratch did not use Prettier at this
|
|
174
|
+
time, so there is no legacy Prettier configuration.
|
|
175
|
+
|
|
66
176
|
## Committing
|
|
177
|
+
|
|
67
178
|
This project uses [semantic release](https://github.com/semantic-release/semantic-release)
|
|
68
179
|
to ensure version bumps follow semver so that projects using the config don't
|
|
69
180
|
break unexpectedly.
|
|
@@ -71,7 +182,8 @@ break unexpectedly.
|
|
|
71
182
|
In order to automatically determine the type of version bump necessary, semantic
|
|
72
183
|
release expects commit messages to be formatted following
|
|
73
184
|
[conventional-changelog](https://github.com/bcoe/conventional-changelog-standard/blob/master/convention.md).
|
|
74
|
-
|
|
185
|
+
|
|
186
|
+
```raw
|
|
75
187
|
<type>(<scope>): <subject>
|
|
76
188
|
<BLANK LINE>
|
|
77
189
|
<body>
|
|
@@ -84,16 +196,17 @@ where you would include `BREAKING CHANGE` and `ISSUES FIXED` sections if
|
|
|
84
196
|
applicable.
|
|
85
197
|
|
|
86
198
|
`type` is one of:
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
199
|
+
|
|
200
|
+
- `fix`: A bug fix **Causes a patch release (0.0.x)**
|
|
201
|
+
- `feat`: A new feature **Causes a minor release (0.x.0)**
|
|
202
|
+
- `docs`: Documentation only changes
|
|
203
|
+
- `style`: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
|
|
204
|
+
- `refactor`: A code change that neither fixes a bug nor adds a feature
|
|
205
|
+
- `perf`: A code change that improves performance **May or may not cause a minor release. It's not clear.**
|
|
206
|
+
- `test`: Adding missing tests or correcting existing tests
|
|
207
|
+
- `ci`: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
|
|
208
|
+
- `chore`: Other changes that don't modify src or test files
|
|
209
|
+
- `revert`: Reverts a previous commit
|
|
97
210
|
|
|
98
211
|
Use the [commitizen CLI](https://github.com/commitizen/cz-cli) to make commits
|
|
99
212
|
formatted in this way:
|
|
@@ -106,8 +219,9 @@ npm install
|
|
|
106
219
|
Now you're ready to make commits using `git cz`.
|
|
107
220
|
|
|
108
221
|
## Breaking changes
|
|
222
|
+
|
|
109
223
|
If you're committing a change that makes the linter more strict, or will
|
|
110
224
|
otherwise require changes to existing code, ensure your commit specifies a
|
|
111
|
-
breaking change.
|
|
225
|
+
breaking change. In your commit body, prefix the changes with "BREAKING CHANGE: "
|
|
112
226
|
This will cause a major version bump so downstream projects must choose to upgrade
|
|
113
227
|
the config and will not break the build unexpectedly.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Do not rename, migrate, or convert this file without checking the `wagoid/commitlint-github-action` documentation!
|
|
2
|
+
// `commitlint.config.mjs` is the only supported config file name as of `wagoid/commitlint-github-action@v6`
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @type {import('@commitlint/types').UserConfig}
|
|
6
|
+
*/
|
|
7
|
+
export default {
|
|
8
|
+
extends: ['@commitlint/config-conventional'],
|
|
9
|
+
ignores: [message => message.startsWith('chore(release):')],
|
|
10
|
+
}
|