Skip to content

Commit 671cfcd

Browse files
Merge pull request #1240 from opencomponents/last-ts
Refactor the rest of the remaining src file to TypeScript
2 parents 26ce7bd + bfac958 commit 671cfcd

Some content is hidden

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

41 files changed

+1119
-825
lines changed

.eslintrc.json

Lines changed: 6 additions & 192 deletions
Original file line numberDiff line numberDiff line change
@@ -15,238 +15,52 @@
1515
"sourceType": "module"
1616
},
1717
"rules": {
18-
"accessor-pairs": "error",
19-
"array-bracket-spacing": "off",
20-
"array-callback-return": "off",
21-
"arrow-body-style": "error",
22-
"arrow-parens": "off",
23-
"arrow-spacing": [
24-
"error",
25-
{
26-
"after": true,
27-
"before": true
28-
}
29-
],
30-
"block-scoped-var": "off",
31-
"block-spacing": "off",
32-
"brace-style": "off",
33-
"callback-return": "off",
34-
"camelcase": "off",
35-
"capitalized-comments": "off",
18+
"@typescript-eslint/no-unused-vars": "error",
19+
"@typescript-eslint/no-explicit-any": "off",
20+
"@typescript-eslint/no-non-null-assertion": "off",
21+
"@typescript-eslint/explicit-module-boundary-types": "off",
22+
"@typescript-eslint/ban-ts-comment": "off",
3623
"class-methods-use-this": "error",
37-
"comma-dangle": "off",
38-
"comma-spacing": "off",
39-
"comma-style": "off",
40-
"complexity": "off",
41-
"computed-property-spacing": "off",
42-
"consistent-return": "off",
43-
"consistent-this": "off",
44-
"curly": "off",
4524
"default-case": "error",
46-
"dot-location": ["error", "property"],
47-
"dot-notation": "off",
48-
"eol-last": ["error", "always"],
49-
"eqeqeq": "off",
50-
"func-call-spacing": "off",
5125
"func-name-matching": "error",
52-
"func-names": "off",
53-
"func-style": "off",
54-
"generator-star-spacing": "error",
55-
"global-require": "off",
56-
"guard-for-in": "off",
57-
"handle-callback-err": "off",
58-
"id-blacklist": "error",
59-
"id-length": "off",
60-
"id-match": "error",
61-
"indent": ["error", 2],
62-
"init-declarations": "off",
63-
"jsx-quotes": "error",
64-
"key-spacing": "off",
65-
"keyword-spacing": "off",
66-
"line-comment-position": "off",
67-
"linebreak-style": "off",
68-
"lines-around-comment": "off",
69-
"lines-around-directive": "off",
70-
"max-depth": "off",
71-
"max-len": "off",
72-
"max-lines": "off",
7326
"max-nested-callbacks": "error",
74-
"max-params": "off",
75-
"max-statements": "off",
76-
"max-statements-per-line": "off",
77-
"multiline-ternary": "off",
78-
"new-parens": "error",
79-
"newline-after-var": "off",
80-
"newline-before-return": "off",
81-
"newline-per-chained-call": "off",
8227
"no-alert": "error",
8328
"no-array-constructor": "error",
84-
"no-await-in-loop": "error",
85-
"no-bitwise": "off",
8629
"no-caller": "error",
87-
"no-catch-shadow": "off",
88-
"no-compare-neg-zero": "error",
89-
"no-confusing-arrow": "off",
90-
"no-continue": "off",
9130
"no-console": "warn",
92-
"no-div-regex": "error",
9331
"no-duplicate-imports": "error",
94-
"no-else-return": "off",
9532
"no-empty": [
9633
"error",
9734
{
9835
"allowEmptyCatch": true
9936
}
10037
],
101-
"no-empty-function": "off",
102-
"no-eq-null": "off",
103-
"no-eval": "off",
10438
"no-extend-native": "error",
105-
"no-extra-bind": "error",
10639
"no-extra-label": "error",
107-
"no-extra-parens": "off",
108-
"no-floating-decimal": "error",
109-
"no-extra-boolean-cast": "warn",
110-
"no-implicit-coercion": [
111-
"error",
112-
{
113-
"boolean": false,
114-
"number": false,
115-
"string": false
116-
}
117-
],
11840
"no-implicit-globals": "error",
11941
"no-implied-eval": "error",
120-
"no-inline-comments": "off",
121-
"no-inner-declarations": ["error", "functions"],
122-
"no-invalid-this": "off",
12342
"no-iterator": "error",
12443
"no-label-var": "error",
12544
"no-labels": "error",
12645
"no-lone-blocks": "error",
127-
"no-lonely-if": "off",
12846
"no-loop-func": "error",
129-
"no-magic-numbers": "off",
130-
"no-mixed-operators": "off",
131-
"no-mixed-requires": "off",
132-
"no-multi-assign": "off",
133-
"no-multi-spaces": "off",
13447
"no-multi-str": "error",
135-
"no-multiple-empty-lines": "off",
136-
"no-native-reassign": "error",
137-
"no-negated-condition": "off",
138-
"no-negated-in-lhs": "error",
139-
"no-nested-ternary": "off",
14048
"no-new": "error",
141-
"no-new-func": "off",
14249
"no-new-object": "error",
143-
"no-new-require": "error",
14450
"no-new-wrappers": "error",
14551
"no-octal-escape": "error",
146-
"no-param-reassign": "off",
147-
"no-path-concat": "error",
148-
"no-plusplus": "off",
149-
"no-process-env": "off",
150-
"no-process-exit": "off",
15152
"no-proto": "error",
152-
"no-prototype-builtins": "off",
15353
"no-restricted-globals": "error",
15454
"no-restricted-imports": "error",
155-
"no-restricted-modules": "error",
15655
"no-restricted-properties": "error",
15756
"no-restricted-syntax": "error",
158-
"no-return-assign": "off",
15957
"no-return-await": "error",
16058
"no-script-url": "error",
161-
"no-self-compare": "off",
162-
"no-sequences": "off",
163-
"no-shadow": "off",
164-
"no-shadow-restricted-names": "off",
165-
"no-spaced-func": "off",
166-
"no-sync": "off",
167-
"no-tabs": "off",
168-
"no-template-curly-in-string": "off",
169-
"no-ternary": "off",
170-
"no-throw-literal": "off",
171-
"no-trailing-spaces": "error",
172-
"no-undef-init": "off",
173-
"no-undefined": "off",
174-
"no-undef": "off",
175-
"no-underscore-dangle": "off",
176-
"no-unmodified-loop-condition": "off",
177-
"no-unneeded-ternary": "off",
178-
"no-unused-expressions": "off",
179-
"no-unused-vars": "error",
180-
"no-use-before-define": "off",
181-
"no-useless-call": "off",
182-
"no-useless-computed-key": "error",
183-
"no-useless-concat": "off",
18459
"no-useless-constructor": "error",
185-
"no-useless-escape": "off",
186-
"no-useless-rename": "error",
18760
"no-useless-return": "error",
188-
"no-var": "error",
189-
"no-void": "off",
19061
"no-warning-comments": "error",
191-
"no-whitespace-before-property": "error",
192-
"no-with": "error",
193-
"nonblock-statement-body-position": ["error", "any"],
194-
"object-curly-newline": "off",
195-
"object-curly-spacing": "off",
196-
"object-property-newline": "off",
197-
"object-shorthand": "off",
198-
"one-var": "off",
199-
"one-var-declaration-per-line": "off",
200-
"operator-assignment": "off",
201-
"operator-linebreak": "off",
202-
"padded-blocks": "off",
203-
"prefer-arrow-callback": "error",
204-
"prefer-const": "error",
205-
"prefer-destructuring": [
206-
"error",
207-
{
208-
"array": false,
209-
"object": false
210-
}
211-
],
212-
"prefer-numeric-literals": "error",
21362
"prefer-promise-reject-errors": "error",
214-
"prefer-reflect": "off",
215-
"prefer-rest-params": "off",
216-
"prefer-spread": "off",
217-
"prefer-template": "off",
218-
"quote-props": "off",
219-
"quotes": "off",
220-
"radix": ["error", "always"],
22163
"require-await": "error",
222-
"require-jsdoc": "off",
223-
"rest-spread-spacing": "error",
224-
"semi": ["error", "always"],
225-
"semi-spacing": "off",
226-
"sort-imports": "error",
227-
"sort-keys": "off",
228-
"sort-vars": "off",
229-
"space-before-blocks": "off",
230-
"space-before-function-paren": "off",
231-
"space-in-parens": "off",
232-
"space-infix-ops": "off",
233-
"spaced-comment": "off",
234-
"strict": "off",
235-
"symbol-description": "error",
236-
"template-curly-spacing": ["error", "never"],
237-
"template-tag-spacing": "error",
238-
"unicode-bom": ["error", "never"],
239-
"valid-jsdoc": "off",
240-
"valid-typeof": [
241-
"error",
242-
{
243-
"requireStringLiterals": false
244-
}
245-
],
246-
"vars-on-top": "off",
247-
"wrap-iife": "off",
248-
"wrap-regex": "off",
249-
"yield-star-spacing": "error",
250-
"yoda": "off"
64+
"symbol-description": "error"
25165
}
25266
}

