Skip to content

Commit

Permalink
upgrade eslint to v9 (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
tiavina-mika authored Oct 9, 2024
1 parent 4e34b0d commit fb2ea57
Show file tree
Hide file tree
Showing 15 changed files with 1,212 additions and 1,569 deletions.
8 changes: 0 additions & 8 deletions .eslintignore

This file was deleted.

25 changes: 25 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,33 @@ env:
APP_NAME: tiptap-parser

jobs:
lint:
name: Lint
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

# need this for using yarn v4
- name: Enable Corepack
run: corepack enable

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install dependencies
run: yarn

- name: Lint
run: yarn lint

changelog:
name: Changelog
needs:
- lint
if: github.event_name != 'pull_request'
runs-on: ubuntu-latest

Expand Down
2 changes: 1 addition & 1 deletion .prettierrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports = {
endOfLine: "lf",
importOrderParserPlugins: ['typescript', 'jsx', 'decorators-legacy'],
plugins: [
'"plugins": ["prettier-plugin-organize-imports"]',
"prettier-plugin-organize-imports"
],
printWidth: 80,
semi: true,
Expand Down
112 changes: 112 additions & 0 deletions airbnb.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
import { fixupConfigRules } from "@eslint/compat";
import reactRefresh from "eslint-plugin-react-refresh";
import preferArrowFunctions from "eslint-plugin-prefer-arrow-functions";
import globals from "globals";
import tsParser from "@typescript-eslint/parser";
import path from "node:path";
import { fileURLToPath } from "node:url";
import js from "@eslint/js";
import { FlatCompat } from "@eslint/eslintrc";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all
});

export default [{
ignores: [
"**/dist",
"**/node_modules/",
"**/.eslintrc.cjs",
"**/node_modules",
"**/.eslintrc.cjs",
"**/.prettier.js",
"**/config.overrides.js",
"**/types",
"**/build",
"**/vite.config.ts",
],
}, ...fixupConfigRules(compat.extends(
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react-hooks/recommended",
"airbnb",
"airbnb/hooks",
"airbnb-typescript",
"plugin:eslint-comments/recommended",
"plugin:prettier/recommended",
)), {
plugins: {
"react-refresh": reactRefresh,
"prefer-arrow-functions": preferArrowFunctions,
},

languageOptions: {
globals: {
...globals.browser,
},

parser: tsParser,
ecmaVersion: 5,
sourceType: "module",

parserOptions: {
tsconfigRootDir: "E:\\my-libs\\tiptap-parser",
project: "./tsconfig.json",
},
},

rules: {
"prettier/prettier": ["off", {
singleQuote: true,
}],

"react/no-unknown-property": ["error", {
ignore: ["css"],
}],

"react-refresh/only-export-components": ["warn", {
allowConstantExport: true,
}],

"import/no-extraneous-dependencies": "off",
"import/extensions": "off",
"no-await-in-loop": "off",
"import/no-cycle": "off",
"@typescript-eslint/no-throw-literal": "off",
"no-plusplus": "off",
"no-param-reassign": "off",
"prefer-template": "off",
"@typescript-eslint/no-explicit-any": 0,
"react/react-in-jsx-scope": "off",
"no-console": "off",
"import/prefer-default-export": "off",
"global-require": "off",
"@typescript-eslint/no-shadow": "off",
"react/require-default-props": "off",
"react/jsx-props-no-spreading": "off",
"jsx-a11y/label-has-associated-control": "off",
"react/no-unescaped-entities": "off",
"jsx-a11y/control-has-associated-label": "off",
"react/function-component-definition": "off",
"react/prop-types": "off",
"eslint-comments/no-unused-disable": "warn",
"max-len": "off",
"consistent-return": "off",
"react/no-array-index-key": "off",
"no-restricted-syntax": "off",
"arrow-body-style": "off",
"prefer-arrow-callback": "off",

"prefer-arrow-functions/prefer-arrow-functions": ["warn", {
allowNamedFunctions: false,
classPropertiesAllowed: false,
disallowPrototype: false,
returnStyle: "unchanged",
singleReturnOnly: false,
}],
},
}];
127 changes: 127 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
import js from '@eslint/js'
import globals from 'globals'
import reactHooks from 'eslint-plugin-react-hooks'
import reactRefresh from 'eslint-plugin-react-refresh'
import tseslint from 'typescript-eslint'
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
import preferArrowFunctions from "eslint-plugin-prefer-arrow-functions";
import eslint from '@eslint/js';
import comments from "@eslint-community/eslint-plugin-eslint-comments/configs";

