Skip to content
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

feat: eslint 9 support #627

Merged
merged 2 commits into from
Jul 11, 2024
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
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.github
CHANGELOG.md
CODE_OF_CONDUCT.md
28 changes: 13 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@ npm install eslint-plugin-compat
#### New Config (`eslint.config.mjs`)

```js
import compat from "eslint-plugin-compat"
import compat from "eslint-plugin-compat";

export default [
compat.configs['flat/recommended']
];
export default [compat.configs["flat/recommended"]];
```

#### Legacy Config (`.eslintrc.json`)
Expand All @@ -38,8 +36,8 @@ export default [
"plugins": ["compat"],
"extends": ["plugin:compat/recommended"],
"env": {
"browser": true
}
"browser": true,
},
// ...
}
```
Expand All @@ -53,7 +51,7 @@ Browser targets are configured using [browserslist](https://github.com/browsersl
```jsonc
{
// ...
"browserslist": ["defaults"]
"browserslist": ["defaults"],
}
```

Expand All @@ -77,9 +75,9 @@ Add polyfills to the settings section of your eslint config. Append the name of
// Example of API with no property (i.e. a function)
"fetch",
// Example of instance method, must add `.prototype.`
"Array.prototype.push"
]
}
"Array.prototype.push",
],
},
}
```

Expand All @@ -91,8 +89,8 @@ This plugin also supports linting the compatibility of ES APIs in addition to We
{
// ...
"settings": {
"lintAllEsApis": true
}
"lintAllEsApis": true,
},
}
```

Expand Down Expand Up @@ -123,9 +121,9 @@ Target `modern` browserslist environment:
{
"settings": {
"browserslistOpts": {
"env": "modern"
}
}
"env": "modern",
},
},
}
```

Expand Down
4 changes: 2 additions & 2 deletions docs/rules/compat.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ This rule enables linting your code for browser compatibility.

```js
// Targeting IE
fetch('https://exmaple.com');
fetch("https://exmaple.com");
```

## This will not be reported

```js
// Using default browser targets
fetch('https://exmaple.com');
fetch("https://exmaple.com");
```
50 changes: 50 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import path from "node:path";
import { fileURLToPath } from "node:url";

import { includeIgnoreFile } from "@eslint/compat";
import eslint from "@eslint/js";
import eslintPlugin from "eslint-plugin-eslint-plugin";
import eslintConfigPrettier from "eslint-config-prettier";
import tseslint from "typescript-eslint";
import globals from "globals";
import compat from "./lib/esm/src/index.js";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const gitignorePath = path.resolve(__dirname, ".gitignore");

export default [
includeIgnoreFile(gitignorePath),
eslint.configs.recommended,
...tseslint.configs.recommended,
eslintPlugin.configs["flat/recommended"],
compat.configs["flat/recommended"],
eslintConfigPrettier,
{
files: ["**/*.ts", "**/*.js", "**/*.mjs"],
rules: {
"no-template-curly-in-string": ["error"],
"no-console": ["warn"],
},
languageOptions: {
globals: {
...globals.jest,
...globals.node,
},
},
},
];

/*
parserOptions: {
project: './tsconfig.json'
},
"extends": [
"airbnb-typescript/base",
"plugin:import/typescript",
],
"rules": {
"import/extensions": "off",
"import/no-extraneous-dependencies": "off"
},
*/
Loading
Loading