Skip to content

Eslint-all #89

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
env:
browser: true
es2021: true
extends:
- eslint:recommended
- plugin:@typescript-eslint/recommended
- prettier
parser: '@typescript-eslint/parser'
parserOptions:
ecmaVersion: latest
sourceType: module
plugins:
- '@typescript-eslint'
rules:
indent:
- warn
- 2
linebreak-style:
- error
- unix
semi:
- error
- always
19 changes: 14 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -13,9 +13,11 @@
"build:examples": "pnpm -r --filter {examples/*} build",
"build:types": "pnpm -r --filter !{examples/*} exec -- tsup --dts-only",
"dev": "pnpm -r --parallel --filter !{examples/*} dev",
"lint": "prettier --check --plugin-search-dir=. .",
"lint:eslint": "eslint packages/**/src",
"lint:prettier": "prettier --check --plugin-search-dir=. .",
"lint": "pnpm lint:prettier && pnpm lint:eslint",
"lint:fix": "pnpm lint:fix:prettier",
"lint:fix:prettier": "prettier --write --plugin-search-dir=. .",
"lint:fix:prettier": "pretty-quick --staged",
"play": "cd examples/sveltekit && pnpm dev",
"play:build": "pnpm build && cd examples/sveltekit && pnpm build",
"prepublish:ci": "pnpm -r update",
@@ -38,9 +40,9 @@
"dependencies": {
"@flatbread/config": "workspace:*",
"@flatbread/core": "workspace:*",
"@flatbread/resolver-svimg": "workspace:*",
"@flatbread/source-filesystem": "workspace:*",
"@flatbread/transformer-markdown": "workspace:*",
"@flatbread/resolver-svimg": "workspace:*",
"flatbread": "workspace:*"
},
"devDependencies": {
@@ -49,14 +51,16 @@
"@types/node": "16.11.47",
"ava": "4.3.1",
"bumpp": "8.2.1",
"eslint": "7",
"esno": "0.16.3",
"export-size": "0.5.2",
"husky": "7.0.4",
"husky": "8.0.1",
"kleur": "4.1.5",
"npkill": "0.8.3",
"prettier": "2.7.1",
"pretty-quick": "3.1.3",
"ts-node": "10.9.1",
"tsconfig-paths": "3.14.1",
"tsconfig-paths": "4.0.0",
"tsup": "6.2.1",
"typescript": "4.7.4"
},
@@ -66,5 +70,10 @@
"graphql": "^16.0.1"
}
}
},
"husky": {
"hooks": {
"pre-commit": "lint:fix"
}
}
}
2 changes: 1 addition & 1 deletion packages/core/src/generators/schema.ts
Original file line number Diff line number Diff line change
@@ -82,7 +82,7 @@ export async function generateSchema(
/**
* @todo potentially able to remove this
**/
let queries: RootQueries = {
const queries: RootQueries = {
maybeReturnsSingleItem: [],
maybeReturnsList: [],
};
2 changes: 1 addition & 1 deletion packages/core/src/resolvers/arguments.ts
Original file line number Diff line number Diff line change
@@ -83,7 +83,7 @@ const resolveQueryArgs = async (
*
*/
function buildFilterQueryFragment(filterSetManifest: TargetAndComparator) {
let filterToQuery = [];
const filterToQuery = [];

for (const filter of filterSetManifest) {
let graphQLFieldAccessor = '';
2 changes: 1 addition & 1 deletion packages/core/src/utils/deepEntries.ts
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ const deepEntries = (
stack: any[] = []
): [string[], any] => {
if (typeOf(obj) === 'object') {
for (let [key, value] of Object.entries(obj)) {
for (const [key, value] of Object.entries(obj)) {
stack = deepEntries(value, [...path, key], stack);
}
} else {
4 changes: 2 additions & 2 deletions packages/core/src/utils/sift.ts
Original file line number Diff line number Diff line change
@@ -26,9 +26,9 @@ const createFilterFunction = (
// Filter args transformed to logical expressions.
filterSetManifest ??= generateFilterSetManifest(filterArgs);

let evaluatedFilterSet: boolean[] = [];
const evaluatedFilterSet: boolean[] = [];

for (let { path, comparator } of filterSetManifest) {
for (const { path, comparator } of filterSetManifest) {
// Retrieve the value of interest from the node.
const needle = get(node, path, undefined);
// Compare the value of interest to the target value, and store the result of the evaluated expression.
5 changes: 4 additions & 1 deletion packages/core/src/utils/typeOf.ts
Original file line number Diff line number Diff line change
@@ -9,7 +9,10 @@ export default function typeOf<T>(obj?: T) {
return (obj + '').toLowerCase();
} // implicit toString() conversion

var deepType = Object.prototype.toString.call(obj).slice(8, -1).toLowerCase();
const deepType = Object.prototype.toString
.call(obj)
.slice(8, -1)
.toLowerCase();
if (deepType === 'generatorfunction') {
return 'function';
}
6 changes: 3 additions & 3 deletions packages/flatbread/src/cli/runner.ts
Original file line number Diff line number Diff line change
@@ -26,7 +26,7 @@ export default function orchestrateProcesses({
packageManager = null,
}: OrchestraOptions) {
const pkgManager = packageManager || detectPkgManager(process.cwd());
let serverModulePath = 'node_modules/flatbread/dist/graphql/server.js';
const serverModulePath = 'node_modules/flatbread/dist/graphql/server.js';

process.cwd();
const gql = fork(resolve(process.cwd(), serverModulePath), [''], {
@@ -36,7 +36,7 @@ export default function orchestrateProcesses({
FLATBREAD_PORT: String(flatbreadPort),
},
});
let runningScripts = [gql];
const runningScripts = [gql];

gql.on('message', (msg) => {
if (msg === 'flatbread-gql-ready') {
@@ -49,7 +49,7 @@ export default function orchestrateProcesses({
runningScripts.push(targetProcess);

// Exit the parent process when the target process exits
for (let script of runningScripts) {
for (const script of runningScripts) {
script.on('close', () => {
process.exit();
});
11 changes: 4 additions & 7 deletions packages/source-filesystem/src/index.ts
Original file line number Diff line number Diff line change
@@ -45,13 +45,10 @@ async function getAllNodes(
): Promise<Record<string, VFile[]>> {
const nodeEntries = await Promise.all(
allContentTypes.map(
async (contentType): Promise<Record<string, any>> =>
new Promise(async (res) =>
res([
contentType.collection,
await getNodesFromDirectory(contentType.path, config),
])
)
async (contentType): Promise<Record<string, any>> => [
contentType.collection,
await getNodesFromDirectory(contentType.path, config),
]
)
);

2 changes: 1 addition & 1 deletion packages/source-filesystem/src/utils/gatherFileNodes.ts
Original file line number Diff line number Diff line change
@@ -56,7 +56,7 @@ export default async function gatherFileNodes(
// for each segment - gather names for capture groups
// and calculate what to remove from matches ex: [name].md => remove .md from match
const segments = globs.map((branch) => {
let index = branch.indexOf(']');
const index = branch.indexOf(']');
if (index === -1) return null;
return {
name: branch.slice(0, index),
12 changes: 0 additions & 12 deletions packages/transformer-markdown/README.md
Original file line number Diff line number Diff line change
@@ -70,18 +70,6 @@ export interface MarkdownTransformerConfig {
markdown?: MarkdownConfig;
}

/**
* An engine may either be an object with parse and
* (optionally) stringify methods, or a function that will
* be used for parsing only.
*/
export type LanguageEngine =
| {
parse: (input: string) => object;
stringify?: (data: object) => string;
}
| ((input: string) => object);

/**
* User-configurable options for the [gray-matter](https://www.npmjs.com/package/gray-matter) frontmatter parser.
*/
1 change: 1 addition & 0 deletions packages/transformer-markdown/src/processors/markdown.ts
Original file line number Diff line number Diff line change
@@ -28,6 +28,7 @@ const applyPlugins = (
): Processor => {
plugins.forEach((plugin) => {
if (Array.isArray(plugin)) {
// TODO: is this a bug?
if (plugin[1] && plugin[1]) processor.use(plugin[0] as Plugin, plugin[1]);
else processor.use(plugin[0]);
} else {
111 changes: 100 additions & 11 deletions pnpm-lock.yaml