Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 3 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ const _gqlRules = require("./gqlRules");
const _noRenamedTranslationImport = require("./noRenamedTranslationImport");
const _noUnawaitedSkeletons = require("./noUnawaitedSkeletons");
const _oneTranslationImport = require("./oneTranslationImport");
const _noJestInProduction = require("./noJestInProduction");
const rules = {
"one-translation-import-per-file": _oneTranslationImport.oneTranslationImport,
"no-renamed-translation-import": _noRenamedTranslationImport.noRenamedTranslationImport,
"gql-objects": _gqlRules.gqlObjects,
"gql-operation-name": _gqlRules.gqlOperationName,
"cross-reference": _crossReference.crossReference,
"circular-dependency": _circularDependency.circularDependency,
"no-unawaited-skeletons": _noUnawaitedSkeletons.noUnawaitedSkeletons
"no-unawaited-skeletons": _noUnawaitedSkeletons.noUnawaitedSkeletons,
"no-jest-in-production": _noJestInProduction.noJestInProduction
};
48 changes: 48 additions & 0 deletions dist/noJestInProduction/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "noJestInProduction", {
enumerable: true,
get: ()=>_noJestInProduction
});
const _noJestInProduction = /*#__PURE__*/ _interopRequireWildcard(require("./noJestInProduction"));
function _getRequireWildcardCache(nodeInterop) {
if (typeof WeakMap !== "function") return null;
var cacheBabelInterop = new WeakMap();
var cacheNodeInterop = new WeakMap();
return (_getRequireWildcardCache = function(nodeInterop) {
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
})(nodeInterop);
}
function _interopRequireWildcard(obj, nodeInterop) {
if (!nodeInterop && obj && obj.__esModule) {
return obj;
}
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
return {
default: obj
};
}
var cache = _getRequireWildcardCache(nodeInterop);
if (cache && cache.has(obj)) {
return cache.get(obj);
}
var newObj = {};
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
for(var key in obj){
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
if (desc && (desc.get || desc.set)) {
Object.defineProperty(newObj, key, desc);
} else {
newObj[key] = obj[key];
}
}
}
newObj.default = obj;
if (cache) {
cache.set(obj, newObj);
}
return newObj;
}
47 changes: 47 additions & 0 deletions dist/noJestInProduction/noJestInProduction.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
meta: ()=>meta,
create: ()=>create
});
const meta = {
type: "problem",
docs: {
description: "Prevents jest from being used in production code",
category: "no-jest-in-production",
recommended: false
},
fixable: null,
schema: []
};
const create = (context)=>{
// split the filepath into an array
const filePath = context.getFilename().split("/");
// the last entry will always be the file name
const fileName = filePath.at(-1);
// Spec files are allowed to have jest, so we skip them
const isNotSpec = ()=>{
return fileName && !fileName.includes(".spec.");
};
const isNotValid = (node)=>{
return isNotSpec() && node.name === "jest";
};
return {
Identifier (node) {
if (isNotValid(node)) {
context.report({
node,
message: "Jest should not be used in production code"
});
}
}
};
};
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"Hossam Mourad",
"Ryan O'Connor <charle692@gmail.com>",
"Aidan Feuerherm <aidan.feuerherm@fullscript.com>",
"Valentyn Patsera <valentyn.patsera@fullscript.com>"
"Valentyn Patsera <valentyn.patsera@fullscript.com>",
"Omar Nasr <omar.nasr@fullscript.com>"
],
"license": "MIT",
"private": false,
Expand Down
2 changes: 2 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { gqlObjects, gqlOperationName } from "./gqlRules";
import { noRenamedTranslationImport } from "./noRenamedTranslationImport";
import { noUnawaitedSkeletons } from "./noUnawaitedSkeletons";
import { oneTranslationImport } from "./oneTranslationImport";
import { noJestInProduction } from "./noJestInProduction";

const rules = {
"one-translation-import-per-file": oneTranslationImport,
Expand All @@ -13,6 +14,7 @@ const rules = {
"cross-reference": crossReference,
"circular-dependency": circularDependency,
"no-unawaited-skeletons": noUnawaitedSkeletons,
"no-jest-in-production": noJestInProduction,
};

export { rules };
1 change: 1 addition & 0 deletions src/noJestInProduction/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * as noJestInProduction from "./noJestInProduction";
39 changes: 39 additions & 0 deletions src/noJestInProduction/noJestInProduction.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
const meta = {
type: "problem",
docs: {
description: "Prevents jest from being used in production code",
category: "no-jest-in-production",
recommended: false,
},
fixable: null,
schema: [],
};

const create = context => {
// split the filepath into an array
const filePath = context.getFilename().split("/");
// the last entry will always be the file name
const fileName = filePath.at(-1);

// Spec files are allowed to have jest, so we skip them
const isNotSpec = () => {
return fileName && !fileName.includes(".spec.");
};

const isNotValid = node => {
return isNotSpec() && node.name === "jest";
};

return {
Identifier(node) {
if (isNotValid(node)) {
context.report({
node,
message: "Jest should not be used in production code",
});
}
},
};
};

export { meta, create };