Skip to content

Commit

Permalink
test(eslint-config-bananass-react): add tests for react, `react-hoo…
Browse files Browse the repository at this point in the history
…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
lumirlumir authored Jan 19, 2025
1 parent 344cadf commit 5b74a4e
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/eslint-config-bananass-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
},
"scripts": {
"prepublishOnly": "npm run build",
"build": "cp ../../LICENSE.md ../../README.md ."
"build": "cp ../../LICENSE.md ../../README.md .",
"test": "node --test"
},
"peerDependencies": {
"eslint": "^9.0.0",
Expand Down
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);
});
});
});
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 packages/eslint-config-bananass-react/src/rules/react.test.js
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);
});
});
});

0 comments on commit 5b74a4e

Please sign in to comment.