Skip to content

Commit f10d2a9

Browse files
authored
fix: airbnb + prettier lint; and update tests (#542)
* chore: airbnb + prettier lint & fmt; * chore: del eslintcache * fix: convert IncomingForm to class * fix: convert File to class, fmt more * chore: lower devDeps, simplify test paths resolving * fix: method names, missing hashish module, one step closer * fix: organize multipart parser * chore: use self instead of this * chore: cleanup * fix ports and call done in _transform() method of multipart parser * make tests pass, add todo comments Signed-off-by: Charlike Mike Reagent <opensource@tunnckocore.com>
1 parent a5db8d9 commit f10d2a9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+3553
-1498
lines changed

.eslintignore

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
CHANGELOG.md
2+
README.md
3+
*.d.ts
4+
recipes
5+
patches
6+
7+
test-legacy
8+
*.js.snap
9+
*.tsbuildinfo
10+
.cache
11+
.*cache
12+
*.cache
13+
14+
# TODO: lint
15+
example
16+
benchmark
17+
18+
# Build environment
19+
dist
20+
21+
# Package managers lockfiles
22+
package-lock.json
23+
shrinkwrap.json
24+
pnpm-lock.json
25+
26+
# Logs
27+
logs
28+
*.log
29+
*~
30+
31+
# Runtime data
32+
pids
33+
*.pid
34+
*.seed
35+
*.pid.lock
36+
37+
# Directory for instrumented libs generated by jscoverage/JSCover
38+
lib-cov
39+
40+
# Coverage directory used by tools like istanbul
41+
coverage
42+
43+
# nyc test coverage
44+
.nyc_output
45+
46+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
47+
.grunt
48+
49+
# Bower dependency directory (https://bower.io/)
50+
bower_components
51+
52+
# node-waf configuration
53+
.lock-wscript
54+
55+
# Compiled binary addons (https://nodejs.org/api/addons.html)
56+
build/Release
57+
58+
# Dependency directories
59+
node_modules/
60+
jspm_packages/
61+
62+
# TypeScript v1 declaration files
63+
typings/
64+
65+
# Optional npm cache directory
66+
.npm
67+
68+
# Optional eslint cache
69+
.eslintcache
70+
71+
# Optional REPL history
72+
.node_repl_history
73+
74+
# Output of 'npm pack'
75+
*.tgz
76+
77+
# Yarn Integrity file
78+
.yarn-integrity
79+
80+
# dotenv environment variables file
81+
.env
82+
83+
# next.js build output
84+
.next

.eslintrc.js

+176
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
'use strict';
2+
3+
const airbnbBase = require('eslint-config-airbnb-base');
4+
5+
// eslint-disable-next-line import/no-dynamic-require
6+
const bestPractices = require(airbnbBase.extends[0]);
7+
8+
const ignoredProps = bestPractices.rules[
9+
'no-param-reassign'
10+
][1].ignorePropertyModificationsFor.concat(
11+
'err',
12+
'x',
13+
'_',
14+
'opts',
15+
'options',
16+
'settings',
17+
'config',
18+
'cfg',
19+
);
20+
21+
// Additional rules that are specific and overiding previous
22+
const additionalChanges = {
23+
strict: 'off',
24+
25+
// Enforce using named functions when regular function is used,
26+
// otherwise use arrow functions
27+
'func-names': ['error', 'always'],
28+
// Always use parens (for consistency).
29+
// https://eslint.org/docs/rules/arrow-parens
30+
'arrow-parens': ['error', 'always', { requireForBlockBody: true }],
31+
'prefer-arrow-callback': [
32+
'error',
33+
{ allowNamedFunctions: true, allowUnboundThis: true },
34+
],
35+
// http://eslint.org/docs/rules/max-params
36+
'max-params': ['error', { max: 3 }],
37+
// http://eslint.org/docs/rules/max-statements
38+
'max-statements': ['error', { max: 20 }],
39+
// http://eslint.org/docs/rules/max-statements-per-line
40+
'max-statements-per-line': ['error', { max: 1 }],
41+
// http://eslint.org/docs/rules/max-nested-callbacks
42+
'max-nested-callbacks': ['error', { max: 4 }],
43+
// http://eslint.org/docs/rules/max-depth
44+
'max-depth': ['error', { max: 4 }],
45+
// enforces no braces where they can be omitted
46+
// https://eslint.org/docs/rules/arrow-body-style
47+
// Never enable for object literal.
48+
'arrow-body-style': [
49+
'error',
50+
'as-needed',
51+
{ requireReturnForObjectLiteral: false },
52+
],
53+
// Allow functions to be use before define because:
54+
// 1) they are hoisted,
55+
// 2) because ensure read flow is from top to bottom
56+
// 3) logically order of the code.
57+
// 4) the only addition is 'typedefs' option, see overrides for TS files
58+
'no-use-before-define': [
59+
'error',
60+
{
61+
functions: false,
62+
classes: true,
63+
variables: true,
64+
},
65+
],
66+
// Same as AirBnB, but adds `opts`, `options`, `x` and `err` to exclusions!
67+
// disallow reassignment of function parameters
68+
// disallow parameter object manipulation except for specific exclusions
69+
// rule: https://eslint.org/docs/rules/no-param-reassign.html
70+
'no-param-reassign': [
71+
'error',
72+
{
73+
props: true,
74+
ignorePropertyModificationsFor: ignoredProps,
75+
},
76+
],
77+
78+
// disallow declaration of variables that are not used in the code
79+
'no-unused-vars': [
80+
'error',
81+
{
82+
ignoreRestSiblings: true, // airbnb's default
83+
vars: 'all', // airbnb's default
84+
varsIgnorePattern: '^(?:$$|xx|_|__|[iI]gnor(?:e|ing|ed))',
85+
args: 'after-used', // airbnb's default
86+
argsIgnorePattern: '^(?:$$|xx|_|__|[iI]gnor(?:e|ing|ed))',
87+
88+
// catch blocks are handled by Unicorns
89+
caughtErrors: 'none',
90+
// caughtErrorsIgnorePattern: '^(?:$$|xx|_|__|[iI]gnor(?:e|ing|ed))',
91+
},
92+
],
93+
};
94+
95+
const importRules = {
96+
'import/namespace': ['error', { allowComputed: true }],
97+
'import/no-absolute-path': 'error',
98+
'import/no-webpack-loader-syntax': 'error',
99+
'import/no-self-import': 'error',
100+
101+
// Enable this sometime in the future when Node.js has ES2015 module support
102+
// 'import/no-cycle': 'error',
103+
104+
// Disabled as it doesn't work with TypeScript
105+
// 'import/newline-after-import': 'error',
106+
107+
'import/no-amd': 'error',
108+
'import/no-duplicates': 'error',
109+
110+
// Enable this sometime in the future when Node.js has ES2015 module support
111+
// 'import/unambiguous': 'error',
112+
113+
// Enable this sometime in the future when Node.js has ES2015 module support
114+
// 'import/no-commonjs': 'error',
115+
116+
// Looks useful, but too unstable at the moment
117+
// 'import/no-deprecated': 'error',
118+
119+
'import/no-extraneous-dependencies': 'off',
120+
'import/no-mutable-exports': 'error',
121+
'import/no-named-as-default-member': 'error',
122+
'import/no-named-as-default': 'error',
123+
124+
// Disabled because it's buggy and it also doesn't work with TypeScript
125+
// 'import/no-unresolved': [
126+
// 'error',
127+
// {
128+
// commonjs: true
129+
// }
130+
// ],
131+
132+
'import/order': 'error',
133+
'import/no-unassigned-import': [
134+
'error',
135+
{ allow: ['@babel/polyfill', '@babel/register'] },
136+
],
137+
138+
'import/prefer-default-export': 'off',
139+
140+
// Ensure more web-compat
141+
// ! note that it doesn't work in CommonJS
142+
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/extensions.md
143+
'import/extensions': 'off',
144+
145+
// ? Always use named exports. Enable?
146+
// 'import/no-default-export': 'error',
147+
148+
// ? enable?
149+
'import/exports-last': 'off',
150+
151+
// todo: Enable in future.
152+
// Ensures everything is tested (all exports should be used).
153+
// For cases when you don't want or can't test, add eslint-ignore comment!
154+
// see: https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-unused-modules.md
155+
'import/no-unused-modules': 'off',
156+
157+
'import/no-useless-path-segments': ['error', { noUselessIndex: false }],
158+
};
159+
160+
module.exports = {
161+
env: {
162+
es6: true,
163+
es2020: true,
164+
jest: true,
165+
node: true,
166+
commonjs: true,
167+
},
168+
extends: ['eslint:recommended', 'airbnb-base', 'plugin:prettier/recommended'],
169+
plugins: ['prettier'],
170+
rules: {
171+
'prettier/prettier': 'error',
172+
173+
...additionalChanges,
174+
...importRules,
175+
},
176+
};

.prettierignore

+97
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
CHANGELOG.md
2+
LICENSE
3+
LICENSE.md
4+
LICENSE*.md
5+
dist
6+
# fixture
7+
# fixtures
8+
# __fixture__
9+
# __fixtures__
10+
.gitkeep
11+
*.map
12+
*.lock
13+
.npmrc
14+
.yarnrc
15+
*.js.snap
16+
coverage
17+
*.ico
18+
*.png
19+
*.svg
20+
*.jpeg
21+
*.jpg
22+
23+
.*
24+
!.*rc.js
25+
!.verb*.md
26+
patches
27+
**/static/**/*.css
28+
29+
*.tsbuildinfo
30+
.cache
31+
.*cache
32+
*.cache
33+
34+
# Package managers lockfiles
35+
package-lock.json
36+
shrinkwrap.json
37+
pnpm-lock.json
38+
39+
# Logs
40+
logs
41+
*.log
42+
*~
43+
44+
# Runtime data
45+
pids
46+
*.pid
47+
*.seed
48+
*.pid.lock
49+
50+
# Directory for instrumented libs generated by jscoverage/JSCover
51+
lib-cov
52+
53+
# Coverage directory used by tools like istanbul
54+
coverage
55+
56+
# nyc test coverage
57+
.nyc_output
58+
59+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
60+
.grunt
61+
62+
# Bower dependency directory (https://bower.io/)
63+
bower_components
64+
65+
# node-waf configuration
66+
.lock-wscript
67+
68+
# Compiled binary addons (https://nodejs.org/api/addons.html)
69+
build/Release
70+
71+
# Dependency directories
72+
node_modules/
73+
jspm_packages/
74+
75+
# TypeScript v1 declaration files
76+
typings/
77+
78+
# Optional npm cache directory
79+
.npm
80+
81+
# Optional eslint cache
82+
.eslintcache
83+
84+
# Optional REPL history
85+
.node_repl_history
86+
87+
# Output of 'npm pack'
88+
*.tgz
89+
90+
# Yarn Integrity file
91+
.yarn-integrity
92+
93+
# dotenv environment variables file
94+
.env
95+
96+
# next.js build output
97+
.next

.prettierrc.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
'use strict';
2+
3+
module.exports = require( '@tunnckocore/prettier-config');

0 commit comments

Comments
 (0)