chore: lint

This commit is contained in:
liyasthomas
2022-01-05 10:17:23 +05:30
parent dd7aebaf94
commit ffd1acdfae
10 changed files with 50 additions and 48 deletions

View File

@@ -1,12 +1,12 @@
import typescript from "rollup-plugin-ts" import typescript from "rollup-plugin-ts"
import {lezer} from "@lezer/generator/rollup" import { lezer } from "@lezer/generator/rollup"
export default { export default {
input: "src/index.js", input: "src/index.js",
external: id => id != "tslib" && !/^(\.?\/|\w:)/.test(id), external: (id) => id != "tslib" && !/^(\.?\/|\w:)/.test(id),
output: [ output: [
{file: "dist/index.cjs", format: "cjs"}, { file: "dist/index.cjs", format: "cjs" },
{dir: "./dist", format: "es"} { dir: "./dist", format: "es" },
], ],
plugins: [lezer(), typescript()] plugins: [lezer(), typescript()],
} }

View File

@@ -1,22 +1,30 @@
import {parser} from "./syntax.grammar" import { parser } from "./syntax.grammar"
import {LRLanguage, LanguageSupport, indentNodeProp, foldNodeProp, foldInside, delimitedIndent} from "@codemirror/language" import {
import {styleTags, tags as t} from "@codemirror/highlight" LRLanguage,
LanguageSupport,
indentNodeProp,
foldNodeProp,
foldInside,
delimitedIndent,
} from "@codemirror/language"
import { styleTags, tags as t } from "@codemirror/highlight"
export const GQLLanguage = LRLanguage.define({ export const GQLLanguage = LRLanguage.define({
parser: parser.configure({ parser: parser.configure({
props: [ props: [
indentNodeProp.add({ indentNodeProp.add({
"SelectionSet FieldsDefinition ObjectValue SchemaDefinition RootTypeDef": delimitedIndent({ closing: "}", align: true }), "SelectionSet FieldsDefinition ObjectValue SchemaDefinition RootTypeDef":
delimitedIndent({ closing: "}", align: true }),
}), }),
foldNodeProp.add({ foldNodeProp.add({
Application: foldInside, Application: foldInside,
"SelectionSet FieldsDefinition ObjectValue RootOperationTypeDefinition RootTypeDef": (node) => { "SelectionSet FieldsDefinition ObjectValue RootOperationTypeDefinition RootTypeDef":
return { (node) => {
from: node.from, return {
to: node.to from: node.from,
} to: node.to,
}
} },
}), }),
styleTags({ styleTags({
Name: t.definition(t.variableName), Name: t.definition(t.variableName),
@@ -29,13 +37,13 @@ export const GQLLanguage = LRLanguage.define({
NullValue: t.null, NullValue: t.null,
ObjectValue: t.brace, ObjectValue: t.brace,
Comment: t.lineComment, Comment: t.lineComment,
}) }),
] ],
}), }),
languageData: { languageData: {
commentTokens: { line: "#" }, commentTokens: { line: "#" },
closeBrackets: { brackets: ["(", "[", "{", '"', '"""'] } closeBrackets: { brackets: ["(", "[", "{", '"', '"""'] },
} },
}) })
export function GQL() { export function GQL() {

View File

@@ -6,7 +6,7 @@
"newLine": "lf", "newLine": "lf",
"declaration": true, "declaration": true,
"moduleResolution": "node", "moduleResolution": "node",
"allowJs": true, "allowJs": true
}, },
"include": ["src/*"] "include": ["src/*"]
} }

View File

@@ -1,13 +1,13 @@
import dts from 'rollup-plugin-dts' import dts from "rollup-plugin-dts"
import esbuild from 'rollup-plugin-esbuild' import esbuild from "rollup-plugin-esbuild"
import multi from '@rollup/plugin-multi-entry' import multi from "@rollup/plugin-multi-entry"
const name = require('./package.json').main.replace(/\.js$/, '') const name = require("./package.json").main.replace(/\.js$/, "")
const bundle = config => ({ const bundle = (config) => ({
...config, ...config,
input: 'src/**/*.ts', input: "src/**/*.ts",
external: id => !/^[./]/.test(id), external: (id) => !/^[./]/.test(id),
}) })
export default [ export default [
@@ -16,12 +16,12 @@ export default [
output: [ output: [
{ {
file: `${name}.js`, file: `${name}.js`,
format: 'cjs', format: "cjs",
sourcemap: true, sourcemap: true,
}, },
{ {
file: `${name}.mjs`, file: `${name}.mjs`,
format: 'es', format: "es",
sourcemap: true, sourcemap: true,
}, },
], ],
@@ -30,7 +30,7 @@ export default [
plugins: [dts()], plugins: [dts()],
output: { output: {
file: `${name}.d.ts`, file: `${name}.d.ts`,
format: 'es', format: "es",
}, },
}), }),
] ]

View File

@@ -1,8 +1,8 @@
import { Options } from 'tsup' import { Options } from "tsup"
const options: Options = { const options: Options = {
format: [ format: [
'cjs', "cjs",
// loading Babel in ESM is tricky, since Babel itself it CJS only // loading Babel in ESM is tricky, since Babel itself it CJS only
// we decided to drop ESM support until Babel supports native ESM // we decided to drop ESM support until Babel supports native ESM
// 'esm', // 'esm',
@@ -10,9 +10,7 @@ const options: Options = {
clean: true, clean: true,
splitting: true, splitting: true,
dts: true, dts: true,
entryPoints: [ entryPoints: ["src/**/*.ts"],
'src/**/*.ts',
],
} }
export default options export default options

View File

@@ -10,11 +10,7 @@
"~/*": ["./src/*"], "~/*": ["./src/*"],
"@/*": ["./src/*"] "@/*": ["./src/*"]
}, },
"types": [ "types": ["@types/node", "@types/jest", "@relmify/jest-fp-ts"],
"@types/node",
"@types/jest",
"@relmify/jest-fp-ts"
],
"outDir": "./lib/", "outDir": "./lib/",
"rootDir": "./src/", "rootDir": "./src/",
"declaration": true, "declaration": true,