Skip to content
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

#185 into [email protected] 🧊 add new eslint #186

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from 7 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
26 changes: 0 additions & 26 deletions .eslintrc.js

This file was deleted.

9 changes: 9 additions & 0 deletions .husky/_/husky.sh
MiaInturi marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
echo "husky - DEPRECATED
Please remove the following two lines from $0:
#!/usr/bin/env sh
. \"\$(dirname -- \"\$0\")/_/husky.sh\"
They WILL FAIL in v10.0.0
"
3 changes: 0 additions & 3 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

if [ -f .emoji ]
then
branch=$(git symbolic-ref --short HEAD)
Expand Down
7 changes: 1 addition & 6 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

yarn lint-staged --no-stash
yarn unit-test --run
yarn build
yarn lint-staged --no-stash
2 changes: 2 additions & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
yarn unit-test --run
yarn build
7 changes: 4 additions & 3 deletions bin/bin.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#!/usr/bin/env node

const pleaseUpgradeNode = require('please-upgrade-node');
import pleaseUpgradeNode from 'please-upgrade-node';

const packageJson = require('../../package.json');
import packageJson from '../package.json';

pleaseUpgradeNode(packageJson);

const { cli } = require('./cli');
// eslint-disable-next-line import/first
import { cli } from './cli';

cli();

Expand Down
2 changes: 0 additions & 2 deletions bin/helpers/getMostSpecificPathFromError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export const getMostSpecificPathFromError = (error: z.ZodError): (string | numbe
currentMostSpecificPath = unionErrorMostSpecificPath;
}
}
// eslint-disable-next-line no-continue
continue;
}

Expand All @@ -20,7 +19,6 @@ export const getMostSpecificPathFromError = (error: z.ZodError): (string | numbe
if (issuePath.length > currentMostSpecificPath.length) {
currentMostSpecificPath = issuePath;
}
// eslint-disable-next-line no-continue
continue;
}

Expand Down
4 changes: 2 additions & 2 deletions bin/helpers/resolveConfigFilePath.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import fs from 'fs';
import path from 'path';
import fs from 'node:fs';
import path from 'node:path';

