Skip to content

fix(globals): Add globals to shared root config #1036

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Apr 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/thin-cooks-flow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"eslint-config-godaddy": patch
---

fix(globals): add globals to the config
84 changes: 27 additions & 57 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ Official GoDaddy JavaScript styleguide. It includes `eslint` packages for variou
- [`eslint-config-godaddy-react`]: Configuration for ES6 React JavaScript applications
- [`eslint-config-godaddy-typescript`]: Configuration for ES6 TypeScript applications
- [`eslint-config-godaddy-react-typescript`]: Configuration for ES6 React JavaScript applications
- [`eslint-config-godaddy-flow`]: Configuration for ES6 React JavaScript applications using Flow
- [`eslint-config-godaddy-react-flow`]: Configuration for ES6 React JavaScript applications using Flow

There are many useful features:

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

# OR (ES6 with React and TypeScript rules)
npm i eslint-config-godaddy-react-typescript --save-dev

# OR (ES6 with Flow rules)
npm i eslint-config-godaddy-flow --save-dev

# OR (ES6 with React and Flow rules)
npm i eslint-config-godaddy-react-flow --save-dev
```

## Usage

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.

### 1. Use the pre-included binaries

These use _exactly_ the configuration defined in the individual `eslint-config-godaddy*` package **with auto-fix enabled automatically.**

``` js
{
"scripts": {
"lint": "eslint-godaddy files/ you/ want-to/ lint/"
}
}
```

### 2. Define your local `.eslintrc.js` and run `eslint` yourself
### 2. Define your local `eslint.config.js|mjs` and run `eslint` yourself

``` js
module.exports = {
extends: 'godaddy',
import GDConfig from 'eslint-config-godaddy';
import { defineConfig } from 'eslint-define-config';
export default defineConfig({
extends: [
GDConfig,
],
rules: {
//
// Put any rules you wish to override here.
//
}
}
// Add your own rules here
'no-console': 'warn',
},
});
```

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`.
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`.

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

## How do I override a specific rule ?

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

``` js
{
"extends": "godaddy",
"rules": {
// Disable the 'max-params' rule
"max-params": 0
}
}
```

### 2. Add a param to specify the path of your own `.eslintrc` file in your `package.json`

``` js
{
"scripts": {
"eslint": "eslint-godaddy -c .eslintrc lib/ test/",
}
}
import GDConfig from 'eslint-config-godaddy';
import { defineConfig } from 'eslint-define-config';
export default defineConfig({
extends: [
GDConfig,
],
rules: {
// Add your own rules here
'no-console': 'warn',
},
});
```

## How do I disable auto fix

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

``` js
{
"scripts": {
"eslint:ci": "eslint-godaddy --fix=false --max-warnings=0 lib/ test/",
"eslint": "eslint -c myconfig.js lib/ test/",
}
}
```


## How do I contribute?

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

Since this repository uses npm workspaces it will install and hoist all `node_modules` to
the root of the monorepo.
Since this repository uses npm workspaces it will install and hoist all `node_modules` to the root of the monorepo.

### Submit a changeset

Expand Down Expand Up @@ -200,6 +172,4 @@ No problem. Reach out to us by [opening an issue]
[`eslint-config-godaddy-react`]: /packages/eslint-config-godaddy-react
[`eslint-config-godaddy-typescript`]: /packages/eslint-config-godaddy-typescript
[`eslint-config-godaddy-react-typescript`]: /packages/eslint-config-godaddy-react-typescript
[`eslint-config-godaddy-flow`]: /packages/eslint-config-godaddy-react-flow
[`eslint-config-godaddy-react-flow`]: /packages/eslint-config-godaddy-react-flow
[changesets]: https://github.com/changesets/changesets
Loading
Loading