Skip to content

Commit

Permalink
chore(lint): eslint parsing error tsconfig (#2048)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoSven committed Jun 27, 2023
1 parent 6da3702 commit a445bb5
Show file tree
Hide file tree
Showing 143 changed files with 3,344 additions and 8,190 deletions.
212 changes: 113 additions & 99 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,103 @@
/** @type {import('eslint').Linter.Config} */
const baseRules = {
'prefer-const': ['error', { destructuring: 'all' }],

'unicorn/better-regex': 'error',
'unicorn/catch-error-name': 'error',
'unicorn/consistent-destructuring': 'error',
'unicorn/error-message': 'error',
'unicorn/escape-case': 'error',
'unicorn/expiring-todo-comments': 'off',
'unicorn/explicit-length-check': 'error',
'unicorn/filename-case': ['error', { case: 'kebabCase' }],
'unicorn/import-style': 'error',
'unicorn/new-for-builtins': 'error',
'unicorn/no-abusive-eslint-disable': 'error',
'unicorn/no-array-reduce': 'error',
'unicorn/no-console-spaces': 'error',
'unicorn/no-for-loop': 'error',
'unicorn/no-hex-escape': 'error',
'unicorn/no-instanceof-array': 'error',
'unicorn/no-lonely-if': 'error',
'unicorn/no-new-array': 'error',
'unicorn/no-new-buffer': 'error',
'unicorn/no-process-exit': 'error',
'unicorn/no-unreadable-array-destructuring': 'error',
'unicorn/no-useless-undefined': 'error',
'unicorn/no-zero-fractions': 'error',
'unicorn/number-literal-case': 'error',
'unicorn/numeric-separators-style': 'error',
'unicorn/prefer-add-event-listener': 'error',
'unicorn/prefer-array-find': 'error',
'unicorn/prefer-array-flat-map': 'error',
'unicorn/prefer-array-index-of': 'error',
'unicorn/prefer-array-some': 'error',
'unicorn/prefer-date-now': 'error',
'unicorn/prefer-default-parameters': 'error',
'unicorn/prefer-dom-node-append': 'error',
'unicorn/prefer-dom-node-remove': 'error',
'unicorn/prefer-dom-node-text-content': 'error',
'unicorn/prefer-includes': 'error',
'unicorn/prefer-keyboard-event-key': 'error',
'unicorn/prefer-math-trunc': 'error',
'unicorn/prefer-modern-dom-apis': 'error',
'unicorn/prefer-negative-index': 'error',
'unicorn/prefer-number-properties': 'error',
'unicorn/prefer-optional-catch-binding': 'error',
'unicorn/prefer-query-selector': 'error',
'unicorn/prefer-reflect-apply': 'error',
'unicorn/prefer-regexp-test': 'error',
'unicorn/prefer-set-has': 'error',
'unicorn/prefer-spread': 'error',
'unicorn/prefer-string-slice': 'error',
'unicorn/prefer-string-starts-ends-with': 'error',
'unicorn/prefer-string-trim-start-end': 'error',
'unicorn/prefer-ternary': 'error',
'unicorn/prefer-type-error': 'error',
'unicorn/throw-new-error': 'error',
'unicorn/no-array-push-push': 'error',

'unicorn/no-keyword-prefix': 'off',
'no-nested-ternary': 'off',
'unicorn/no-nested-ternary': 'off',
'unicorn/no-unsafe-regex': 'off',
'unicorn/no-unused-properties': 'off',
'unicorn/string-content': 'off',
'unicorn/custom-error-definition': 'off',
'unicorn/empty-brace-spaces': 'off',
};

const importRules = {
'sort-imports': 'off',

// Use nice import and export rules
'simple-import-sort/exports': ['warn'], // TODO switch on after release
'simple-import-sort/imports': [
'warn',
{
groups: [
// Side effect imports.
['^\\u0000'],

// Packages that are not scoped to `remirror`
// Things that start with a letter (or digit or underscore), or `@` followed by a letter.
['^(?!@remirror)@?\\w', '^@remirror'],

// Scoped packages
// [],

// Absolute imports and other imports such as Vue-style `@/foo`.
// Anything that does not start with a dot.
['^[^.]'],

// Relative imports.
// Anything that starts with a dot.
['^\\.'],
],
},
],
};

let config = {
parser: '@typescript-eslint/parser',
ignorePatterns: ['*.d.ts'],
Expand Down Expand Up @@ -35,6 +134,8 @@ let config = {
ecmaFeatures: {
jsx: true,
},
project: 'tsconfig.eslint.json',
tsconfigRootDir: __dirname,
},
settings: {
react: {
Expand All @@ -48,72 +149,8 @@ let config = {
es6: true,
},
rules: {
'prefer-const': ['error', { destructuring: 'all' }],

'unicorn/better-regex': 'error',
'unicorn/catch-error-name': 'error',
'unicorn/consistent-destructuring': 'error',
'unicorn/error-message': 'error',
'unicorn/escape-case': 'error',
'unicorn/expiring-todo-comments': 'off',
'unicorn/explicit-length-check': 'error',
'unicorn/filename-case': ['error', { case: 'kebabCase' }],
'unicorn/import-style': 'error',
'unicorn/new-for-builtins': 'error',
'unicorn/no-abusive-eslint-disable': 'error',
'unicorn/no-array-reduce': 'error',
'unicorn/no-console-spaces': 'error',
'unicorn/no-for-loop': 'error',
'unicorn/no-hex-escape': 'error',
'unicorn/no-instanceof-array': 'error',
'unicorn/no-lonely-if': 'error',
'unicorn/no-new-array': 'error',
'unicorn/no-new-buffer': 'error',
'unicorn/no-process-exit': 'error',
'unicorn/no-unreadable-array-destructuring': 'error',
'unicorn/no-useless-undefined': 'error',
'unicorn/no-zero-fractions': 'error',
'unicorn/number-literal-case': 'error',
'unicorn/numeric-separators-style': 'error',
'unicorn/prefer-add-event-listener': 'error',
'unicorn/prefer-array-find': 'error',
'unicorn/prefer-array-flat-map': 'error',
'unicorn/prefer-array-index-of': 'error',
'unicorn/prefer-array-some': 'error',
'unicorn/prefer-date-now': 'error',
'unicorn/prefer-default-parameters': 'error',
'unicorn/prefer-dom-node-append': 'error',
'unicorn/prefer-dom-node-remove': 'error',
'unicorn/prefer-dom-node-text-content': 'error',
'unicorn/prefer-includes': 'error',
'unicorn/prefer-keyboard-event-key': 'error',
'unicorn/prefer-math-trunc': 'error',
'unicorn/prefer-modern-dom-apis': 'error',
'unicorn/prefer-negative-index': 'error',
'unicorn/prefer-number-properties': 'error',
'unicorn/prefer-optional-catch-binding': 'error',
'unicorn/prefer-query-selector': 'error',
'unicorn/prefer-reflect-apply': 'error',
'unicorn/prefer-regexp-test': 'error',
'unicorn/prefer-set-has': 'error',
'unicorn/prefer-spread': 'error',
'unicorn/prefer-string-slice': 'error',
'unicorn/prefer-string-starts-ends-with': 'error',
'unicorn/prefer-string-trim-start-end': 'error',
'unicorn/prefer-ternary': 'error',
'unicorn/prefer-type-error': 'error',
'unicorn/throw-new-error': 'error',
'unicorn/no-array-push-push': 'error',

'unicorn/no-keyword-prefix': 'off',
'no-nested-ternary': 'off',
'unicorn/no-nested-ternary': 'off',
'unicorn/no-unsafe-regex': 'off',
'unicorn/no-unused-properties': 'off',
'unicorn/string-content': 'off',
'unicorn/custom-error-definition': 'off',
'unicorn/empty-brace-spaces': 'off',

...baseRules,
...importRules,
'jest/no-test-return-statement': 'off',
'jest/prefer-strict-equal': 'off',
'jest/no-export': 'off',
Expand All @@ -129,35 +166,6 @@ let config = {
{ toBeTruthy: 'Avoid `toBeTruthy`', toBeFalsy: 'Avoid `toBeFalsy`' },
],

'sort-imports': 'off',

// Use nice import and export rules
'simple-import-sort/exports': ['warn'], // TODO switch on after release
'simple-import-sort/imports': [
'warn',
{
groups: [
// Side effect imports.
['^\\u0000'],

// Packages that are not scoped to `remirror`
// Things that start with a letter (or digit or underscore), or `@` followed by a letter.
['^(?!@remirror)@?\\w', '^@remirror'],

// Scoped packages
// [],

// Absolute imports and other imports such as Vue-style `@/foo`.
// Anything that does not start with a dot.
['^[^.]'],

// Relative imports.
// Anything that starts with a dot.
['^\\.'],
],
},
],

'@typescript-eslint/no-unused-expressions': [
'error',
{ allowTernary: true, allowShortCircuit: true },
Expand Down Expand Up @@ -495,25 +503,31 @@ if (process.env.FULL_ESLINT_CHECK) {
...config.overrides,
],
};
} else {
config.plugins = [...config.plugins, 'markdown'];
} else if (process.env.MD_ESLINT_CHECK) {
config = {
...config,
// Apply the markdown plugin
plugins: [...config.plugins, 'markdown'],

parserOptions: {
ecmaVersion: 2021,
sourceType: 'module',
ecmaFeatures: {
jsx: true,
},
},

// Only apply markdown rules when not in TypeScript mode, since they are
// currently incompatible.
overrides: [
...config.overrides,

{ files: ['*.mdx', '*.md'], processor: 'markdown/markdown' },
{
// Lint code blocks in markdown
files: ['**/*.{md,mdx}/*.{ts,tsx,js}'],

// Set up rules to be excluded in the markdown blocks.
rules: {
...importRules,
'simple-import-sort/exports': 'warn',
'simple-import-sort/imports': 'warn',
'unicorn/filename-case': 'off',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"lint": "run-s lint:*",
"lint:css": "tsx support/scripts/src/check-styles",
"lint:es": "cross-env FULL_ESLINT_CHECK=true eslint -f unix --ext=.tsx,.ts,.js .",
"lint:md": "eslint -f unix --ignore-pattern='*.js' --ignore-pattern='*.ts' --ignore-pattern='*.tsx' .",
"lint:md": "cross-env MD_ESLINT_CHECK=true eslint -f unix --ignore-pattern='*.js' --ignore-pattern='*.ts' --ignore-pattern='*.tsx' .",
"lint:prettier": "pnpm run run:prettier --check",
"lint:repo": "manypkg check",
"mutate:pr": "tsx support/scripts/src/publish-pr",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,10 @@ test('supports hooks state', () => {
value: string;
setValue: (value: string) => void;
}
const [OuterProvider, useOuter] = createContextState<OuterContext>(({ set }) => {
return {
value: 'initial',
setValue: (value) => set({ value }),
};
});
const [OuterProvider, useOuter] = createContextState<OuterContext>(({ set }) => ({
value: 'initial',
setValue: (value) => set({ value }),
}));

const [CountProvider, useCount] = createContextState<Context, Props, State>(
({ state, set, props, previousContext }) => ({
Expand Down
16 changes: 8 additions & 8 deletions packages/create-context-state/src/create-context-state.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,15 @@ export function createContextState<
const setContextRef = useRef<Dispatch<React.SetStateAction<Context>>>();
const state = hook?.(props) as State;

const [context, setContext] = useState(() => {
return creator({
const [context, setContext] = useState(() =>
creator({
get: createGet(contextRef),
set: createSet(setContextRef),
previousContext: undefined,
props,
state,
});
});
}),
);

const dependencies = [...Object.values(props), state];

Expand All @@ -104,15 +104,15 @@ export function createContextState<
return;
}

setContext((previousContext) => {
return creator({
setContext((previousContext) =>
creator({
get: createGet(contextRef),
set: createSet(setContextRef),
previousContext,
props,
state,
});
});
}),
);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, dependencies);

Expand Down
20 changes: 5 additions & 15 deletions packages/jest-prosemirror/src/jest-prosemirror-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ const atomInline: NodeSpec = {
tag: 'span[data-node-type="atomInline"]',
},
],
toDOM: () => {
return ['span', { 'data-node-type': 'atomInline' }];
},
toDOM: () => ['span', { 'data-node-type': 'atomInline' }],
};

const atomBlock: NodeSpec = {
Expand All @@ -61,9 +59,7 @@ const atomBlock: NodeSpec = {
tag: 'div[data-node-type="atomBlock"]',
},
],
toDOM: () => {
return ['div', { 'data-node-type': 'atomBlock' }];
},
toDOM: () => ['div', { 'data-node-type': 'atomBlock' }],
};

const atomContainer: NodeSpec = {
Expand All @@ -75,9 +71,7 @@ const atomContainer: NodeSpec = {
tag: 'div[data-node-type="atomBlockContainer"]',
},
],
toDOM: () => {
return ['div', { 'data-node-type': 'atomBlockContainer' }];
},
toDOM: () => ['div', { 'data-node-type': 'atomBlockContainer' }],
};

const containerWithRestrictedContent: NodeSpec = {
Expand All @@ -89,9 +83,7 @@ const containerWithRestrictedContent: NodeSpec = {
tag: 'div[data-node-type="containerWithRestrictedContent"]',
},
],
toDOM: () => {
return ['div', { 'data-node-type': 'containerWithRestrictedContent' }];
},
toDOM: () => ['div', { 'data-node-type': 'containerWithRestrictedContent' }],
};

const strike: MarkSpec = {
Expand All @@ -110,9 +102,7 @@ const strike: MarkSpec = {
getAttrs: (node) => (node === 'line-through' ? {} : false),
},
],
toDOM: () => {
return ['s', 0];
},
toDOM: () => ['s', 0],
};

export const schema = new Schema({
Expand Down
4 changes: 1 addition & 3 deletions packages/jest-remirror/src/jest-remirror-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -369,9 +369,7 @@ export class RemirrorTestChain<Extension extends AnyExtension> {
/**
* Alias for add.
*/
readonly overwrite = (taggedDocument: TaggedProsemirrorNode): this => {
return this.add(taggedDocument);
};
readonly overwrite = (taggedDocument: TaggedProsemirrorNode): this => this.add(taggedDocument);

/**
* Updates the tags.
Expand Down

1 comment on commit a445bb5

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉 Published on https://remirror.io as production
🚀 Deployed on https://649a8b2d7ce5234f5b50e407--remirror.netlify.app

Please sign in to comment.