Skip to content
Snippets Groups Projects
Commit 0120d4dc authored by Jack Reed's avatar Jack Reed Committed by Chris Beer
Browse files

Add a container-lint process for inspecting all of the containers

parent 422509da
Branches
No related tags found
No related merge requests found
......@@ -10,7 +10,8 @@
"sideEffects": false,
"scripts": {
"clean": "rm -rf ./dist",
"lint": "node_modules/.bin/eslint ./ && npm run lint:translations",
"lint": "node_modules/.bin/eslint ./ && npm run lint:translations && npm run lint:containers",
"lint:containers": "node ./scripts/container-lint.js",
"lint:translations": "node ./scripts/i18n-lint.js",
"server": "node_modules/.bin/http-server --cors",
"test": "npm run build && npm run lint && npm run size && jest -c jest.json",
......
const glob = require('glob'); // eslint-disable-line import/no-extraneous-dependencies
const fs = require('fs');
const chalk = require('chalk'); // eslint-disable-line import/no-extraneous-dependencies
const { error } = console;
const globOpts = { cwd: 'src/containers' };
const files = glob.sync('**/*.js', globOpts);
files.forEach((fileName) => {
const fileContent = fs.readFileSync(`src/containers/${fileName}`).toString();
const withPlugins = fileContent.indexOf('withPlugins(');
if (withPlugins > 0) {
const correctCall = fileContent.indexOf(`withPlugins('${fileName.replace('.js', '')}')`);
if (withPlugins !== correctCall) {
error(chalk.red(`Check withPlugins for ${fileName} for an incorrect target`));
}
}
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment