Skip to content
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
36 changes: 0 additions & 36 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,39 +31,3 @@ jobs:
with:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
e2e-legacy-config:
name: E2E Legacy Config
runs-on: ubuntu-latest
steps:
- uses: tatethurston/github-actions/build@main
- name: pnpm eslint
run: |
cd packages/legacy-config
output=$(pnpm eslint index.jsx || true)
echo "$output"

expected="Class component should be written as a function react-prefer-function-component/react-prefer-function-component"
if [[ "$output" != *"$expected"* ]]; then
echo "❌ Fail"
exit 1
else
echo "✅ Pass"
fi
e2e-flat-config:
name: E2E Flat Config
runs-on: ubuntu-latest
steps:
- uses: tatethurston/github-actions/build@main
- name: pnpm eslint
run: |
cd packages/flat-config
output=$(pnpm eslint index.jsx || true)
echo "$output"

expected="Class component should be written as a function react-prefer-function-component/react-prefer-function-component"
if [[ "$output" != *"$expected"* ]]; then
echo "❌ Fail"
exit 1
else
echo "✅ Pass"
fi
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,17 @@ export default [

### ESLint Legacy Configuration

`.eslintrc` configuration:
`.eslintrc.js` configuration:

```js
module.exports = {
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
ecmaFeatures: {
jsx: true,
},
},
extends: ["plugin:react-prefer-function-component/recommended"],
};
```
Expand Down
2 changes: 1 addition & 1 deletion examples/custom-config/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "example-custom-config",
"version": "1.0.0",
"description": "",
"name": "test",
"scripts": {
"lint": "eslint *.jsx"
},
Expand Down
2 changes: 1 addition & 1 deletion examples/flat-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"version": "1.0.0",
"type": "module",
"description": "",
"name": "flat-config",
"name": "examples-flat-config",
"scripts": {
"lint": "eslint ."
},
Expand Down
2 changes: 1 addition & 1 deletion examples/recommended-config/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "recommended-config",
"version": "1.0.0",
"description": "",
"name": "test",
"scripts": {
"lint": "eslint *.jsx"
},
Expand Down
1 change: 1 addition & 0 deletions jest.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
export default {
clearMocks: true,
coverageDirectory: "coverage",
prettierPath: null,
testEnvironment: "node",
// TS ESM imports are referenced with .js extensions, but jest will fail to find
// the uncompiled file because it ends with .ts and is looking for .js.
Expand Down
28 changes: 28 additions & 0 deletions packages/flat-config/test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { spawnSync } from "child_process";

function run(cmd: string) {
return spawnSync(cmd, { shell: true, encoding: "utf8" });
}

function removeAbsolutePathToEslintFile(str: string): string {
return str.replace(__dirname, "");
}

describe("flat config", () => {
beforeAll(() => process.chdir(__dirname));

it("flags errors", () => {
const result = run("pnpm eslint index.jsx");
expect(removeAbsolutePathToEslintFile(result.stdout))
.toMatchInlineSnapshot(`
"
/index.jsx
3:14 error Class component should be written as a function react-prefer-function-component/react-prefer-function-component

✖ 1 problem (1 error, 0 warnings)

"
`);
expect(result.status).toEqual(1);
});
});
28 changes: 28 additions & 0 deletions packages/legacy-config/test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { spawnSync } from "child_process";

function run(cmd: string) {
return spawnSync(cmd, { shell: true, encoding: "utf8" });
}

function removeAbsolutePathToEslintFile(str: string): string {
return str.replace(__dirname, "");
}

describe("flat config", () => {
beforeAll(() => process.chdir(__dirname));

it("flags errors", () => {
const result = run("pnpm eslint index.jsx");
expect(removeAbsolutePathToEslintFile(result.stdout))
.toMatchInlineSnapshot(`
"
/index.jsx
3:14 error Class component should be written as a function react-prefer-function-component/react-prefer-function-component

✖ 1 problem (1 error, 0 warnings)

"
`);
expect(result.status).toEqual(1);
});
});