Skip to content

Commit

Permalink
wip: back to just coding without a goal
Browse files Browse the repository at this point in the history
Throw stuff at the wall and keep what sticks.
  • Loading branch information
ifiokjr committed Mar 29, 2020
1 parent 972d4eb commit 9037427
Show file tree
Hide file tree
Showing 19 changed files with 462 additions and 311 deletions.
20 changes: 13 additions & 7 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ module.exports = {
'prettier/@typescript-eslint',
'prettier/react',
'plugin:jest-formatting/strict',
'plugin:unicorn/recommended',
],
plugins: [
'jest',
Expand Down Expand Up @@ -75,7 +76,10 @@ module.exports = {
rules: {
...graphqlRules,
eqeqeq: ['error', 'always', { null: 'ignore' }],
'prefer-exponentiation-operator': 'error',

'unicorn/filename-case': ['error', { case: 'kebabCase' }],

'default-case': 'warn',

'prefer-template': 'warn',
Expand All @@ -92,19 +96,19 @@ module.exports = {

'jest/no-focused-tests': 'error',
'jest/no-identical-title': 'error',
'jest/no-duplicate-hooks': 'warn',
'jest/no-if': 'warn',
'jest/no-test-prefixes': 'warn',
'jest/no-duplicate-hooks': 'error',
'jest/no-if': 'error',
'jest/no-test-prefixes': 'error',
'jest/prefer-spy-on': 'warn',
'jest/no-test-callback': 'warn',
'jest/no-test-callback': 'error',
'jest/no-large-snapshots': ['warn', { maxSize: 12 }],

'react/prop-types': 'off', // Because we're using TypeScript

'react-hooks/exhaustive-deps': 'error',
'react-hooks/rules-of-hooks': 'error',

'import/no-deprecated': 'error',
'import/no-deprecated': 'warning',
'import/first': 'error',
'import/no-duplicates': 'error',
'import/no-cycle': 'error',
Expand Down Expand Up @@ -141,7 +145,6 @@ module.exports = {

// ESLint rules (those without a '/' in) come after here

'no-nested-ternary': 'off', // Prettier makes nested ternaries more acceptable
'no-return-assign': ['error', 'except-parens'],
'@typescript-eslint/no-unused-expressions': [
'error',
Expand Down Expand Up @@ -223,7 +226,10 @@ module.exports = {
'@typescript-eslint/no-non-null-assertion': 'off', // Makes writing tests more convenient
'@typescript-eslint/no-use-before-define': 'off',
'react/display-name': 'off',
...Object.keys(tsProjectRules).reduce((acc, key) => ({ ...acc, [key]: 'off' }), {}),
...Object.keys(tsProjectRules).reduce(
(accumulator, key) => ({ ...accumulator, [key]: 'off' }),
{},
),
},
},
{
Expand Down
30 changes: 20 additions & 10 deletions @remirror/core-constants/src/core-constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ export enum ExtensionType {
*/
export enum Tag {
/**
* Describes a node that can be used as the last node of a document and
* by extension doesn't need to render a node after itself.
* Describes a node that can be used as the last node of a document and by
* extension doesn't need to render a node after itself.
*
* @remarks
*
Expand Down Expand Up @@ -233,22 +233,32 @@ export enum RemirrorIdentifier {
/**
* The string used to identify an instance of the remirror extension.
*/
Extension = '$$RemirrorExtension',
Extension = 'RemirrorExtension',

/**
* The string used to identify the constructor used to create extension instances.
* Identifies `PlainExtensionConstructor`s.
*/
ExtensionConstructor = '$$RemirrorExtensionConstructor',
PlainExtensionConstructor = 'RemirrorPlainExtensionConstructor',

/**
* Identifies `NodeExtensionConstructor`s.
*/
NodeExtensionConstructor = 'RemirrorNodeExtensionConstructor',

/**
* Identifies `MarkExtensionConstructor`s.
*/
MarkExtensionConstructor = 'RemirrorMarkExtensionConstructor',

/**
* The string used to identify an instance of the `ExtensionManager`
*/
ExtensionManager = '$$RemirrorExtensionManager',
ExtensionManager = 'RemirrorExtensionManager',

/**
* The preset type identifier.
*/
Preset = '$$RemirrorPreset',
Preset = 'RemirrorPreset',
}

/**
Expand All @@ -257,9 +267,9 @@ export enum RemirrorIdentifier {
*
* @remarks
*
* Higher priority extension (lower number) will take precedence when
* there's a class. For example if two extensions have the same name the higher
* priority extension is the one that will be loaded.
* Higher priority extension (lower number) will take precedence when there's a
* class. For example if two extensions have the same name the higher priority
* extension is the one that will be loaded.
*
* The lower the numeric value the higher the priority. The priority can also be
* passed a number but naming things in this `enum` should help provide some
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
BaseExtensionConfig,
Extension,
ExtensionManagerParams,
isEmptyArray,
NodeMatch,
ResolvedPos,
uniqueArray,
Expand All @@ -18,9 +19,9 @@ export const findSpecialNodeAfter = ($pos: ResolvedPos, tr: Transaction, matcher
}

const { parentOffset, parent } = $pos;
const docSize = tr.doc.nodeSize - 2;
const documentSize = tr.doc.nodeSize - 2;

if (parentOffset === parent.content.size && $pos.pos + 1 < docSize - 2) {
if (parentOffset === parent.content.size && $pos.pos + 1 < documentSize - 2) {
const { nodeAfter } = tr.doc.resolve($pos.pos + 1);
if (nodeAfter && nodeNameMatchesList(nodeAfter.firstChild, matchers)) {
return $pos.pos + 2;
Expand Down Expand Up @@ -55,10 +56,10 @@ export const findSpecialNodeBefore = (
return;
};

const createNodeCursorExtensionPlugin = (ctx: NodeCursorExtension, nodeNames: string[]) => {
const targets = uniqueArray([...nodeNames, ...ctx.options.targets]);
const createNodeCursorExtensionPlugin = (context: NodeCursorExtension, nodeNames: string[]) => {
const targets = uniqueArray([...nodeNames, ...context.options.targets]);
return new Plugin({
key: ctx.pluginKey,
key: context.pluginKey,

state: {
init: () => [],
Expand All @@ -85,12 +86,12 @@ const createNodeCursorExtensionPlugin = (ctx: NodeCursorExtension, nodeNames: st
props: {
decorations(state: EditorState) {
const { doc } = state;
const positions = getPluginState<number[]>(ctx.pluginKey, state);
const positions = getPluginState<number[]>(context.pluginKey, state);

if (positions?.length) {
if (!isEmptyArray(positions)) {
const decorations = positions.map((position) => {
const node = document.createElement('span');
node.appendChild(document.createTextNode(ZERO_WIDTH_SPACE_CHAR));
node.append(document.createTextNode(ZERO_WIDTH_SPACE_CHAR));
return Decoration.widget(position, node, {
raw: true,
side: -1,
Expand Down

0 comments on commit 9037427

Please sign in to comment.