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
Show file tree
Hide file tree
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
Expand Up @@ -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",
Expand All @@ -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": {
Expand All @@ -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"
},
Expand All @@ -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
Expand Up @@ -82,7 +82,7 @@ export async function generateSchema(
/**
* @todo potentially able to remove this
**/
let queries: RootQueries = {
const queries: RootQueries = {
maybeReturnsSingleItem: [],
maybeReturnsList: [],
};
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/resolvers/arguments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const resolveQueryArgs = async (
*
*/
function buildFilterQueryFragment(filterSetManifest: TargetAndComparator) {
let filterToQuery = [];
const filterToQuery = [];

for (const filter of filterSetManifest) {
let graphQLFieldAccessor = '';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/utils/deepEntries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/utils/sift.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 4 additions & 1 deletion packages/core/src/utils/typeOf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
Expand Down
6 changes: 3 additions & 3 deletions packages/flatbread/src/cli/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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), [''], {
Expand All @@ -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') {
Expand All @@ -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();
});
Expand Down
11 changes: 4 additions & 7 deletions packages/source-filesystem/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
]
)
);

Expand Down
2 changes: 1 addition & 1 deletion packages/source-filesystem/src/utils/gatherFileNodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
12 changes: 0 additions & 12 deletions packages/transformer-markdown/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
1 change: 1 addition & 0 deletions packages/transformer-markdown/src/processors/markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading