fix: lint
This commit is contained in:
parent
a2e775b64f
commit
675aaadaed
|
@ -291,15 +291,11 @@ module.exports = class Build extends Flecks {
|
|||
.map(async ([
|
||||
root,
|
||||
{
|
||||
flecks,
|
||||
path,
|
||||
source,
|
||||
},
|
||||
]) => {
|
||||
allowlist.push(new RegExp(`^${path}`));
|
||||
// flecks.forEach((fleck) => {
|
||||
// allowlist.push(fleck);
|
||||
// });
|
||||
debugSilly('%s runtime de-externalized %s, alias: %s', runtime, root, source || path);
|
||||
// Alias.
|
||||
config.resolve.alias[path] = source || path;
|
||||
|
|
|
@ -121,6 +121,7 @@ exports.commands = (program, flecks) => {
|
|||
cmd,
|
||||
{
|
||||
cwd,
|
||||
env: {FLECKS_CORE_ROOT},
|
||||
},
|
||||
);
|
||||
child.on('error', reject);
|
||||
|
|
|
@ -23,6 +23,7 @@ module.exports = async (flecks) => ({
|
|||
'build/**/*.js',
|
||||
],
|
||||
rules: {
|
||||
'import/no-extraneous-dependencies': ['error', {devDependencies: true}],
|
||||
'import/no-dynamic-require': 'off',
|
||||
'global-require': 'off',
|
||||
},
|
||||
|
|
|
@ -38,7 +38,7 @@ if (FLECKS_CORE_SYNC_FOR_ESLINT) {
|
|||
}
|
||||
else {
|
||||
// Check cache first.
|
||||
const cacheDirectory = join(FLECKS_CORE_ROOT, 'node_modules', '.cache', '@flecks', 'core');
|
||||
const cacheDirectory = join(FLECKS_CORE_ROOT, 'node_modules', '.cache', '@flecks', 'build');
|
||||
try {
|
||||
statSync(join(cacheDirectory, 'eslint.config.json'));
|
||||
module.exports = JSON.parse(readFileSync(join(cacheDirectory, 'eslint.config.json')).toString());
|
||||
|
|
|
@ -99,9 +99,8 @@ module.exports = async function explicate(
|
|||
if (path !== request) {
|
||||
resolver.addAlias(path, request);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (await resolver.resolve(join(descriptor.request, 'src', platform))) {
|
||||
else if (await resolver.resolve(join(descriptor.request, 'src', platform))) {
|
||||
const [path, request] = [
|
||||
join(descriptor.path, platform),
|
||||
join(descriptor.request, 'src', platform),
|
||||
|
@ -110,7 +109,6 @@ module.exports = async function explicate(
|
|||
if (path !== request) {
|
||||
resolver.addAlias(path, request);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}),
|
||||
);
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
"commander": "11.1.0",
|
||||
"copy-webpack-plugin": "^11.0.0",
|
||||
"enhanced-resolve": "^5.9.2",
|
||||
"eslint": "^7.0.0",
|
||||
"eslint": "^8.56.0",
|
||||
"eslint-config-airbnb": "^19.0.4",
|
||||
"eslint-config-airbnb-base": "^15.0.0",
|
||||
"eslint-import-resolver-webpack": "^0.13.8",
|
||||
|
|
74
packages/core/build/core.eslint.config.js
Normal file
74
packages/core/build/core.eslint.config.js
Normal file
|
@ -0,0 +1,74 @@
|
|||
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||
const globals = require('globals');
|
||||
|
||||
module.exports = ({
|
||||
extends: [
|
||||
require.resolve('eslint-config-airbnb'),
|
||||
require.resolve('eslint-config-airbnb/hooks'),
|
||||
],
|
||||
globals: {
|
||||
...globals.browser,
|
||||
...globals.es2021,
|
||||
...globals.mocha,
|
||||
...globals.node,
|
||||
__non_webpack_require__: true,
|
||||
},
|
||||
ignorePatterns: [
|
||||
'dist/**',
|
||||
// Not even gonna try.
|
||||
'build/dox/hooks.js',
|
||||
],
|
||||
overrides: [
|
||||
{
|
||||
files: [
|
||||
'build/**/*.js',
|
||||
],
|
||||
rules: {
|
||||
'import/no-dynamic-require': 'off',
|
||||
'global-require': 'off',
|
||||
},
|
||||
},
|
||||
{
|
||||
files: [
|
||||
'test/**/*.js',
|
||||
],
|
||||
rules: {
|
||||
'brace-style': 'off',
|
||||
'class-methods-use-this': 'off',
|
||||
'import/no-extraneous-dependencies': 'off',
|
||||
'import/no-unresolved': 'off',
|
||||
'max-classes-per-file': 'off',
|
||||
'no-new': 'off',
|
||||
'no-unused-expressions': 'off',
|
||||
'padded-blocks': 'off',
|
||||
},
|
||||
},
|
||||
],
|
||||
parser: require.resolve('@babel/eslint-parser'),
|
||||
parserOptions: {
|
||||
requireConfigFile: false,
|
||||
},
|
||||
plugins: ['@babel'],
|
||||
rules: {
|
||||
'brace-style': ['error', 'stroustrup'],
|
||||
// Bug: https://github.com/import-js/eslint-plugin-import/issues/2181
|
||||
'import/no-import-module-exports': 'off',
|
||||
'import/prefer-default-export': 'off',
|
||||
'jsx-a11y/control-has-associated-label': ['error', {assert: 'either'}],
|
||||
'jsx-a11y/label-has-associated-control': ['error', {assert: 'either'}],
|
||||
'no-param-reassign': ['error', {props: false}],
|
||||
'no-plusplus': 'off',
|
||||
'no-shadow': 'off',
|
||||
'object-curly-spacing': 'off',
|
||||
'padded-blocks': ['error', {classes: 'always'}],
|
||||
yoda: 'off',
|
||||
},
|
||||
settings: {
|
||||
'import/resolver': {
|
||||
node: {},
|
||||
},
|
||||
react: {
|
||||
version: '18.2.0',
|
||||
},
|
||||
},
|
||||
});
|
|
@ -463,7 +463,8 @@ exports.Flecks = class Flecks {
|
|||
}
|
||||
|
||||
/**
|
||||
* Return an object whose keys are fleck paths and values are the `await`ed result of invoking the hook.
|
||||
* Return an object whose keys are fleck paths and values are the `await`ed result of invoking
|
||||
* the hook.
|
||||
* @param {string} hook
|
||||
* @param {...any} args Arguments passed to each implementation.
|
||||
* @returns {*}
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
"scripts": {
|
||||
"build": "NODE_PATH=./node_modules webpack --config ./build/core.webpack.config.js --mode production",
|
||||
"clean": "rm -rf yarn.lock && yarn",
|
||||
"lint": "NODE_PATH=./node_modules eslint --config ../build/build/eslint.config.js .",
|
||||
"lint": "NODE_PATH=./node_modules eslint --config ./build/core.eslint.config.js .",
|
||||
"postversion": "cp package.json dist",
|
||||
"test": "npm run build -d && mocha -t 10000 --colors ./dist/test.js"
|
||||
},
|
||||
|
@ -50,7 +50,7 @@
|
|||
"chai": "4.2.0",
|
||||
"chai-as-promised": "7.1.1",
|
||||
"copy-webpack-plugin": "^11.0.0",
|
||||
"eslint": "^7.0.0",
|
||||
"eslint": "^8.56.0",
|
||||
"eslint-config-airbnb": "^19.0.4",
|
||||
"eslint-config-airbnb-base": "^15.0.0",
|
||||
"eslint-import-resolver-webpack": "^0.13.8",
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const {processCode, spawnWith} = require('@flecks/core/build/commands');
|
||||
const {processCode, spawnWith} = require('@flecks/build/build/commands');
|
||||
|
||||
module.exports = async (packageManager, cwd) => {
|
||||
const code = await processCode(spawnWith([packageManager, 'install'], {cwd}));
|
||||
|
|
|
@ -2,10 +2,7 @@
|
|||
|
||||
const {join} = require('path');
|
||||
|
||||
const {
|
||||
Option,
|
||||
program,
|
||||
} = require('@flecks/core/build/commands');
|
||||
const {program} = require('@flecks/build/build/commands');
|
||||
const {
|
||||
dumpYml,
|
||||
loadYml,
|
||||
|
@ -23,7 +20,7 @@ const {
|
|||
(async () => {
|
||||
program.argument('<app>', 'name of the app to create');
|
||||
program.addOption(
|
||||
new Option('-pm,--package-manager <binary>', 'package manager binary')
|
||||
program.createOption('-pm,--package-manager <binary>', 'package manager binary')
|
||||
.choices(['npm', 'bun', 'yarn'])
|
||||
.default('npm'),
|
||||
);
|
||||
|
|
|
@ -74,6 +74,6 @@ export const mixin = (Flecks) => class FlecksWithDb extends Flecks {
|
|||
this.transaction = sequelize.transaction.bind(sequelize);
|
||||
},
|
||||
transaction: () => {},
|
||||
}
|
||||
};
|
||||
|
||||
};
|
||||
|
|
|
@ -47,9 +47,7 @@ module.exports = (program, flecks) => {
|
|||
if (siteDirExisted) {
|
||||
throw new Error(`A website directory at ${resolvedSiteDir} already exists!`);
|
||||
}
|
||||
const templateDirectory = dirname(
|
||||
__non_webpack_require__.resolve('@flecks/dox/website/sidebars.js'),
|
||||
);
|
||||
const templateDirectory = dirname(require.resolve('@flecks/dox/website/sidebars.js'));
|
||||
await cp(templateDirectory, resolvedSiteDir, {recursive: true});
|
||||
// Copy the docusaurus config if it doesn't already exist.
|
||||
try {
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
// There are various equivalent ways to declare your Docusaurus config.
|
||||
// See: https://docusaurus.io/docs/api/docusaurus-config
|
||||
|
||||
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||
const {configDefaults} = require('@flecks/dox/build/docusaurus');
|
||||
|
||||
module.exports = async function flecksDocusaurus() {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
const {stat, unlink} = require('fs/promises');
|
||||
const {join} = require('path');
|
||||
|
||||
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||
const {commands: coreCommands} = require('@flecks/build/build/commands');
|
||||
const {D} = require('@flecks/core');
|
||||
const {glob} = require('@flecks/core/server');
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
const {join} = require('path');
|
||||
|
||||
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||
const {hook} = require('@flecks/build/build/process-assets');
|
||||
|
||||
const commands = require('./commands');
|
||||
|
|
|
@ -48,7 +48,6 @@ export const hooks = {
|
|||
next();
|
||||
}
|
||||
catch (error) {
|
||||
console.log(error);
|
||||
if (!(error instanceof RateLimiterRes)) {
|
||||
throw error;
|
||||
}
|
||||
|
@ -142,6 +141,6 @@ export const hooks = {
|
|||
|
||||
export const mixin = (Flecks) => class FlecksWithGovernor extends Flecks {
|
||||
|
||||
governor = {}
|
||||
governor = {};
|
||||
|
||||
};
|
||||
|
|
|
@ -21,4 +21,4 @@ exports.HistoryRouter = function HistoryRouter({basename, children, history}) {
|
|||
navigationType: state.action,
|
||||
navigator: history,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
|
@ -8,7 +8,7 @@ const {version} = require('../package.json');
|
|||
|
||||
(async () => {
|
||||
const runtime = await __non_webpack_require__('@flecks/server/runtime');
|
||||
const {config, loadFlecks, stubs} = runtime;
|
||||
const {loadFlecks, stubs} = runtime;
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(`flecks server v${version}`);
|
||||
try {
|
||||
|
|
|
@ -62,6 +62,7 @@ export const createHttpServer = async (flecks) => {
|
|||
}
|
||||
routeMiddleware(req, res, (error) => {
|
||||
if (error) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(error);
|
||||
res.status(error.code || 500).end(error.stack);
|
||||
return;
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
import {D} from '@flecks/core';
|
||||
|
||||
import {configSource, inlineConfig} from './config';
|
||||
import {createHttpServer} from './http';
|
||||
|
||||
const debug = D('@flecks/web/server');
|
||||
|
||||
export {configSource};
|
||||
|
||||
export const hooks = {
|
||||
|
|
Loading…
Reference in New Issue
Block a user