Skip to content

Commit

Permalink
feat(eslint-config-bananass): add tests for import rules and update b…
Browse files Browse the repository at this point in the history
…uild script
  • Loading branch information
lumirlumir committed Jan 12, 2025
1 parent 2aeb82e commit 7b3ac33
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/eslint-config-bananass/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,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
51 changes: 51 additions & 0 deletions packages/eslint-config-bananass/src/rules/import.test.js
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 `import/`.', () => {
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);
});
});
});

0 comments on commit 7b3ac33

Please sign in to comment.