File tree Expand file tree Collapse file tree 8 files changed +68
-40
lines changed Expand file tree Collapse file tree 8 files changed +68
-40
lines changed Original file line number Diff line number Diff line change 3131 with :
3232 fail_ci_if_error : true
3333 token : ${{ secrets.CODECOV_TOKEN }}
34- e2e-legacy-config :
35- name : E2E Legacy Config
36- runs-on : ubuntu-latest
37- steps :
38- - uses : tatethurston/github-actions/build@main
39- - name : pnpm eslint
40- run : |
41- cd packages/legacy-config
42- output=$(pnpm eslint index.jsx || true)
43- echo "$output"
44-
45- expected="Class component should be written as a function react-prefer-function-component/react-prefer-function-component"
46- if [[ "$output" != *"$expected"* ]]; then
47- echo "❌ Fail"
48- exit 1
49- else
50- echo "✅ Pass"
51- fi
52- e2e-flat-config :
53- name : E2E Flat Config
54- runs-on : ubuntu-latest
55- steps :
56- - uses : tatethurston/github-actions/build@main
57- - name : pnpm eslint
58- run : |
59- cd packages/flat-config
60- output=$(pnpm eslint index.jsx || true)
61- echo "$output"
62-
63- expected="Class component should be written as a function react-prefer-function-component/react-prefer-function-component"
64- if [[ "$output" != *"$expected"* ]]; then
65- echo "❌ Fail"
66- exit 1
67- else
68- echo "✅ Pass"
69- fi
Original file line number Diff line number Diff line change @@ -79,10 +79,17 @@ export default [
7979
8080### ESLint Legacy Configuration
8181
82- ` .eslintrc ` configuration:
82+ ` .eslintrc.js ` configuration:
8383
8484``` js
8585module .exports = {
86+ parserOptions: {
87+ ecmaVersion: " latest" ,
88+ sourceType: " module" ,
89+ ecmaFeatures: {
90+ jsx: true ,
91+ },
92+ },
8693 extends: [" plugin:react-prefer-function-component/recommended" ],
8794};
8895```
Original file line number Diff line number Diff line change 11{
2+ "name" : " example-custom-config" ,
23 "version" : " 1.0.0" ,
34 "description" : " " ,
4- "name" : " test" ,
55 "scripts" : {
66 "lint" : " eslint *.jsx"
77 },
Original file line number Diff line number Diff line change 22 "version" : " 1.0.0" ,
33 "type" : " module" ,
44 "description" : " " ,
5- "name" : " flat-config" ,
5+ "name" : " examples- flat-config" ,
66 "scripts" : {
77 "lint" : " eslint ."
88 },
Original file line number Diff line number Diff line change 11{
2+ "name" : " recommended-config" ,
23 "version" : " 1.0.0" ,
34 "description" : " " ,
4- "name" : " test" ,
55 "scripts" : {
66 "lint" : " eslint *.jsx"
77 },
Original file line number Diff line number Diff line change 22export default {
33 clearMocks : true ,
44 coverageDirectory : "coverage" ,
5+ prettierPath : null ,
56 testEnvironment : "node" ,
67 // TS ESM imports are referenced with .js extensions, but jest will fail to find
78 // the uncompiled file because it ends with .ts and is looking for .js.
Original file line number Diff line number Diff line change 1+ import { spawnSync } from "child_process" ;
2+
3+ function run ( cmd : string ) {
4+ return spawnSync ( cmd , { shell : true , encoding : "utf8" } ) ;
5+ }
6+
7+ function removeAbsolutePathToEslintFile ( str : string ) : string {
8+ return str . replace ( __dirname , "" ) ;
9+ }
10+
11+ describe ( "flat config" , ( ) => {
12+ beforeAll ( ( ) => process . chdir ( __dirname ) ) ;
13+
14+ it ( "flags errors" , ( ) => {
15+ const result = run ( "pnpm eslint index.jsx" ) ;
16+ expect ( removeAbsolutePathToEslintFile ( result . stdout ) )
17+ . toMatchInlineSnapshot ( `
18+ "
19+ /index.jsx
20+ 3:14 error Class component should be written as a function react-prefer-function-component/react-prefer-function-component
21+
22+ ✖ 1 problem (1 error, 0 warnings)
23+
24+ "
25+ ` ) ;
26+ expect ( result . status ) . toEqual ( 1 ) ;
27+ } ) ;
28+ } ) ;
Original file line number Diff line number Diff line change 1+ import { spawnSync } from "child_process" ;
2+
3+ function run ( cmd : string ) {
4+ return spawnSync ( cmd , { shell : true , encoding : "utf8" } ) ;
5+ }
6+
7+ function removeAbsolutePathToEslintFile ( str : string ) : string {
8+ return str . replace ( __dirname , "" ) ;
9+ }
10+
11+ describe ( "flat config" , ( ) => {
12+ beforeAll ( ( ) => process . chdir ( __dirname ) ) ;
13+
14+ it ( "flags errors" , ( ) => {
15+ const result = run ( "pnpm eslint index.jsx" ) ;
16+ expect ( removeAbsolutePathToEslintFile ( result . stdout ) )
17+ . toMatchInlineSnapshot ( `
18+ "
19+ /index.jsx
20+ 3:14 error Class component should be written as a function react-prefer-function-component/react-prefer-function-component
21+
22+ ✖ 1 problem (1 error, 0 warnings)
23+
24+ "
25+ ` ) ;
26+ expect ( result . status ) . toEqual ( 1 ) ;
27+ } ) ;
28+ } ) ;
You can’t perform that action at this time.
0 commit comments