strictr 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -2
- package/lib/check.js +18 -1
- package/lib/check.js.map +1 -1
- package/lib/functions/add.use.strict.d.ts +3 -0
- package/lib/functions/add.use.strict.js +48 -0
- package/lib/functions/add.use.strict.js.map +1 -0
- package/lib/strictr.js +1 -0
- package/lib/strictr.js.map +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -30,9 +30,10 @@ Check for missing strict statement in files.
|
|
|
30
30
|
Use .strictr.json config file to override default settings.
|
|
31
31
|
|
|
32
32
|
Options:
|
|
33
|
-
-V, --version output the version number
|
|
33
|
+
-V, --version output the version number
|
|
34
|
+
-a, --add Add missing strict statements (default: false)
|
|
34
35
|
-c, --config <config> Alternative config file (must be .json) (default: ".strictr.json")
|
|
35
|
-
-h, --help display help for command
|
|
36
|
+
-h, --help display help for command
|
|
36
37
|
```
|
|
37
38
|
|
|
38
39
|
## run strictr check
|
package/lib/check.js
CHANGED
|
@@ -35,10 +35,12 @@ const get_files_listing_1 = __importDefault(require("./functions/get.files.listi
|
|
|
35
35
|
const convert_files_to_objects_1 = __importDefault(require("./functions/convert.files.to.objects"));
|
|
36
36
|
const missing_strict_statement_1 = __importDefault(require("./functions/missing.strict.statement"));
|
|
37
37
|
const get_table_from_file_objects_1 = __importDefault(require("./functions/get.table.from.file.objects"));
|
|
38
|
+
const add_use_strict_1 = __importDefault(require("./functions/add.use.strict"));
|
|
38
39
|
exports.default = {
|
|
39
40
|
run(commander) {
|
|
40
41
|
console.clear();
|
|
41
|
-
const options = _.pick(commander, ['config']);
|
|
42
|
+
const options = _.pick(commander, ['config', 'add']);
|
|
43
|
+
const { add = false } = options;
|
|
42
44
|
const root = process.cwd();
|
|
43
45
|
const config = (0, get_config_1.default)(root, options === null || options === void 0 ? void 0 : options.config);
|
|
44
46
|
const { srcFolderName, testFolderName } = config;
|
|
@@ -63,6 +65,21 @@ exports.default = {
|
|
|
63
65
|
}
|
|
64
66
|
else
|
|
65
67
|
console.log('\nNo test files are missing the strict statement.');
|
|
68
|
+
if (add) {
|
|
69
|
+
if (_.isEmpty(srcFiles) && _.isEmpty(testFiles)) {
|
|
70
|
+
console.log('\nAdd is set to true, but there is nothing to add.');
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
console.log("\nAdd is set to true. Adding 'use strict'; where I can...\n");
|
|
74
|
+
_.each(srcFiles, (file) => {
|
|
75
|
+
(0, add_use_strict_1.default)(file);
|
|
76
|
+
});
|
|
77
|
+
console.log('');
|
|
78
|
+
_.each(testFiles, (file) => {
|
|
79
|
+
(0, add_use_strict_1.default)(file);
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
66
83
|
console.log('\n');
|
|
67
84
|
}
|
|
68
85
|
};
|
package/lib/check.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"check.js","sourceRoot":"","sources":["../src/check.ts"],"names":[],"mappings":";AACA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEb,2CAA6B;AAE7B,0CAA4B;AAE5B,wEAA+C;AAC/C,4EAAmD;AACnD,sFAA4D;AAC5D,oGAAyE;AACzE,oGAA0E;AAC1E,0GAA8E;
|
|
1
|
+
{"version":3,"file":"check.js","sourceRoot":"","sources":["../src/check.ts"],"names":[],"mappings":";AACA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEb,2CAA6B;AAE7B,0CAA4B;AAE5B,wEAA+C;AAC/C,4EAAmD;AACnD,sFAA4D;AAC5D,oGAAyE;AACzE,oGAA0E;AAC1E,0GAA8E;AAC9E,gFAAsD;AAEtD,kBAAe;IACd,GAAG,CAAC,SAAc;QACjB,OAAO,CAAC,KAAK,EAAE,CAAC;QAEhB,MAAM,OAAO,GAAQ,CAAC,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,QAAQ,E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AC;QACxD,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE;YAC1B,OAAO,CAAC,GAAG,CAAC,4CAA4C,CAAC,CAAC;YAC1D,OAAO,CAAC,GAAG,CAAC,IAAA,qCAAuB,EAAC,IAAA,kCAAqB,EAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;SAClF;;YAAM,OAAO,CAAC,GAAG,CAAC,mDAAmD,CAAC,CAAC;QAExE,IAAI,GAAG,EAAE;YACR,IAAI,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE;gBAChD,OAAO,CAAC,GAAG,CAAC,oDAAoD,CAAC,CAAC;aAClE;iBAAM;gBACN,OAAO,CAAC,GAAG,CAAC,6DAA6D,CAAC,CAAC;gBAE3E,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,EAAE;oBACzB,IAAA,wBAAY,EAAC,IAAI,CAAC,CAAC;gBACpB,CAAC,CAAC,CAAC;gBACH,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;gBAChB,CAAC,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,EAAE;oBAC1B,IAAA,wBAAY,EAAC,IAAI,CAAC,CAAC;gBACpB,CAAC,CAAC,CAAC;aACH;SACD;QAED,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACnB,CAAC;CACD,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
20
|
+
if (mod && mod.__esModule) return mod;
|
|
21
|
+
var result = {};
|
|
22
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
23
|
+
__setModuleDefault(result, mod);
|
|
24
|
+
return result;
|
|
25
|
+
};
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
const fs = __importStar(require("fs"));
|
|
28
|
+
const lodash_1 = require("lodash");
|
|
29
|
+
const addUseStrict = (path) => {
|
|
30
|
+
if (!fs.existsSync(path))
|
|
31
|
+
return console.log(`\nERROR: ${path} does not exist.`);
|
|
32
|
+
const content = fs.readFileSync(path, 'utf-8');
|
|
33
|
+
let lines = (0, lodash_1.split)((0, lodash_1.trim)(content), '\n');
|
|
34
|
+
const one = (0, lodash_1.trim)((0, lodash_1.first)(lines));
|
|
35
|
+
const hasBang = (0, lodash_1.startsWith)(one, '#!/');
|
|
36
|
+
let allButFirst = hasBang
|
|
37
|
+
? (0, lodash_1.tail)(lines)
|
|
38
|
+
: lines;
|
|
39
|
+
allButFirst = (0, lodash_1.split)((0, lodash_1.trim)((0, lodash_1.join)(allButFirst, '\n')), '\n');
|
|
40
|
+
lines = ["'use strict';", '', ...allButFirst];
|
|
41
|
+
lines = hasBang
|
|
42
|
+
? [one, ...lines]
|
|
43
|
+
: lines;
|
|
44
|
+
fs.writeFileSync(path, (0, lodash_1.join)(lines, '\n'), 'utf-8');
|
|
45
|
+
console.log(" - Added 'use strict'; to", path, '...');
|
|
46
|
+
};
|
|
47
|
+
exports.default = addUseStrict;
|
|
48
|
+
//# sourceMappingURL=add.use.strict.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add.use.strict.js","sourceRoot":"","sources":["../../src/functions/add.use.strict.ts"],"names":[],"mappings":";AACA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;AAEb,uCAAyB;AACzB,mCAAkE;AAElE,MAAM,YAAY,GAAG,CAAC,IAAY,EAAQ,EAAE;IAC3C,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,OAAO,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,kBAAkB,CAAC,CAAC;IAEjF,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC/C,IAAI,KAAK,GAAa,IAAA,cAAK,EAAC,IAAA,aAAI,EAAC,OAAO,CAAC,EAAE,IAAI,CAAC,CAAC;IAEjD,MAAM,GAAG,GAAW,IAAA,aAAI,EAAC,IAAA,cAAK,EAAC,KAAK,CAAC,CAAC,CAAC;IACvC,MAAM,OAAO,GAAG,IAAA,mBAAU,EAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAEvC,IAAI,WAAW,GAAG,OAAO;QACxB,CAAC,CAAC,IAAA,aAAI,EAAC,KAAK,CAAC;QACb,CAAC,CAAC,KAAK,CAAC;IACT,WAAW,GAAG,IAAA,cAAK,EAAC,IAAA,aAAI,EAAC,IAAA,aAAI,EAAC,WAAW,EAAE,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IACzD,KAAK,GAAG,CAAC,eAAe,EAAE,EAAE,EAAE,GAAG,WAAW,CAAC,CAAC;IAE9C,KAAK,GAAG,OAAO;QACd,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC;QACjB,CAAC,CAAC,KAAK,CAAC;IAET,EAAE,CAAC,aAAa,CAAC,IAAI,EAAE,IAAA,aAAI,EAAC,KAAK,EAAE,IAAI,CAAC,EAAE,OAAO,CAAC,CAAC;IACnD,OAAO,CAAC,GAAG,CAAC,2BAA2B,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;AACvD,CAAC,CAAC;AAEF,kBAAe,YAAY,CAAC"}
|
package/lib/strictr.js
CHANGED
|
@@ -11,6 +11,7 @@ const packageJson = require('../package.json');
|
|
|
11
11
|
commander
|
|
12
12
|
.version(packageJson.version)
|
|
13
13
|
.description('Check for missing strict statement in files.\nUse .strictr.json config file to override default settings.')
|
|
14
|
+
.option('-a, --add', 'Add missing strict statements', false)
|
|
14
15
|
.option('-c, --config <config>', 'Alternative config file (must be .json)', '.strictr.json')
|
|
15
16
|
.parse(process.argv);
|
|
16
17
|
const options = commander.opts();
|
package/lib/strictr.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"strictr.js","sourceRoot":"","sources":["../src/strictr.ts"],"names":[],"mappings":";AACA,YAAY,CAAC;;;;;
|
|
1
|
+
{"version":3,"file":"strictr.js","sourceRoot":"","sources":["../src/strictr.ts"],"names":[],"mappings":";AACA,YAAY,CAAC;;;;;AAab,yCAAkC;AAClC,oDAA4B;AAE5B,MAAM,SAAS,GAAQ,IAAI,mBAAO,EAAE,CAAC;AACrC,MAAM,WAAW,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAE/C,SAAS;KACP,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC;KAC5B,WAAW,CAAC,2GAA2G,CAAC;KACxH,MAAM,CAAC,WAAW,EAAE,+BAA+B,EAAE,KAAK,CAAC;KAC3D,MAAM,CAAC,uBAAuB,EAAE,yCAAyC,EAAE,eAAe,CAAC;KAC3F,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAEtB,MAAM,OAAO,GAAG,SAAS,CAAC,IAAI,EAAE,CAAC;AACjC,IAAI,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI,CAAA;IAAE,OAAO,CAAC,GAAG,CAAC,iEAAiE,CAAC,CAAC;AAEnG,eAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "strictr",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "strict statement checker",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=16.0.0"
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"types": "./lib/strictr.d.ts",
|
|
10
10
|
"scripts": {
|
|
11
11
|
"go": "ts-node ./src/strictr.ts",
|
|
12
|
-
"all": "
|
|
12
|
+
"all": "pnpm i & tsc & pnpm clean & pnpm format & pnpm build & pnpm test & pnpm docs",
|
|
13
13
|
"build": "del /S /Q lib\\* && tsc",
|
|
14
14
|
"build:watch": "tsc --watch",
|
|
15
15
|
"lint": "tslint -p tsconfig.json",
|
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
"imports": "tslint --project tsconfig.json --config tslint-imports.json",
|
|
20
20
|
"fiximports": "tslint --project tsconfig.json --config tslint-imports.json --fix --project",
|
|
21
21
|
"format": "prettier --write \"src/**/*.ts\"",
|
|
22
|
-
"up": "
|
|
23
|
-
"upgrade": "
|
|
24
|
-
"latest": "
|
|
22
|
+
"up": "pnpm up -i",
|
|
23
|
+
"upgrade": "pnpm up",
|
|
24
|
+
"latest": "pnpm up -i -L"
|
|
25
25
|
},
|
|
26
26
|
"preferGlobal": true,
|
|
27
27
|
"bin": {
|