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
35 changes: 35 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,38 @@ 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"
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
5 changes: 0 additions & 5 deletions jest.config.cjs

This file was deleted.

15 changes: 15 additions & 0 deletions jest.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/** @type {import('jest').Config} */
export default {
clearMocks: true,
coverageDirectory: "coverage",
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.
moduleNameMapper: {
"(.+)\\.jsx?": "$1",
"(.+)\\.mjs": "$1.mts",
},
transform: {
"^.+\\.(ts|tsx|js|jsx|mjs|mts)$": "babel-jest",
},
};
17 changes: 17 additions & 0 deletions packages/flat-config/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import preferFunctionComponent from "eslint-plugin-react-prefer-function-component/config";

export default [
{
files: ["*.jsx"],
languageOptions: {
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
ecmaFeatures: {
jsx: true,
},
},
},
},
preferFunctionComponent.configs.recommended,
];
7 changes: 7 additions & 0 deletions packages/flat-config/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Component } from "react";

export class Foo extends Component {

Check failure on line 3 in packages/flat-config/index.jsx

View workflow job for this annotation

GitHub Actions / E2E Flat Config

Class component should be written as a function
render() {
return <div>{this.props.foo}</div>;
}
}
17 changes: 17 additions & 0 deletions packages/flat-config/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "flat-config",
"type": "module",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"eslint": "^9.22.0",
"eslint-plugin-react-prefer-function-component": "workspace:^"
}
}
11 changes: 11 additions & 0 deletions packages/legacy-config/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// eslint-disable-next-line no-undef
module.exports = {
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
ecmaFeatures: {
jsx: true,
},
},
extends: ["plugin:react-prefer-function-component/recommended"],
};
7 changes: 7 additions & 0 deletions packages/legacy-config/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Component } from "react";

export class Foo extends Component {

Check failure on line 3 in packages/legacy-config/index.jsx

View workflow job for this annotation

GitHub Actions / E2E Legacy Config

Class component should be written as a function
render() {
return <div>{this.props.foo}</div>;
}
}
Loading