-
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.
test(eslint-config-bananass-react): add tests for
react
, `react-hoo…
…ks`, and `react-compiler` rules (#90) This pull request includes several changes to the `eslint-config-bananass-react` package, focusing on adding tests for various rule files and updating the build script. The most important changes include adding new test files for `react`, `react-compiler`, and `react-hooks` rules, and updating the `package.json` to include a test script. ### Added tests for rule files: * [`packages/eslint-config-bananass-react/src/rules/react-compiler.test.js`](diffhunk://#diff-955e041e8da3e21eaa98d58513c1ddfb89d5d8eb45d3802d949d2086662321faR1-R30): Added a test file to ensure all key values in `react-compiler.js` start with the prefix `react-compiler/`. * [`packages/eslint-config-bananass-react/src/rules/react-hooks.test.js`](diffhunk://#diff-a3072c88c74ff7641603a55dd0822a496b364fe8f41dfe517f6de41d01389cfcR1-R30): Added a test file to ensure all key values in `react-hooks.js` start with the prefix `react-hooks/`. * [`packages/eslint-config-bananass-react/src/rules/react.test.js`](diffhunk://#diff-52eea9b3a0687b5c61ac906828bddf336f237a2f9da292f1064a95bc52da36b3R1-R30): Added a test file to ensure all key values in `react.js` start with the prefix `react/`. ### Build script update: * [`packages/eslint-config-bananass-react/package.json`](diffhunk://#diff-263baf2bd4636e9041e07fa4d170bdde1545c6a48947ab5ff1f511e289d53356L39-R40): Updated the build script to include a test script using `node --test`.
- Loading branch information
1 parent
344cadf
commit 5b74a4e
Showing
4 changed files
with
92 additions
and
1 deletion.
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
30 changes: 30 additions & 0 deletions
30
packages/eslint-config-bananass-react/src/rules/react-compiler.test.js
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,30 @@ | ||
/** | ||
* @fileoverview Test for `react-compiler.js`. | ||
*/ | ||
|
||
// -------------------------------------------------------------------------------- | ||
// Require | ||
// -------------------------------------------------------------------------------- | ||
|
||
const { strictEqual } = require('node:assert'); | ||
const { describe, it } = require('node:test'); | ||
|
||
const reactCompiler = require('./react-compiler'); | ||
|
||
// -------------------------------------------------------------------------------- | ||
// Declaration | ||
// -------------------------------------------------------------------------------- | ||
|
||
const prefix = 'react-compiler/'; | ||
|
||
// -------------------------------------------------------------------------------- | ||
// Test | ||
// -------------------------------------------------------------------------------- | ||
|
||
describe(`All key values must start with \`${prefix}\`.`, () => { | ||
it('react-compiler.js', () => { | ||
Object.keys(reactCompiler).forEach(key => { | ||
strictEqual(key.startsWith(prefix), true); | ||
}); | ||
}); | ||
}); |
30 changes: 30 additions & 0 deletions
30
packages/eslint-config-bananass-react/src/rules/react-hooks.test.js
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,30 @@ | ||
/** | ||
* @fileoverview Test for `react-hooks.js`. | ||
*/ | ||
|
||
// -------------------------------------------------------------------------------- | ||
// Require | ||
// -------------------------------------------------------------------------------- | ||
|
||
const { strictEqual } = require('node:assert'); | ||
const { describe, it } = require('node:test'); | ||
|
||
const reactHooks = require('./react-hooks'); | ||
|
||
// -------------------------------------------------------------------------------- | ||
// Declaration | ||
// -------------------------------------------------------------------------------- | ||
|
||
const prefix = 'react-hooks/'; | ||
|
||
// -------------------------------------------------------------------------------- | ||
// Test | ||
// -------------------------------------------------------------------------------- | ||
|
||
describe(`All key values must start with \`${prefix}\`.`, () => { | ||
it('react-hooks.js', () => { | ||
Object.keys(reactHooks).forEach(key => { | ||
strictEqual(key.startsWith(prefix), true); | ||
}); | ||
}); | ||
}); |
30 changes: 30 additions & 0 deletions
30
packages/eslint-config-bananass-react/src/rules/react.test.js
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,30 @@ | ||
/** | ||
* @fileoverview Test for `react.js`. | ||
*/ | ||
|
||
// -------------------------------------------------------------------------------- | ||
// Require | ||
// -------------------------------------------------------------------------------- | ||
|
||
const { strictEqual } = require('node:assert'); | ||
const { describe, it } = require('node:test'); | ||
|
||
const react = require('./react'); | ||
|
||
// -------------------------------------------------------------------------------- | ||
// Declaration | ||
// -------------------------------------------------------------------------------- | ||
|
||
const prefix = 'react/'; | ||
|
||
// -------------------------------------------------------------------------------- | ||
// Test | ||
// -------------------------------------------------------------------------------- | ||
|
||
describe(`All key values must start with \`${prefix}\`.`, () => { | ||
it('react.js', () => { | ||
Object.keys(react).forEach(key => { | ||
strictEqual(key.startsWith(prefix), true); | ||
}); | ||
}); | ||
}); |