export default tseslint.config(
{
ignores: [
"**/dist",
"**/node_modules/",
"**/node_modules",
"**/build",
"**/vite.config.ts",
"**/example",

// temp files
"old.eslintrc.cjs",
"airbnb.mjs",
]
},
eslint.configs.recommended,
// ...fixupConfigRules(compat.extends(
// "plugin:react-hooks/recommended",
// "airbnb",
// "airbnb/hooks",
// "airbnb-typescript",
// "plugin:eslint-comments/recommended",
// "plugin:prettier/recommended",
// )),
{
extends: [
js.configs.recommended,
...tseslint.configs.recommended,
eslintPluginPrettierRecommended,
comments.recommended,
],
files: ['**/*.ts', '**/*.tsx'],
languageOptions: {
globals: {
...globals.browser,
// ...globals.node,
// ...globals.jest,
},
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
// parser: tsParser,
sourceType: "module",
ecmaVersion: 2023,
},
plugins: {
'react-hooks': reactHooks,
'react-refresh': reactRefresh,
"prefer-arrow-functions": preferArrowFunctions,
},
rules: {
...reactHooks.configs.recommended.rules,
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
"prettier/prettier": ["off", {
singleQuote: true,
}],
"@typescript-eslint/no-explicit-any": "off",
"import/no-extraneous-dependencies": "off",
"import/extensions": "off",
"no-await-in-loop": "off",
"import/no-cycle": "off",
"no-plusplus": "off",
"no-param-reassign": "off",
"prefer-template": "off",
"react/react-in-jsx-scope": "off",
"no-console": "off",
"import/prefer-default-export": "off",
"global-require": "off",
"react/require-default-props": "off",
"react/jsx-props-no-spreading": "off",
"jsx-a11y/label-has-associated-control": "off",
"react/no-unescaped-entities": "off",
"jsx-a11y/control-has-associated-label": "off",
"react/function-component-definition": "off",
"react/prop-types": "off",
"max-len": "off",
"consistent-return": "off",
"react/no-array-index-key": "off",
"no-restricted-syntax": "off",
"arrow-body-style": "off",
"prefer-arrow-callback": "off",
"comma-dangle": ["error", {
"arrays": "always-multiline", // Trailing commas for arrays with multiple lines
"objects": "always-multiline", // Trailing commas for objects with multiple lines
"imports": "always-multiline", // Trailing commas in multi-line import statements
"exports": "always-multiline", // Trailing commas in multi-line export statements
"functions": "never" // No trailing commas for function parameters
}],
"prefer-arrow-functions/prefer-arrow-functions": ["warn", {
allowNamedFunctions: false,
classPropertiesAllowed: false,
disallowPrototype: false,
returnStyle: "unchanged",
singleReturnOnly: false,
}],

// ------------ if not using airbnb ------------ //
"semi": ["error", "always"],
"no-useless-return": "error",
"require-await": "error",
"no-unused-vars": "warn",
"no-use-before-define": "error",
"array-bracket-spacing": ["error", "never"],
"block-spacing": "error",

// ------------ for airbnb ------------ //
// "react/no-unknown-property": ["error", {
// ignore: ["css"],
// }],
// "eslint-comments/no-unused-disable": "warn",
},
},
)
File renamed without changes.
26 changes: 15 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"format": "prettier --write .",
"format:check": "prettier --check .",
"lint:check": "eslint --max-warnings 0 --ext .js,.jsx,.ts,.tsx src",
"lint": "eslint . --ext ts,tsx --fix --report-unused-disable-directives --max-warnings 0",
"lint": "eslint . --fix",
"md-link:check": "markdown-link-check -v -p README.md -v -p CONTRIBUTING.md -v -p .github/**/*.md -c .markdown-link-check-config.json",
"spell:check": "cspell \"{README.md,CONTRIBUTING.md,.github/*.md}\"",
"visualize": "npx vite-bundle-visualizer",
Expand All @@ -74,33 +74,37 @@
"react-dom": "^16.8.0 || ^17.0.2 || ^18.2.0"
},
"devDependencies": {
"@eslint-community/eslint-plugin-eslint-comments": "^4.4.0",
"@eslint/compat": "^1.2.0",
"@eslint/eslintrc": "^3.1.0",
"@eslint/js": "^9.12.0",
"@types/eslint__js": "^8.42.3",
"@types/react": "^18.2.43",
"@types/react-dom": "^18.2.17",
"@typescript-eslint/eslint-plugin": "^6.14.0",
"@typescript-eslint/parser": "^6.20.0",
"@vitejs/plugin-react": "^4.2.1",
"babel-plugin-module-resolver": "^5.0.0",
"copyfiles": "^2.4.1",
"cspell": "^6.31.1",
"eslint": "^8.56.0",
"eslint": "^9.12.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-airbnb-typescript": "^17.1.0",
"eslint-config-next": "^14.0.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-prefer-arrow-functions": "^3.2.4",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.5",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-react-hooks": "^4.6.2",
"eslint-plugin-react-refresh": "^0.4.12",
"globals": "^15.11.0",
"markdown-link-check": "^3.12.1",
"prettier": "^3.2.2",
"prettier-plugin-organize-imports": "^3.2.4",
"prettier": "^3.3.3",
"prettier-plugin-organize-imports": "^4.1.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"rimraf": "^5.0.5",
"ts-add-js-extension": "^1.6.4",
"typescript": "^5.2.2",
"typescript": "5.5.3",
"typescript-eslint": "^8.8.1",
"vite": "5.0.8",
"vite-tsconfig-paths": "^4.3.1"
},
Expand Down
10 changes: 5 additions & 5 deletions src/TiptapParser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
*
*/
import parse, { HTMLReactParserOptions, DOMNode, Element, attributesToProps, domToReact } from 'html-react-parser';
import { common, createLowlight } from 'lowlight'
import { toHtml } from 'hast-util-to-html'
import { common, createLowlight } from 'lowlight';
import { toHtml } from 'hast-util-to-html';
import { ElementType } from 'react';
import './index.css';
import CodeBlockWithCopy from './components/CodeBlockWithCopy';
Expand Down Expand Up @@ -109,15 +109,15 @@ const parseHtml = (
</Component>
);
}
}
},
};

/*
* If the `<code>` tag is not found in the html string content
* it means that there are no code snippets to be highlighted.
*/
return parse(text, { ...defaultOptions, ...options });
}
};

// ------------------------------ //
// ---------- main props -------- //
Expand Down Expand Up @@ -151,6 +151,6 @@ const TiptapParser = ({ classNames, containerClassName, language, content, ...re
{parseHtml(content, classNames, language, rest)}
</div>
);
}
};

export default TiptapParser;
2 changes: 1 addition & 1 deletion src/components/icons/Check.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ const Check = () => {
<polyline points="20 6 9 17 4 12" />
</svg>
);
}
};

export default Check;
Loading

0 comments on commit fb2ea57

Please sign in to comment.