Skip to content

Commit 545241e

Browse files
fix(globals): Add globals to shared root config (#1036)
* fix: Add globals by default * fix: correct usage of globals * docs: update readme's for the packages to reference flat config * chore: add changeset * chore(deps): update deps to latest * test: add `defineConfig` to config files for proper testing * test: fix lint test * chore(turbo): update turbo to latest * chore: update changeset as a patch --------- Co-authored-by: Richard Markins <[email protected]>
1 parent bafb902 commit 545241e

File tree

17 files changed

+554
-616
lines changed

17 files changed

+554
-616
lines changed

.changeset/thin-cooks-flow.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"eslint-config-godaddy": patch
3+
---
4+
5+
fix(globals): add globals to the config

README.md

Lines changed: 27 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ Official GoDaddy JavaScript styleguide. It includes `eslint` packages for variou
66
- [`eslint-config-godaddy-react`]: Configuration for ES6 React JavaScript applications
77
- [`eslint-config-godaddy-typescript`]: Configuration for ES6 TypeScript applications
88
- [`eslint-config-godaddy-react-typescript`]: Configuration for ES6 React JavaScript applications
9-
- [`eslint-config-godaddy-flow`]: Configuration for ES6 React JavaScript applications using Flow
10-
- [`eslint-config-godaddy-react-flow`]: Configuration for ES6 React JavaScript applications using Flow
119

1210
There are many useful features:
1311

@@ -43,44 +41,29 @@ npm i eslint-config-godaddy-typescript --save-dev
4341

4442
# OR (ES6 with React and TypeScript rules)
4543
npm i eslint-config-godaddy-react-typescript --save-dev
46-
47-
# OR (ES6 with Flow rules)
48-
npm i eslint-config-godaddy-flow --save-dev
49-
50-
# OR (ES6 with React and Flow rules)
51-
npm i eslint-config-godaddy-react-flow --save-dev
5244
```
5345

5446
## Usage
5547

5648
There are two ways to use this styleguide depending on your own tooling preference: directly using pre-included binaries or running `eslint` yourself with a custom `.eslintrc` config.
5749

58-
### 1. Use the pre-included binaries
59-
60-
These use _exactly_ the configuration defined in the individual `eslint-config-godaddy*` package **with auto-fix enabled automatically.**
61-
62-
``` js
63-
{
64-
"scripts": {
65-
"lint": "eslint-godaddy files/ you/ want-to/ lint/"
66-
}
67-
}
68-
```
69-
70-
### 2. Define your local `.eslintrc.js` and run `eslint` yourself
50+
### 2. Define your local `eslint.config.js|mjs` and run `eslint` yourself
7151

7252
``` js
73-
module.exports = {
74-
extends: 'godaddy',
53+
import GDConfig from 'eslint-config-godaddy';
54+
import { defineConfig } from 'eslint-define-config';
55+
export default defineConfig({
56+
extends: [
57+
GDConfig,
58+
],
7559
rules: {
76-
//
77-
// Put any rules you wish to override here.
78-
//
79-
}
80-
}
60+
// Add your own rules here
61+
'no-console': 'warn',
62+
},
63+
});
8164
```
8265

83-
The `--fix` option in `eslint` is [**only** available as a CLI option](https://github.com/eslint/eslint/issues/8041). Auto-fix will *NOT be enabled* unless you run `eslint --fix` in your `package.json`.
66+
The `--fix` option in `eslint` is [**only** available as a CLI option](https://github.com/eslint/eslint/issues/8041). Auto-fix will **_NOT be enabled_** unless you run `eslint --fix` in your `package.json`.
8467

8568
``` js
8669
{
@@ -102,42 +85,32 @@ This section is a place for additional best practices that may be useful but are
10285

10386
## How do I override a specific rule ?
10487

105-
### 1. Add a `.eslintrc` file at the root of your project:
88+
### 1. Add a `eslint.config.js|mjs` file at the root of your project
10689

10790
``` js
108-
{
109-
"extends": "godaddy",
110-
"rules": {
111-
// Disable the 'max-params' rule
112-
"max-params": 0
113-
}
114-
}
115-
```
116-
117-
### 2. Add a param to specify the path of your own `.eslintrc` file in your `package.json`
118-
119-
``` js
120-
{
121-
"scripts": {
122-
"eslint": "eslint-godaddy -c .eslintrc lib/ test/",
123-
}
124-
}
91+
import GDConfig from 'eslint-config-godaddy';
92+
import { defineConfig } from 'eslint-define-config';
93+
export default defineConfig({
94+
extends: [
95+
GDConfig,
96+
],
97+
rules: {
98+
// Add your own rules here
99+
'no-console': 'warn',
100+
},
101+
});
125102
```
126103

127-
## How do I disable auto fix
128-
129-
You may wish to disable auto fix so when you run `eslint` in ci it will error
130-
if it catches anything unlinted.
104+
### 2. Add a param to specify the path of your own `my-config.js|cjs|mjs` file in your `package.json`
131105

132106
``` js
133107
{
134108
"scripts": {
135-
"eslint:ci": "eslint-godaddy --fix=false --max-warnings=0 lib/ test/",
109+
"eslint": "eslint -c myconfig.js lib/ test/",
136110
}
137111
}
138112
```
139113

140-
141114
## How do I contribute?
142115

143116
Fork this repository and submit a pull request.
@@ -150,8 +123,7 @@ For a first time setup make sure to run from the root of the monorepo
150123
npm install
151124
```
152125

153-
Since this repository uses npm workspaces it will install and hoist all `node_modules` to
154-
the root of the monorepo.
126+
Since this repository uses npm workspaces it will install and hoist all `node_modules` to the root of the monorepo.
155127

156128
### Submit a changeset
157129

@@ -200,6 +172,4 @@ No problem. Reach out to us by [opening an issue]
200172
[`eslint-config-godaddy-react`]: /packages/eslint-config-godaddy-react
201173
[`eslint-config-godaddy-typescript`]: /packages/eslint-config-godaddy-typescript
202174
[`eslint-config-godaddy-react-typescript`]: /packages/eslint-config-godaddy-react-typescript
203-
[`eslint-config-godaddy-flow`]: /packages/eslint-config-godaddy-react-flow
204-
[`eslint-config-godaddy-react-flow`]: /packages/eslint-config-godaddy-react-flow
205175
[changesets]: https://github.com/changesets/changesets

0 commit comments

Comments
 (0)