export const resolveConfigFilePath = (cliConfigFilePath?: string) => {
const appPath = process.cwd();
Expand Down
4 changes: 2 additions & 2 deletions bin/helpers/resolveExportsFromSourceCode.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export const resolveExportsFromSourceCode = (sourceCode: string) => {
// @ts-ignore
// @ts-expect-error: module is constructed
const moduleInstance = new module.constructor();
// eslint-disable-next-line no-underscore-dangle

moduleInstance._compile(sourceCode, '');
return moduleInstance.exports;
};
4 changes: 2 additions & 2 deletions bin/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const init = async (argv: MockServerConfigArgv) => {
try {
portSchema.parse(+port);
return true;
} catch (error: any) {
} catch {
return 'Invalid port value';
}
}
Expand Down Expand Up @@ -83,7 +83,7 @@ export const init = async (argv: MockServerConfigArgv) => {

await createTemplate({ ...argv, ...response });
const userAgent = process.env.npm_config_user_agent ?? '';
// eslint-disable-next-line no-nested-ternary

const packageManager = /pnpm/.test(userAgent)
? 'pnpm'
: /yarn/.test(userAgent)
Expand Down
14 changes: 0 additions & 14 deletions bin/templates/.eslintrc.js

This file was deleted.

7 changes: 7 additions & 0 deletions bin/templates/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { eslint } from '@siberiacancode/eslint';

export default eslint(
{
typescript: true
}
);
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe('routeConfigSchema: data resolving properties combinations', () => {
];
incorrectDataResolvingPropertiesCombinations.forEach(
(incorrectDataResolvingPropertiesCombination) => {
test(`Should return error on handle object with incorrect data resolving properties combination:\n${JSON.stringify(incorrectDataResolvingPropertiesCombination)}`, () => {
it(`Should return error on handle object with incorrect data resolving properties combination:\n${JSON.stringify(incorrectDataResolvingPropertiesCombination)}`, () => {
const parseResult = routeConfigSchema.safeParse(
incorrectDataResolvingPropertiesCombination
);
Expand All @@ -30,7 +30,7 @@ describe('routeConfigSchema: data resolving properties combinations', () => {
];
correctDataResolvingPropertiesCombinations.forEach(
(correctDataResolvingPropertiesCombination) => {
test(`Should pass object with correct data resolving properties combination:\n${JSON.stringify(correctDataResolvingPropertiesCombination)}`, () => {
it(`Should pass object with correct data resolving properties combination:\n${JSON.stringify(correctDataResolvingPropertiesCombination)}`, () => {
const parseResult = routeConfigSchema.safeParse(correctDataResolvingPropertiesCombination);
expect(parseResult.success).toBe(true);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe('routeConfigSchema: data resolving properties combinations', () => {
];
incorrectDataResolvingPropertiesCombinations.forEach(
(incorrectDataResolvingPropertiesCombination) => {
test(`Should return error on handle object with incorrect data resolving properties combination:\n${JSON.stringify(incorrectDataResolvingPropertiesCombination)}`, () => {
it(`Should return error on handle object with incorrect data resolving properties combination:\n${JSON.stringify(incorrectDataResolvingPropertiesCombination)}`, () => {
const schema = routeConfigSchema('get');

const parseResult = schema.safeParse(incorrectDataResolvingPropertiesCombination);
Expand All @@ -31,7 +31,7 @@ describe('routeConfigSchema: data resolving properties combinations', () => {
];
correctDataResolvingPropertiesCombinations.forEach(
(correctDataResolvingPropertiesCombination) => {
test(`Should pass object with correct data resolving properties combination:\n${JSON.stringify(correctDataResolvingPropertiesCombination)}`, () => {
it(`Should pass object with correct data resolving properties combination:\n${JSON.stringify(correctDataResolvingPropertiesCombination)}`, () => {
const schema = routeConfigSchema('get');

const parseResult = schema.safeParse(correctDataResolvingPropertiesCombination);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { getMostSpecificPathFromError, getValidationMessageFromPath } from '../.
import { plainEntitySchema } from './entitiesSchema';

describe('plainEntitySchema: checkMode exclude', () => {
test('Should return correct error path for descriptor (top and property level) without required value', () => {
it('Should return correct error path for descriptor (top and property level) without required value', () => {
const incorrectTopLevelDescriptorBodyEntities = {
checkMode: 'equals'
};
Expand Down Expand Up @@ -35,7 +35,7 @@ describe('plainEntitySchema: checkMode exclude', () => {
}
});

test('Should return correct path for object (top and property level) with checkMode property', () => {
it('Should return correct path for object (top and property level) with checkMode property', () => {
const incorrectTopLevelObjectBodyEntities = {
checkMode: 'some random string'
};
Expand Down
28 changes: 28 additions & 0 deletions eslint.config.mjs
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

В папке bin/templates остался eslint config старого формата

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

кстати я совсем забыл про template для flat нужно будет добавить

Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { eslint } from '@siberiacancode/eslint';

export default eslint(
{
typescript: true
},
{
name: 'mock-config-server/md',
files: ['**/*.md'],
rules: {
'style/max-len': 'off'
}
},
{
name: 'mock-config-server/typescript',
rules: {
'node/prefer-global/process': 'off'
}
},
{
name: 'mock-config-server/views',
files: ['**/static/views/**/*.js'],
rules: {
'no-unused-vars': 'off',
'unused-imports/no-unused-vars': 'off'
}
}
);
14 changes: 0 additions & 14 deletions examples/.eslintrc.js

This file was deleted.

7 changes: 7 additions & 0 deletions examples/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { eslint } from '@siberiacancode/eslint';

export default eslint(
{
typescript: true
}
);
91 changes: 46 additions & 45 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,23 @@
}
],
"license": "MIT",
"homepage": "https://github.com/siberiacancode/mock-config-server",
"repository": {
"type": "git",
"url": "https://github.com/siberiacancode/mock-config-server.git"
},
"keywords": [
"server",
"fake",
"rest",
"api",
"graphql",
"database",
"mock",
"mocking",
"config",
"data"
],
"main": "dist/index.js",
"types": "./dist/index.d.ts",
"bin": {
Expand All @@ -39,86 +56,70 @@
"dist"
],
"engines": {
"node": ">=12"
"node": ">=12.22.0"
debabin marked this conversation as resolved.
Show resolved Hide resolved
},
"scripts": {
"prepublishOnly": "git diff --exit-code",
"prepare": "husky install && yarn build",
"prepare": "husky && yarn build",
"build:types": "tsc -p tsconfig.production.json && tsc-alias -p tsconfig.production.json",
"build:swc": "swc bin src index.ts -d dist --extensions .ts --copy-files --ignore **/*.test.ts --ignore bin/templates",
"build:copy-templates": "shx mkdir -p dist/bin/templates/ts && shx cp -r bin/templates/ts dist/bin/templates && shx mkdir -p dist/bin/templates/js && shx cp -r bin/templates/js dist/bin/templates",
"build": "shx rm -rf dist && yarn build:types && yarn build:swc && yarn build:copy-templates",
"start": "yarn build && node ./dist/bin/bin.js",
"dev": "nodemon --watch src --watch bin --watch mock-server.config.* -e js,ts,ejs --exec \"yarn start\"",
"unit-test": "vitest",
"lint": "eslint . --ext .ts --no-error-on-unmatched-pattern --fix",
"lint": "eslint . --fix",
"lint-inspector": "npx @eslint/config-inspector",
"stylelint": "stylelint \"src/static/**/*.css\" --fix",
"format": "prettier --write \"**/*.(ts|js)\"",
"pretty": "yarn format && yarn lint"
},
"lint-staged": {
"*.css": [
"stylelint --fix"
],
"*.js": [
"prettier --write"
],
"*.ts": [
"prettier --write",
"eslint --no-error-on-unmatched-pattern --fix"
]
},
"dependencies": {
"@types/body-parser": "^1.19.5",
"@types/express": "^4.17.21",
"@types/flat": "^5.0.5",
"@types/prompts": "^2.4.9",
"@types/yargs": "^17.0.32",
"@types/yargs": "^17.0.33",
"ansi-colors": "^4.1.3",
"body-parser": "^1.20.2",
"body-parser": "^1.20.3",
"ejs": "^3.1.10",
"esbuild": "^0.21.4",
"express": "^4.19.2",
"esbuild": "^0.21.5",
"express": "^4.21.1",
"express-urlrewrite": "^2.0.2",
"flat": "^5.0.2",
"graphql": "^16.8.1",
"graphql": "^16.9.0",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

У пакета graphql в package.json в свойстве engines.node написано "^12.22.0 || ^14.16.0 || ^16.0.0 || >=17.0.0" - это самое строгое свойство из всех пакетов которые мы используем. А нам, чтобы мы корректно работали, надо также указать самое строгое свойство в нашем engines.node, т.е. взять то свойство, которые у пакета graphql

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Я поставил сразу 14, что думаешь ?

"please-upgrade-node": "^3.2.0",
"prompts": "^2.4.2",
"yargs": "^17.7.2",
"zod": "^3.23.8"
},
"devDependencies": {
"@siberiacancode/eslint": "^1.1.1",
"@siberiacancode/eslint": "^2.3.0",
"@siberiacancode/prettier": "^1.1.1",
"@siberiacancode/stylelint": "^1.1.1",
"@siberiacancode/vitest": "^1.2.3",
"@swc/cli": "^0.3.12",
"@swc/core": "^1.5.24",
"@siberiacancode/vitest": "^1.2.4",
"@swc/cli": "^0.4.0",
"@swc/core": "^1.7.36",
"@types/supertest": "^6.0.2",
"husky": "^9.0.11",
"lint-staged": "^15.2.5",
"nodemon": "^3.1.2",
"husky": "^9.1.6",
"lint-staged": "^15.2.10",
"nodemon": "^3.1.7",
"shx": "^0.3.4",
"style-loader": "^4.0.0",
"supertest": "^7.0.0",
"tsc-alias": "^1.8.10",
"typescript": "^5.4.5"
"typescript": "^5.6.3"
},
"homepage": "https://github.com/siberiacancode/mock-config-server",
"repository": {
"type": "git",
"url": "https://github.com/siberiacancode/mock-config-server.git"
},
"keywords": [
"server",
"fake",
"REST",
"rest",
"API",
"api",
"mock",
"mocking",
"config",
"data"
]
"lint-staged": {
"*.css": [
"stylelint --fix"
],
"*.js": [
"prettier --write"
],
"*.ts": [
"prettier --write",
"eslint --no-error-on-unmatched-pattern --fix"
]
}
}
Loading