Skip to content

Commit 74f4984

Browse files
authored
Merge pull request #69 from phanect/doc-flatconfig-workaround
Add notice about Flat Config into README
2 parents dac8177 + 555c732 commit 74f4984

File tree

8 files changed

+83
-1
lines changed

8 files changed

+83
-1
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ $ npm install --save-dev @typescript-eslint/eslint-plugin
2424

2525
## Usage
2626

27+
### eslint.config.* (Flat Config)
28+
29+
Unfortunately, eslint-plugin-editorconfig does not work properly with Flat Config for now, even if you use `@eslint/eslintrc` for compatibility.
30+
Please wait for the next version.
31+
32+
### .eslintrc.*
33+
2734
Like other ESLint plugins,
2835

2936
- add rules in the `rules`

examples/flat-config/.editorconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
indent_style = space
7+
indent_size = 2
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false

examples/flat-config/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Configuration example for Flat Config
2+
3+
This directory is an example of using eslint-plugin-editorconfig with Flat Config.
4+
Unfortunately, it does not work properly with Flat Config yet, even if you use `@eslint/eslintrc` for compatibility.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { dirname, join } from "node:path";
2+
import { fileURLToPath } from "node:url";
3+
import { FlatCompat } from "@eslint/eslintrc";
4+
5+
const __dirname = dirname(fileURLToPath(import.meta.url));
6+
7+
const compat = new FlatCompat({
8+
baseDirectory: __dirname,
9+
resolvePluginsRelativeTo: __dirname,
10+
});
11+
12+
/** @type { import("eslint").Linter.FlatConfig[] } */
13+
export default [
14+
...compat.config({
15+
extends: [ "plugin:editorconfig/all" ],
16+
plugins: [ "editorconfig" ],
17+
}).map(config => ({
18+
...config,
19+
ignores: [ join(__dirname, "src/invalid.ts") ]
20+
})),
21+
];

examples/flat-config/package.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "epe-flat-config-example",
3+
"version": "0.0.0",
4+
"license": "MIT",
5+
"type": "module",
6+
"private": true,
7+
"scripts": {
8+
"lint": "eslint ."
9+
},
10+
"devDependencies": {
11+
"@types/node": "^20.10.6",
12+
"eslint": "^8.56.0",
13+
"eslint-plugin-editorconfig": "^4.0.3",
14+
"undici": "^6.2.1"
15+
}
16+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { fetch } from "undici";
2+
3+
const res = await fetch("https://example.com");
4+
5+
try {
6+
const data = await res.json(); // This line should be warned by this plugin
7+
console.log(data);
8+
} catch (err) {
9+
console.error(err);
10+
process.exit(1);
11+
}

examples/flat-config/src/valid.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { fetch } from "undici";
2+
3+
const res = await fetch("https://example.com");
4+
5+
try {
6+
const data = await res.json();
7+
console.log(data);
8+
} catch (err) {
9+
console.error(err);
10+
process.exit(1);
11+
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"license": "MIT",
1818
"repository": {
1919
"type": "git",
20-
"url": "https://github.com/phanect/eslint-plugin-editorconfig.git"
20+
"url": "git+https://github.com/phanect/eslint-plugin-editorconfig.git"
2121
},
2222
"bugs": {
2323
"url": "https://github.com/phanect/eslint-plugin-editorconfig/issues"

0 commit comments

Comments
 (0)