Skip to content

Commit

Permalink
Migrate eslint to flat config.
Browse files Browse the repository at this point in the history
Update vue.
  • Loading branch information
logue committed Apr 23, 2024
1 parent ac9e283 commit 0d8eee4
Show file tree
Hide file tree
Showing 12 changed files with 618 additions and 438 deletions.
8 changes: 0 additions & 8 deletions .eslintignore

This file was deleted.

73 changes: 0 additions & 73 deletions .eslintrc.yml

This file was deleted.

4 changes: 1 addition & 3 deletions .ncurc
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{
"reject": [
"@codemirror/lang-vue",
"eslint",
"eslint-linter-browserify"
"@codemirror/lang-vue"
]
}
165 changes: 165 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';
import eslintConfigPrettier from 'eslint-config-prettier';

import pluginImport from 'eslint-plugin-import';
import pluginTsdoc from 'eslint-plugin-tsdoc';
//import pluginVue from 'eslint-plugin-vue';
/**
* ESLint Config
*/
// @ts-check
export default tseslint.config(
{
ignores: [
'.vscode/',
'.yarn/',
'dist/',
'public/',
'src/** /*.generated.*',
'eslint.config.js',
],
},
eslint.configs.recommended,
...tseslint.configs.recommended,
...tseslint.configs.stylistic,
{
languageOptions: {
parserOptions: {
project: ['tsconfig.app.json', 'tsconfig.node.json'],
tsconfigRootDir: import.meta.dirname,
extraFileExtensions: ['.vue'],
ecmaVersion: 'latest',
sourceType: 'module',
},
},
plugins: {
import: pluginImport,
tsdoc: pluginTsdoc,
//vue: pluginVue,
},
settings: {
// This will do the trick
'import/parsers': {
espree: ['.js', '.cjs', '.mjs', '.jsx'],
'@typescript-eslint/parser': ['.ts', '.tsx'],
'vue-eslint-parser': ['.vue'],
},
'import/resolver': {
typescript: true,
node: true,
alias: {
map: [
['@', './src'],
['~', './node_modules'],
['vue-codemirror6', './src'],
],
extensions: ['.js', '.ts', '.jsx', '.tsx', '.vue'],
},
},
vite: {
configPath: './vite.config.ts',
},
},
rules: {
'@typescript-eslint/consistent-type-imports': 'error',
'@typescript-eslint/no-import-type-side-effects': 'error',
// ...importPlugin.configs["recommended"].rules,
'no-unused-vars': 'warn',
// const lines: string[] = []; style
'@typescript-eslint/array-type': [
'error',
{
default: 'array',
},
],
// Enable @ts-ignore etc.
'@typescript-eslint/ban-ts-comment': 'off',
// Left-hand side style
'@typescript-eslint/consistent-generic-constructors': [
'error',
'type-annotation',
],
// Enable import sort order, see bellow.
'@typescript-eslint/consistent-type-imports': [
'off',
{
prefer: 'type-imports',
},
],
// Fix for pinia
'@typescript-eslint/explicit-function-return-type': 'off',
// Allow short land for pretter
'@typescript-eslint/no-confusing-void-expression': [
'error',
{
ignoreArrowShorthand: true,
},
],
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unused-vars': 'off',
// Fix for vite import.meta.env
'@typescript-eslint/strict-boolean-expressions': 'off',
// Fix for vite env.d.ts.
'@typescript-eslint/triple-slash-reference': 'off',
// Fix for Vue setup style
'import/default': 'off',
// Fix for Vue setup style
'import/no-default-export': 'off',
// Sort Import Order.
// see https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/order.md#importorder-enforce-a-convention-in-module-import-order
'import/order': [
'error',
{
groups: [
'builtin',
'external',
'parent',
'sibling',
'index',
'object',
'type',
],
pathGroups: [
// Vue Core
{
pattern:
'{vue,vue-router,vuex,@/stores,vue-i18n,pinia,vite,vitest,vitest/**,@vitejs/**,@vue/**}',
group: 'external',
position: 'before',
},
// Internal Codes
{
pattern: '{@/**}',
group: 'internal',
position: 'before',
},
],
pathGroupsExcludedImportTypes: ['builtin'],
alphabetize: {
order: 'asc',
},
'newlines-between': 'always',
},
],
'tsdoc/syntax': 'warn',
/*
// A tag with no content should be written like <br />.
'vue/html-self-closing': [
'error',
{
html: {
void: 'always',
},
},
],
// Mitigate non-multiword component name errors to warnings.
'vue/multi-word-component-names': 'warn',
// for Vuetify Labs Fix (v-data-tables etc.)
'vuetify/no-deprecated-components': 'warn',
*/
},
},
// ...pluginVue.configs['flat/recommended'],
eslintConfigPrettier
);
24 changes: 14 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://json.schemastore.org/package.json",
"name": "vue-codemirror6",
"version": "1.2.7",
"version": "1.3.0",
"license": "MIT",
"description": "CodeMirror6 Component for vue2 and vue3.",
"keywords": [
Expand Down Expand Up @@ -83,21 +83,22 @@
"@codemirror/lang-json": "^6.0.1",
"@codemirror/lang-markdown": "^6.2.5",
"@codemirror/lang-vue": "0.1.2",
"@eslint/js": "^9.1.1",
"@tsconfig/node-lts": "^20.1.3",
"@types/node": "^20.12.7",
"@typescript-eslint/eslint-plugin": "^7.7.0",
"@typescript-eslint/eslint-plugin": "^7.7.1",
"@vitejs/plugin-vue": "^5.0.4",
"@vue/compiler-sfc": "^3.4.23",
"@vue/compiler-sfc": "^3.4.24",
"@vue/eslint-config-prettier": "^9.0.0",
"@vue/tsconfig": "^0.5.1",
"@vueuse/core": "^10.9.0",
"bootstrap": "^5.3.3",
"eslint": "^8.57.0",
"eslint": "^9.1.1",
"eslint-config-standard-with-typescript": "^43.0.1",
"eslint-import-resolver-alias": "^1.1.2",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-linter-browserify": "^8.57.0",
"eslint-plugin-html": "^8.1.0",
"eslint-linter-browserify": "^9.1.1",
"eslint-plugin-html": "^8.1.1",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-n": "^17.2.1",
"eslint-plugin-promise": "^6.1.1",
Expand All @@ -113,14 +114,15 @@
"rollup-plugin-visualizer": "^5.12.0",
"sass": "^1.75.0",
"typescript": "^5.4.5",
"vite": "^5.2.9",
"typescript-eslint": "^7.7.1",
"vite": "^5.2.10",
"vite-plugin-banner": "^0.7.1",
"vite-plugin-checker": "^0.6.4",
"vite-plugin-dts": "^3.8.3",
"vue": "^3.4.23",
"vite-plugin-dts": "^3.9.0",
"vue": "^3.4.24",
"vue-eslint-parser": "^9.4.2",
"vue-markdown-wasm": "^0.4.0",
"vue-tsc": "^2.0.13"
"vue-tsc": "^2.0.14"
},
"husky": {
"hooks": {
Expand All @@ -133,9 +135,11 @@
},
"resolutions": {
"json5": ">=2.2.3",
"ip": ">=2.0.1",
"lodash": ">=4.17.21",
"postcss": ">=8.4.31",
"semver": ">=7.5.3",
"tar": ">=6.2.1",
"yaml": ">=2.3.2"
}
}
21 changes: 9 additions & 12 deletions src-docs/components/LinterAndCrossBindingDemo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import { ref, type Ref } from 'vue';
import CodeMirror from 'vue-codemirror6';
import { esLint, javascript } from '@codemirror/lang-javascript';
import type { LintSource } from '@codemirror/lint';
import { javascript, esLint } from '@codemirror/lang-javascript';
// Uses linter.mjs
import eslint from 'eslint-linter-browserify';
// Sync Dark mode
Expand All @@ -25,20 +25,17 @@ const focused: Ref<boolean> = ref(false);
*
* @see {@link https://github.com/UziTech/eslint-linter-browserify#eslint-linter-browserify}
*/
const linter: LintSource = esLint(
// eslint-disable-next-line
new eslint.Linter(),
{
const linter = esLint(new eslint.Linter(), {
languageOptions: {
parserOptions: {
ecmaVersion: 2022,
sourceType: 'module',
},
env: {
browser: true,
node: true,
},
}
);
},
rules: {
semi: ['error', 'never'],
},
});
const onFocus = (f: boolean): void => {
focused.value = f;
Expand Down
1 change: 1 addition & 0 deletions src-docs/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import './style.scss';

/** Demo Code */
import { createApp } from 'vue';

import App from './App.vue';

createApp(App).mount('#app');
Loading

0 comments on commit 0d8eee4

Please sign in to comment.