Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/kg-default-atoms/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build/
tsconfig.tsbuildinfo
47 changes: 19 additions & 28 deletions packages/kg-default-atoms/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,42 +1,33 @@
import {fixupPluginRules} from '@eslint/compat';
import {defineConfig} from 'eslint/config';
import eslint from '@eslint/js';
import ghostPlugin from 'eslint-plugin-ghost';
import globals from 'globals';
import tseslint from 'typescript-eslint';

const ghost = fixupPluginRules(ghostPlugin);

export default [
export default defineConfig([
{ignores: ['build/**']},
eslint.configs.recommended,
{
files: ['**/*.js'],
plugins: {ghost},
files: ['**/*.ts'],
extends: [
eslint.configs.recommended,
tseslint.configs.recommended
],
languageOptions: {
globals: globals.node
parserOptions: {ecmaVersion: 2022, sourceType: 'module'}
},
plugins: {ghost: ghostPlugin},
rules: {
...ghostPlugin.configs.node.rules,
// match ESLint 8 behavior for catch clause variables
'no-unused-vars': ['error', {caughtErrors: 'none'}],
// disable rules incompatible with ESLint 9 flat config
'ghost/filenames/match-exported-class': 'off',
'ghost/filenames/match-exported': 'off',
'ghost/filenames/match-regex': 'off'
...ghostPlugin.configs.ts.rules,
'@typescript-eslint/no-explicit-any': 'error'
}
},
{
files: ['test/**/*.js'],
plugins: {ghost},
languageOptions: {
globals: {
...globals.node,
...globals.mocha,
should: true,
sinon: true
}
},
files: ['test/**/*.ts'],
rules: {
...ghostPlugin.configs.test.rules
...ghostPlugin.configs['ts-test'].rules,
'ghost/mocha/no-global-tests': 'off',
'ghost/mocha/handle-done-callback': 'off',
'ghost/mocha/no-mocha-arrows': 'off',
'ghost/mocha/max-top-level-suites': 'off'
}
}
];
]);
1 change: 0 additions & 1 deletion packages/kg-default-atoms/index.js

This file was deleted.

3 changes: 0 additions & 3 deletions packages/kg-default-atoms/lib/atoms/index.js

This file was deleted.

7 changes: 0 additions & 7 deletions packages/kg-default-atoms/lib/atoms/soft-return.js

This file was deleted.

34 changes: 28 additions & 6 deletions packages/kg-default-atoms/package.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,50 @@
{
"name": "@tryghost/kg-default-atoms",
"version": "5.1.7",
"repository": "https://github.com/TryGhost/Koenig/tree/master/packages/kg-default-atoms",
"repository": "https://github.com/TryGhost/Koenig/tree/main/packages/kg-default-atoms",
"author": "Ghost Foundation",
"license": "MIT",
"main": "index.js",
"main": "build/cjs/index.js",
"module": "build/esm/index.js",
"types": "build/esm/index.d.ts",
"exports": {
".": {
"types": "./build/esm/index.d.ts",
"import": "./build/esm/index.js",
"require": "./build/cjs/index.js"
}
},
"scripts": {
"dev": "echo \"Implement me!\"",
"test": "NODE_ENV=testing c8 --all --reporter text --reporter cobertura mocha './test/**/*.test.js'",
"build": "tsc && tsc -p tsconfig.cjs.json && echo '{\"type\":\"module\"}' > build/esm/package.json",
"prepare": "tsc && tsc -p tsconfig.cjs.json && echo '{\"type\":\"module\"}' > build/esm/package.json",
"pretest": "tsc && tsc -p tsconfig.cjs.json && echo '{\"type\":\"module\"}' > build/esm/package.json && tsc -p tsconfig.test.json",
"test": "NODE_ENV=testing c8 --all --reporter text --reporter cobertura mocha --require tsx './test/**/*.test.ts'",
"lint": "eslint . --cache",
"posttest": "yarn lint"
},
"engines": {
"node": "^22.13.1 || ^24.0.0"
},
"files": [
"index.js",
"lib"
"build"
],
"publishConfig": {
"access": "public"
},
"devDependencies": {
"@eslint/js": "9.28.0",
"@types/mocha": "10.0.10",
"@types/node": "22.15.29",
"@types/should": "13.0.0",
"@types/sinon": "17.0.4",
"c8": "11.0.0",
"simple-dom": "1.4.0"
"mocha": "11.7.5",
"should": "13.2.3",
"simple-dom": "1.4.0",
"sinon": "21.0.1",
"tsx": "4.19.4",
"typescript": "5.8.3",
"typescript-eslint": "8.33.1"
}
}
3 changes: 3 additions & 0 deletions packages/kg-default-atoms/src/atoms/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import softReturn from './soft-return.js';

