-
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.
feat(eslint-config-bananass): add tests for rules (#67)
This pull request introduces new test files and updates the build script in the `packages/eslint-config-bananass` package. The most important changes include adding tests for various rule files and updating the `package.json` to include a test script. ### Tests added for rule files: * [`packages/eslint-config-bananass/src/rules/eslint.test.js`](diffhunk://#diff-75dfe640494934eadf36b6d985a90a3e7de4fbc4da55fd422d802e56f6d7519aR1-R44): Added tests for `eslint-layout-formatting.js`, `eslint-possible-problems.js`, and `eslint-suggestions.js` to ensure all key values do not include the prefix `/`. * [`packages/eslint-config-bananass/src/rules/import.test.js`](diffhunk://#diff-d9bb1e9956c01e11d0b97a58cbb82ddeddb8f93cfb33197200fde583f374b1fcR1-R51): Added tests for `import-helpful-warnings.js`, `import-module-systems.js`, `import-static-analysis.js`, and `import-style-guide.js` to ensure all key values start with the prefix `import/`. * [`packages/eslint-config-bananass/src/rules/node.test.js`](diffhunk://#diff-549b1b007284f29d5d8ac701a47cdbe4cf71921877998ca97fa1e6630f30700dR1-R30): Added tests for `node.js` to ensure all key values start with the prefix `n/`. * [`packages/eslint-config-bananass/src/rules/stylistic-js.test.js`](diffhunk://#diff-6473b3d0e0f021ddcb34858d267d2b8c21dc2401f1c2f1593d08b8a0f0f92b28R1-R30): Added tests for `stylistic-js.js` to ensure all key values start with the prefix `@stylistic/js/`. ### Build script update: * [`packages/eslint-config-bananass/package.json`](diffhunk://#diff-e820b85e94fd5b26012547982c44a557398b5c3dc850ac0c4094d184dfd5bcbcL36-R37): Updated the build script to include a test script that runs with `node --test`.
- Loading branch information
1 parent
ff8bb99
commit f4d3e70
Showing
5 changed files
with
157 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
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,44 @@ | ||
/** | ||
* @fileoverview Test for `eslint-layout-formatting.js`, `eslint-possible-problems.js`, `eslint-suggestions.js`. | ||
*/ | ||
|
||
// -------------------------------------------------------------------------------- | ||
// Require | ||
// -------------------------------------------------------------------------------- | ||
|
||
const { strictEqual } = require('node:assert'); | ||
const { describe, it } = require('node:test'); | ||
|
||
const eslintLayoutFormatting = require('./eslint-layout-formatting'); | ||
const eslintPossibleProblems = require('./eslint-possible-problems'); | ||
const eslintSuggestions = require('./eslint-suggestions'); | ||
|
||
// -------------------------------------------------------------------------------- | ||
// Declaration | ||
// -------------------------------------------------------------------------------- | ||
|
||
const prefix = '/'; | ||
|
||
// -------------------------------------------------------------------------------- | ||
// Test | ||
// -------------------------------------------------------------------------------- | ||
|
||
describe(`All key values must not include \`${prefix}\`.`, () => { | ||
it('eslint-layout-formatting.js', () => { | ||
Object.keys(eslintLayoutFormatting).forEach(key => { | ||
strictEqual(key.includes(prefix), false); | ||
}); | ||
}); | ||
|
||
it('eslint-possible-problems.js', () => { | ||
Object.keys(eslintPossibleProblems).forEach(key => { | ||
strictEqual(key.includes(prefix), false); | ||
}); | ||
}); | ||
|
||
it('eslint-suggestions.js', () => { | ||
Object.keys(eslintSuggestions).forEach(key => { | ||
strictEqual(key.includes(prefix), false); | ||
}); | ||
}); | ||
}); |
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,51 @@ | ||
/** | ||
* @fileoverview Test for `import-helpful-warnings.js`, `import-module-systems.js`, `import-static-analysis.js`, and `import-style-guide.js`. | ||
*/ | ||
|
||
// -------------------------------------------------------------------------------- | ||
// Require | ||
// -------------------------------------------------------------------------------- | ||
|
||
const { strictEqual } = require('node:assert'); | ||
const { describe, it } = require('node:test'); | ||
|
||
const importHelpfulWarnings = require('./import-helpful-warnings'); | ||
const importModuleSystems = require('./import-module-systems'); | ||
const importStaticAnalysis = require('./import-static-analysis'); | ||
const importStyleGuide = require('./import-style-guide'); | ||
|
||
// -------------------------------------------------------------------------------- | ||
// Declaration | ||
// -------------------------------------------------------------------------------- | ||
|
||
const prefix = 'import/'; | ||
|
||
// -------------------------------------------------------------------------------- | ||
// Test | ||
// -------------------------------------------------------------------------------- | ||
|
||
describe(`All key values must start with \`${prefix}\`.`, () => { | ||
it('import-helpful-warnings.js', () => { | ||
Object.keys(importHelpfulWarnings).forEach(key => { | ||
strictEqual(key.startsWith(prefix), true); | ||
}); | ||
}); | ||
|
||
it('import-module-systems.js', () => { | ||
Object.keys(importModuleSystems).forEach(key => { | ||
strictEqual(key.startsWith(prefix), true); | ||
}); | ||
}); | ||
|
||
it('import-static-analysis.js', () => { | ||
Object.keys(importStaticAnalysis).forEach(key => { | ||
strictEqual(key.startsWith(prefix), true); | ||
}); | ||
}); | ||
|
||
it('import-style-guide.js', () => { | ||
Object.keys(importStyleGuide).forEach(key => { | ||
strictEqual(key.startsWith(prefix), 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,30 @@ | ||
/** | ||
* @fileoverview Test for `node.js`. | ||
*/ | ||
|
||
// -------------------------------------------------------------------------------- | ||
// Require | ||
// -------------------------------------------------------------------------------- | ||
|
||
const { strictEqual } = require('node:assert'); | ||
const { describe, it } = require('node:test'); | ||
|
||
const node = require('./node'); | ||
|
||
// -------------------------------------------------------------------------------- | ||
// Declaration | ||
// -------------------------------------------------------------------------------- | ||
|
||
const prefix = 'n/'; | ||
|
||
// -------------------------------------------------------------------------------- | ||
// Test | ||
// -------------------------------------------------------------------------------- | ||
|
||
describe(`All key values must start with \`${prefix}\`.`, () => { | ||
it('node.js', () => { | ||
Object.keys(node).forEach(key => { | ||
strictEqual(key.startsWith(prefix), true); | ||
}); | ||
}); | ||
}); |
30 changes: 30 additions & 0 deletions
30
packages/eslint-config-bananass/src/rules/stylistic-js.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 `stylistic-js.js`. | ||
*/ | ||
|
||
// -------------------------------------------------------------------------------- | ||
// Require | ||
// -------------------------------------------------------------------------------- | ||
|
||
const { strictEqual } = require('node:assert'); | ||
const { describe, it } = require('node:test'); | ||
|
||
const stylisticJs = require('./stylistic-js'); | ||
|
||
// -------------------------------------------------------------------------------- | ||
// Declaration | ||
// -------------------------------------------------------------------------------- | ||
|
||
const prefix = '@stylistic/js/'; | ||
|
||
// -------------------------------------------------------------------------------- | ||
// Test | ||
// -------------------------------------------------------------------------------- | ||
|
||
describe(`All key values must start with \`${prefix}\`.`, () => { | ||
it('stylistic-js.js', () => { | ||
Object.keys(stylisticJs).forEach(key => { | ||
strictEqual(key.startsWith(prefix), true); | ||
}); | ||
}); | ||
}); |