-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
359 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,13 @@ | ||
import baseConfig from './src/base.js'; | ||
import configs from './src/index.js'; | ||
|
||
export default [ | ||
...baseConfig, | ||
{ ignores: ['**/tests/base', '**/tests/typescript', '**/dist'] }, | ||
...configs.configs.base, | ||
{ | ||
ignores: [ | ||
'**/tests/base', | ||
'**/tests/typescript', | ||
'**/tests/react', | ||
'**/dist', | ||
], | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
import baseConfig from './base.js'; | ||
import reactConfig from './react.js'; | ||
import typescriptConfig from './typescript.js'; | ||
|
||
export default { | ||
configs: { | ||
base: baseConfig, | ||
typescript: typescriptConfig, | ||
react: reactConfig, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import baseConfig from './base.js'; | ||
|
||
import jsxA11y from 'eslint-plugin-jsx-a11y'; | ||
import react from 'eslint-plugin-react'; | ||
import reactHooks from 'eslint-plugin-react-hooks'; | ||
import reactRefresh from 'eslint-plugin-react-refresh'; | ||
|
||
export default [ | ||
...baseConfig, | ||
jsxA11y.flatConfigs.recommended, | ||
{ | ||
files: ['**/*.{js,jsx,ts,tsx}'], | ||
languageOptions: { | ||
parserOptions: { | ||
ecmaFeatures: { jsx: true }, | ||
}, | ||
}, | ||
settings: { | ||
react: { | ||
version: 'detect', | ||
}, | ||
}, | ||
plugins: { | ||
'react-hooks': reactHooks, | ||
react: react, | ||
}, | ||
rules: { | ||
...react.configs.flat.recommended.rules, | ||
...reactHooks.configs.recommended.rules, | ||
'react/react-in-jsx-scope': 'off', | ||
}, | ||
}, | ||
{ | ||
files: ['**/*.{jsx,tsx}'], | ||
plugins: { | ||
'react-refresh': reactRefresh, | ||
}, | ||
rules: { | ||
'react-refresh/only-export-components': [ | ||
'warn', | ||
{ allowConstantExport: true }, | ||
], | ||
}, | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import { expect, test } from '@jest/globals'; | ||
import { ESLint } from 'eslint'; | ||
import config from '../src/index'; | ||
|
||
test('react flavor should be linted correctly', async () => { | ||
const eslint = new ESLint({ | ||
overrideConfigFile: true, | ||
overrideConfig: [...config.configs.typescript, ...config.configs.react], | ||
fix: false, | ||
}); | ||
|
||
const results = await eslint.lintFiles(['tests/react']); | ||
|
||
expect(results).toBeDefined(); | ||
expect(results.length).toBe(3); | ||
|
||
expect(results.at(0).messages.length).toBe(5); | ||
expect(results.at(0).messages).toEqual( | ||
expect.arrayContaining([ | ||
expect.objectContaining({ | ||
ruleId: 'react-refresh/only-export-components', | ||
line: 1, | ||
column: 1, | ||
}), | ||
expect.objectContaining({ | ||
ruleId: 'react/display-name', | ||
line: 1, | ||
column: 16, | ||
}), | ||
expect.objectContaining({ | ||
ruleId: 'react/prop-types', | ||
line: 1, | ||
column: 19, | ||
}), | ||
expect.objectContaining({ | ||
ruleId: 'unicorn/no-anonymous-default-export', | ||
line: 1, | ||
column: 24, | ||
}), | ||
expect.objectContaining({ | ||
ruleId: 'sonarjs/jsx-no-useless-fragment', | ||
line: 2, | ||
column: 10, | ||
}), | ||
]) | ||
); | ||
|
||
expect(results.at(1).messages.length).toBe(2); | ||
expect(results.at(1).messages).toEqual( | ||
expect.arrayContaining([ | ||
expect.objectContaining({ | ||
ruleId: 'no-console', | ||
line: 9, | ||
column: 5, | ||
}), | ||
expect.objectContaining({ | ||
ruleId: 'react-hooks/exhaustive-deps', | ||
line: 10, | ||
column: 6, | ||
}), | ||
]) | ||
); | ||
|
||
expect(results.at(2).messages.length).toBe(2); | ||
expect(results.at(2).messages).toEqual( | ||
expect.arrayContaining([ | ||
expect.objectContaining({ | ||
ruleId: 'react-refresh/only-export-components', | ||
line: 1, | ||
column: 14, | ||
}), | ||
expect.objectContaining({ | ||
ruleId: 'sonarjs/no-empty-function', | ||
line: 1, | ||
column: 26, | ||
}), | ||
]) | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default ({ a }) => { | ||
return <>{a}</>; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import React, { useEffect } from 'react'; | ||
|
||
type Properties = { | ||
name: string; | ||
}; | ||
|
||
export default function Test({ name }: Properties) { | ||
useEffect(() => { | ||
console.log('Hello', name); | ||
}, []); | ||
|
||
return <div>Test</div>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export const foo = () => {}; | ||
export const Bar = () => <></>; |
Oops, something went wrong.