mirror of
https://github.com/hanzoai/eslint.git
synced 2026-10-30 19:38:10 +00:00
* refactor: Remove eslintrc from flat config functionality * Fix knip error * Fix knip again * Update lib/shared/relative-module-resolver.js Co-authored-by: Francesco Trotta <[email protected]> * Remove unused file --------- Co-authored-by: Francesco Trotta <[email protected]>
67 lines
1.8 KiB
JavaScript
67 lines
1.8 KiB
JavaScript
/**
|
|
* @fileoverview Tests for naming util
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
//------------------------------------------------------------------------------
|
|
// Requirements
|
|
//------------------------------------------------------------------------------
|
|
|
|
const { assert } = require("chai");
|
|
const naming = require("../../../lib/shared/naming.js");
|
|
|
|
//------------------------------------------------------------------------------
|
|
// Tests
|
|
//------------------------------------------------------------------------------
|
|
|
|
describe("naming", () => {
|
|
describe("normalizePackageName()", () => {
|
|
[
|
|
["foo", "eslint-config-foo"],
|
|
["eslint-config-foo", "eslint-config-foo"],
|
|
["@z/foo", "@z/eslint-config-foo"],
|
|
["@z\\foo", "@z/eslint-config-foo"],
|
|
["@z\\foo\\bar.js", "@z/eslint-config-foo/bar.js"],
|
|
["@z/eslint-config", "@z/eslint-config"],
|
|
["@z/eslint-config-foo", "@z/eslint-config-foo"],
|
|
].forEach(([input, expected]) => {
|
|
it(`should return ${expected} when passed ${input}`, () => {
|
|
const result = naming.normalizePackageName(
|
|
input,
|
|
"eslint-config",
|
|
);
|
|
|
|
assert.strictEqual(result, expected);
|
|
});
|
|
});
|
|
});
|
|
|
|
describe("getShorthandName()", () => {
|
|
[
|
|
["foo", "foo"],
|
|
["eslint-config-foo", "foo"],
|
|
["@z", "@z"],
|
|
["@z/eslint-config", "@z"],
|
|
["@z/foo", "@z/foo"],
|
|
["@z/eslint-config-foo", "@z/foo"],
|
|
].forEach(([input, expected]) => {
|
|
it(`should return ${expected} when passed ${input}`, () => {
|
|
const result = naming.getShorthandName(input, "eslint-config");
|
|
|
|
assert.strictEqual(result, expected);
|
|
});
|
|
});
|
|
});
|
|
|
|
describe("getNamespaceFromTerm()", () => {
|
|
it("should remove namespace when passed with namespace", () => {
|
|
const namespace = naming.getNamespaceFromTerm(
|
|
"@namespace/eslint-plugin-test",
|
|
);
|
|
|
|
assert.strictEqual(namespace, "@namespace/");
|
|
});
|
|
});
|
|
});
|