package.json

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,26 +44,38 @@
4444
"oc"
4545
],
4646
"devDependencies": {
47+
"@types/accept-language-parser": "^1.5.2",
48+
"@types/async": "^3.2.8",
49+
"@types/colors": "1.2.1",
50+
"@types/cross-spawn": "^6.0.2",
4751
"@types/errorhandler": "1.5.0",
4852
"@types/express": "4.17.13",
53+
"@types/fs-extra": "^9.0.13",
54+
"@types/livereload": "^0.9.1",
55+
"@types/lodash": "^4.14.175",
4956
"@types/morgan": "1.9.3",
5057
"@types/multer": "1.4.7",
51-
"@types/colors": "1.2.1",
5258
"@types/node": "16.10.1",
59+
"@types/parse-author": "^2.0.1",
60+
"@types/read": "0.0.29",
61+
"@types/response-time": "^2.3.5",
5362
"@types/semver": "7.3.8",
63+
"@types/targz": "^1.0.1",
5464
"@types/yargs": "17.0.3",
5565
"@typescript-eslint/eslint-plugin": "4.32.0",
5666
"@typescript-eslint/parser": "4.32.0",
5767
"chai": "4.3.4",
5868
"chalk": "4.1.2",
69+
"eslint": "^7.32.0",
70+
"eslint-config-prettier": "^8.3.0",
71+
"eslint-plugin-prettier": "^4.0.0",
5972
"glob": "7.2.0",
6073
"husky": "7.0.2",
6174
"injectr": "0.5.1",
6275
"lint-staged": "11.1.2",
6376
"minimist": "1.2.5",
6477
"mocha": "9.1.2",
6578
"node-emoji": "1.11.0",
66-
"oc-template-es6-compiler": "1.1.10",
6779
"prettier-eslint-cli": "5.0.1",
6880
"semver-sort": "0.0.4",
6981
"simple-git": "2.45.1",
@@ -97,12 +109,13 @@
97109
"oc-empty-response-handler": "1.0.1",
98110
"oc-get-unix-utc-timestamp": "1.0.3",
99111
"oc-s3-storage-adapter": "1.1.6",
100-
"oc-storage-adapters-utils": "1.0.3",
101-
"oc-template-es6": "1.0.3",
102-
"oc-template-handlebars": "6.0.21",
103-
"oc-template-handlebars-compiler": "6.2.15",
104-
"oc-template-jade": "7.0.2",
105-
"oc-template-jade-compiler": "7.0.3",
112+
"oc-storage-adapters-utils": "1.0.4",
113+
"oc-template-es6": "1.0.5",
114+
"oc-template-es6-compiler": "1.1.12",
115+
"oc-template-handlebars": "6.0.23",
116+
"oc-template-handlebars-compiler": "6.2.17",
117+
"oc-template-jade": "7.0.4",
118+
"oc-template-jade-compiler": "7.0.5",
106119
"open": "8.2.1",
107120
"parse-author": "2.0.0",
108121
"read": "1.0.7",
Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,30 @@
1-
'use strict';
1+
import fs from 'fs-extra';
2+
import targz from 'targz';
23

3-
const fs = require('fs-extra');
4-
const targz = require('targz');
5-
const _ = require('lodash');
4+
import * as clean from './clean';
5+
import getComponentsByDir from './get-components-by-dir';
6+
import initTemplate from './init-template';
7+
import isTemplateLegacy from '../../utils/is-template-legacy';
8+
import mock from './mock';
9+
import packageComponents from './package-components';
10+
import strings from '../../resources';
11+
import * as validator from '../../registry/domain/validators';
12+
import { Local } from '../../types';
613

7-
const clean = require('./clean');
8-
const getComponentsByDir = require('./get-components-by-dir').default;
9-
const initTemplate = require('./init-template').default;
10-
const isTemplateLegacy = require('../../utils/is-template-legacy').default;
11-
const mock = require('./mock').default;
12-
const packageComponents = require('./package-components');
13-
const strings = require('../../resources').default;
14-
const validator = require('../../registry/domain/validators');
15-
16-
module.exports = function() {
14+
export default function local(): Local {
1715
return {
1816
clean,
19-
cleanup: function(compressedPackagePath, callback) {
17+
cleanup(compressedPackagePath: string, callback) {
2018
return fs.unlink(compressedPackagePath, callback);
2119
},
22-
compress: function(input, output, callback) {
20+
compress(input, output, callback) {
2321
return targz.compress(
2422
{
2523
src: input,
2624
dest: output,
2725
tar: {
28-
map: function(file) {
29-
return _.extend(file, {
26+
map: function (file) {
27+
return Object.assign(file, {
3028
name: `_package/${file.name}`
3129
});
3230
}
@@ -36,11 +34,11 @@ module.exports = function() {
3634
);
3735
},
3836
getComponentsByDir: getComponentsByDir(),
39-
init: function(options, callback) {
37+
init(options, callback) {
4038
const { componentName, logger } = options;
4139
let { templateType } = options;
4240
if (!validator.validateComponentName(componentName)) {
43-
return callback('name not valid');
41+
return callback('name not valid', undefined as any);
4442
}
4543

4644
// LEGACY TEMPLATES WARNING
@@ -59,17 +57,17 @@ module.exports = function() {
5957
}
6058
try {
6159
initTemplate(
62-
_.extend(options, {
60+
Object.assign(options, {
6361
templateType,
6462
compiler: `${templateType}-compiler`
6563
}),
66-
callback
64+
callback as any
6765
);
6866
} catch (e) {
69-
return callback('template type not valid');
67+
return callback('template type not valid', undefined as any);
7068
}
7169
},
7270
mock: mock(),
7371
package: packageComponents()
7472
};
75-
};
73+
}

0 commit comments

Comments
 (0)