mirror of
https://github.com/renovatebot/renovate.git
synced 2026-11-02 02:29:51 +00:00
58771bb183
* refactor(oxlint): enable func-style Enable the built-in func-style rule as ["warn", "declaration"] so that named functions are written as function declarations instead of arrow or function expressions assigned to variables, matching the convention in docs/development/best-practices.md (Functions section). Inline arrow callbacks are unaffected; prefer-arrow-callback continues to cover the callback direction. Severity is "warn" instead of "error" as a fallback: a repo-wide run found 196 pre-existing violations (70 in spec files, 126 in production code), exceeding the 80-violation fix threshold for this change, so no violations were fixed here. Follow-up work can convert the offenders (largest clusters: lib/modules/versioning/ruby, lib/util/cache/package, lib/modules/versioning/maven, lib/modules/versioning/gradle) and then raise the rule to "error". Note oxlint 1.72 also supports an allowTypeAnnotation option if typed consts should remain arrows. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * ci(linter): enforce func-style at error * refactor(func-style): convert const-arrow functions to declarations in with-cache spec and ruby versioning * refactor(func-style): convert const-arrow functions to declarations in maven/gradle modules * refactor(func-style): convert const-arrow functions to declarations in remaining versioning modules * refactor(func-style): convert const-arrow functions to declarations in platform modules Discriminated-union closures (ensureCommentRemoval byTopic/byContent helpers in github, gitlab, bitbucket, bitbucket-server) needed the narrowed field passed explicitly as a parameter, since function declarations are hoisted and lose the outer if-narrowing that inline arrow-function closures previously relied on. * refactor(func-style): convert const-arrow functions to declarations across util/manager/datasource modules One case (logger/renovate-logger.ts logOnceFn) is kept as an arrow function with a documented oxlint-disable: it is stored on this.logger.once[level] and relies on lexically-bound this, which a hoisted function declaration would not preserve. * refactor(func-style): convert remaining const-arrow test helpers to declarations get-updated.spec.ts: hoisted expectPipCompilePackageAndLockFile to module scope (it only closes over the module-level pipCompile mock) and added a documented oxlint-disable for vitest/expect-expect on its caller test, since oxlint's expect-expect check does not trace assertions through an externally-defined helper function. --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
99 lines
3.0 KiB
TypeScript
99 lines
3.0 KiB
TypeScript
import { fromCodepointToUnicode, fromHexcodeToCodepoint } from 'emojibase';
|
|
import { emojify, setEmojiConfig, stripEmojis, unemojify } from './emoji.ts';
|
|
|
|
describe('util/emoji', () => {
|
|
beforeEach(() => {
|
|
setEmojiConfig({ unicodeEmoji: true });
|
|
});
|
|
|
|
describe('emojify', () => {
|
|
it('encodes known shortcodes', () => {
|
|
expect(emojify('Let it :bee:')).toBe('Let it 🐝');
|
|
});
|
|
|
|
it('encodes aliases', () => {
|
|
const bee = emojify(':bee:');
|
|
const honeyBee = emojify(':honeybee:');
|
|
expect(bee).toEqual(honeyBee);
|
|
});
|
|
|
|
it('omits unknown shortcodes', () => {
|
|
expect(emojify(':foo: :bar: :bee:')).toBe(':foo: :bar: 🐝');
|
|
});
|
|
|
|
it('convert warning shortcode to emoji', () => {
|
|
const warning = emojify(':warning:');
|
|
expect(warning).toBe('⚠️');
|
|
});
|
|
|
|
it('does not encode when config option is disabled', () => {
|
|
setEmojiConfig({ unicodeEmoji: false });
|
|
expect(emojify('Let it :bee:')).toBe('Let it :bee:');
|
|
});
|
|
});
|
|
|
|
describe('unemojify', () => {
|
|
it('strips emojis when the config has been set accordingly', () => {
|
|
const emoji = '🚀💎';
|
|
const otherText = 'regular text';
|
|
const text = `${emoji} ${otherText}`;
|
|
setEmojiConfig({ unicodeEmoji: false });
|
|
const result = unemojify(text);
|
|
expect(result).not.toContain(emoji);
|
|
});
|
|
|
|
it('does not strip emojis when the config demands it', () => {
|
|
const emoji = '🚀💎';
|
|
const otherText = 'regular text';
|
|
const text = `${emoji} ${otherText}`;
|
|
setEmojiConfig({ unicodeEmoji: true });
|
|
const result = unemojify(text);
|
|
expect(result).toEqual(text);
|
|
});
|
|
|
|
it('converts warning emoji to shortcode', () => {
|
|
setEmojiConfig({ unicodeEmoji: false });
|
|
const emoji = '⚠️';
|
|
const result = unemojify(emoji);
|
|
expect(result).toBe(':warning:');
|
|
});
|
|
});
|
|
|
|
describe('problematic characters', () => {
|
|
it.each(['🚀', '💎', '🧹', '📦', '⚠️'])(
|
|
'converts %s forth and back',
|
|
(char) => {
|
|
setEmojiConfig({ unicodeEmoji: false });
|
|
const codified = unemojify(char);
|
|
expect(codified).not.toEqual(char);
|
|
|
|
setEmojiConfig({ unicodeEmoji: true });
|
|
const emojified = emojify(codified);
|
|
expect(emojified).toEqual(char);
|
|
},
|
|
);
|
|
});
|
|
|
|
describe('stripEmojis', () => {
|
|
function makeEmoji(hexCode: string): string {
|
|
return fromCodepointToUnicode(fromHexcodeToCodepoint(hexCode));
|
|
}
|
|
|
|
it('is independent of config option', () => {
|
|
const x: string = makeEmoji('26A0-FE0F');
|
|
const y: string = makeEmoji('26A0');
|
|
|
|
setEmojiConfig({ unicodeEmoji: true });
|
|
expect(stripEmojis(`foo ${x} bar`)).toBe(`foo ${y} bar`);
|
|
|
|
setEmojiConfig({ unicodeEmoji: false });
|
|
expect(stripEmojis(`foo ${x} bar`)).toBe(`foo ${y} bar`);
|
|
});
|
|
|
|
it('does not throw on standalone modifiers', () => {
|
|
// This is based on a string from an actual PR description.
|
|
expect(stripEmojis("foo '🏻' bar")).toBe("foo '' bar");
|
|
});
|
|
});
|
|
});
|