export const atoms = [softReturn];
17 changes: 17 additions & 0 deletions packages/kg-default-atoms/src/atoms/soft-return.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export interface AtomEnv {
dom: {
createElement(tag: string): unknown;
};
}

export interface AtomOpts {
env: AtomEnv;
}

export default {
name: 'soft-return',
type: 'dom',
render(opts: AtomOpts) {
return opts.env.dom.createElement('br');
}
};
1 change: 1 addition & 0 deletions packages/kg-default-atoms/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {atoms} from './atoms/index.js';
19 changes: 0 additions & 19 deletions packages/kg-default-atoms/test/atoms/soft-return.test.js

This file was deleted.

18 changes: 18 additions & 0 deletions packages/kg-default-atoms/test/atoms/soft-return.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import '../utils/index.js';
import atom from '../../src/atoms/soft-return.js';
import {Document as SimpleDomDocument, HTMLSerializer, voidMap} from 'simple-dom';
import type {SerializableNode} from '@simple-dom/interface';

const serializer = new HTMLSerializer(voidMap);

describe('Soft return atom', function () {
it('generates a `br` tag', function () {
const opts = {
env: {
dom: new SimpleDomDocument()
}
};

serializer.serialize(atom.render(opts) as SerializableNode).should.match('<br>');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

// Require overrides - these add globals for tests
require('./overrides');
import './overrides.js';

// Require assertions - adds custom should assertions
require('./assertions');
import './assertions.js';
10 changes: 0 additions & 10 deletions packages/kg-default-atoms/test/utils/overrides.js

This file was deleted.

15 changes: 15 additions & 0 deletions packages/kg-default-atoms/test/utils/overrides.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// This file is required before any test is run

// Taken from the should wiki, this is how to make should global
// Should is a global in our eslint test config
import should from 'should';
import sinon from 'sinon';

// @types/should is incomplete — noConflict and extend exist at runtime
const shouldModule = should as unknown as {noConflict(): typeof should; extend(): void};
Object.defineProperty(globalThis, 'should', {value: shouldModule.noConflict(), writable: true, configurable: true});
shouldModule.extend();

// Sinon is a simple case
// Sinon is a global in our eslint test config
Object.defineProperty(globalThis, 'sinon', {value: sinon, writable: true, configurable: true});
13 changes: 13 additions & 0 deletions packages/kg-default-atoms/tsconfig.cjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "NodeNext",
"moduleResolution": "NodeNext",
"outDir": "build/cjs",
"verbatimModuleSyntax": false,
"declaration": false,
"declarationMap": false,
"sourceMap": false,
"incremental": false
}
}
22 changes: 22 additions & 0 deletions packages/kg-default-atoms/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"target": "es2022",
"module": "ES2022",
"moduleResolution": "bundler",
"rootDir": "src",
"outDir": "build/esm",
"strict": true,
"declaration": true,
"declarationMap": true,
"sourceMap": true,
"incremental": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"skipLibCheck": true,
"resolveJsonModule": true,
"isolatedModules": true
},
"include": [
"src/**/*"
]
}
16 changes: 16 additions & 0 deletions packages/kg-default-atoms/tsconfig.test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"rootDir": ".",
"outDir": null,
"noEmit": true,
"declaration": false,
"declarationMap": false,
"sourceMap": false,
"incremental": false
},
"include": [
"src/**/*",
"test/**/*"
]
}
Loading