Skip to content
This repository has been archived by the owner on May 22, 2024. It is now read-only.

Commit

Permalink
renamed rule to require-dependencies-declared-at-appropriate-level
Browse files Browse the repository at this point in the history
  • Loading branch information
pranav300 committed Oct 8, 2021
1 parent f9b604f commit 71a07f7
Show file tree
Hide file tree
Showing 11 changed files with 101 additions and 143 deletions.
2 changes: 1 addition & 1 deletion packages/package-json-lint-config-terra/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## Unreleased

* Added
* Added new rule `require-no-unnecessary-dependency`.
* Added new rule `require-dependencies-declared-at-appropriate-level`.

## 1.1.0 - (September 28, 2021)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ module.exports = {
'require-no-hard-coded-dependency-versions': { severityType: 'error' },
'require-no-terra-base-peer-dependency-versions': { severityType: 'warn' },
'require-theme-context-versions': { severityType: 'warn' },
'require-no-unnecessary-dependency': { severityType: 'warn' },
'require-dependencies-declared-at-appropriate-level': { severityType: 'warn' },
},
};
6 changes: 3 additions & 3 deletions packages/package-json-lint/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

## Unreleased

* Added
* Added new rule `require-dependencies-declared-at-appropriate-level`.

## 1.2.1 - (September 30, 2021)

* Changed
* Moved documentation to terra-toolkit-docs.

## 1.2.0 - (September 28, 2021)

* Added
* Added new rule `require-no-unnecessary-dependency`.

* Added
* Added new rule `require-no-hard-coded-dependency-versions`.

Expand Down
26 changes: 26 additions & 0 deletions packages/package-json-lint/src/rules/dev-dependency-set.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"devDependencySet": [
"@babel/cli",
"@babel/core",
"@babel/helpers",
"@babel/plugin-proposal-object-rest-spread",
"@babel/plugin-syntax-async-generators",
"@babel/plugin-transform-object-assign",
"@babel/plugin-transform-regenerator",
"@babel/plugin-transform-runtime",
"@babel/preset-env",
"@babel/preset-react",
"@babel/register",
"@cerner/browserslist-config-terra",
"@cerner/eslint-config-terra",
"@cerner/jest-config-terra",
"@cerner/stylelint-config-terra",
"@cerner/terra-aggregate-translations",
"@cerner/terra-cli",
"@cerner/terra-dev-site",
"@cerner/terra-functional-testing",
"@cerner/terra-open-source-scripts",
"@cerner/webpack-config-terra",
"jest"
]
}
6 changes: 3 additions & 3 deletions packages/package-json-lint/src/rules/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const requireThemeContextVersions = require('./require-theme-context-versions');
const requireNoTerraBasePeerDependencyVersions = require('./require-no-terra-base-peer-dependency-versions');
const requireNoUnnecessaryDependency = require('./require-no-unnecessary-dependency');
const requireDependenciesDeclaredAtAppropriateLevel = require('./require-dependencies-declared-at-appropriate-level');
const requireNoHardCodedDependencyVersions = require('./require-no-hard-coded-dependency-versions');

module.exports = {
'require-dependencies-declared-at-appropriate-level': requireDependenciesDeclaredAtAppropriateLevel,
'require-no-hard-coded-dependency-versions': requireNoHardCodedDependencyVersions,
'require-no-terra-base-peer-dependency-versions': requireNoTerraBasePeerDependencyVersions,
'require-no-unnecessary-dependency': requireNoUnnecessaryDependency,
'require-theme-context-versions': requireThemeContextVersions,
'require-no-hard-coded-dependency-versions': requireNoHardCodedDependencyVersions,
};
Original file line number Diff line number Diff line change
@@ -1,67 +1,8 @@
const devDependencySet = [
'@babel/cli',
'@babel/core',
'@babel/helpers',
'@babel/plugin-proposal-object-rest-spread',
'@babel/plugin-syntax-async-generators',
'@babel/plugin-transform-object-assign',
'@babel/plugin-transform-regenerator',
'@babel/plugin-transform-runtime',
'@babel/preset-env',
'@babel/preset-react',
'@babel/register',
'@cerner/browserslist-config-terra',
'@cerner/eslint-config-terra',
'@cerner/jest-config-terra',
'@cerner/stylelint-config-terra',
'@cerner/terra-aggregate-translations',
'@cerner/terra-cli',
'@cerner/terra-dev-site',
'@cerner/terra-functional-testing',
'@cerner/terra-open-source-scripts',
'@octokit/core',
'bufferutil',
'chai',
'check-installed-dependencies',
'core-js',
'csvtojson',
'danger',
'enzyme',
'enzyme-adapter-react-16',
'enzyme-to-json',
'eslint',
'gh-pages',
'glob',
'html-webpack-plugin',
'jest',
'jsdom',
'ky',
'lerna',
'link-parent-bin',
'memory-fs',
'mocha',
'nock',
'np',
'one-cerner-style-icons',
'postcss',
'react-test-renderer',
'regenerator-runtime',
'shelljs',
'sinon',
'strip-ansi',
'stylelint',
'svgo',
'utf-8-validate',
'webpack',
'webpack-cli',
'webpack-dev-server',
'webpack-merge',
'yargs',
];
const { devDependencySet } = require('./dev-dependency-set.json');

function findUnnecessaryDependency(rule, dependencies, dependencyType) {
const { ruleConfig, projectType, report } = rule;
const messageString = 'require-no-unnecessary-dependency';
const messageString = 'require-dependencies-declared-at-appropriate-level';
if (projectType !== 'devModule') {
const currentProblems = Object.keys(dependencies).map((dependency) => {
const dependencyVersion = dependencies[dependency];
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`require-dependencies-declared-at-appropriate-level when projectType is application fails as a warning when there unnecessary dependencies/peerDependencies 1`] = `
Array [
Object {
"lintId": "require-dependencies-declared-at-appropriate-level",
"lintMessage": "This project has unnecessary dependencies that violates the require-dependencies-declared-at-appropriate-level rule:
@cerner/webpack-config-terra@^2.0.0 does not satisfy requirement for require-dependencies-declared-at-appropriate-level rule.",
"projectType": "application",
"severity": Object {
"severityType": "warn",
},
},
Object {
"lintId": "require-dependencies-declared-at-appropriate-level",
"lintMessage": "This project has unnecessary peerDependencies that violates the require-dependencies-declared-at-appropriate-level rule:
jest@^26.6.2 does not satisfy requirement for require-dependencies-declared-at-appropriate-level rule.",
"projectType": "application",
"severity": Object {
"severityType": "warn",
},
},
]
`;

exports[`require-dependencies-declared-at-appropriate-level when projectType is application succeeds when there are no unnecessary dependencies/peerDependencies 1`] = `Array []`;

exports[`require-dependencies-declared-at-appropriate-level when projectType is application succeeds when unnecessary dependencies/peerDependencies are passed in the allowList 1`] = `Array []`;

exports[`require-dependencies-declared-at-appropriate-level when projectType is devModule succeeds when there no unnecessary dependencies/peerDependencies 1`] = `Array []`;

exports[`require-dependencies-declared-at-appropriate-level when projectType is devModule succeeds when there unnecessary dependencies/peerDependencies 1`] = `Array []`;

exports[`require-dependencies-declared-at-appropriate-level when projectType is module fails as a warning when there unnecessary dependencies/peerDependencies 1`] = `
Array [
Object {
"lintId": "require-dependencies-declared-at-appropriate-level",
"lintMessage": "This project has unnecessary peerDependencies that violates the require-dependencies-declared-at-appropriate-level rule:
jest@^26.6.2 does not satisfy requirement for require-dependencies-declared-at-appropriate-level rule.",
"projectType": "module",
"severity": Object {
"severityType": "warn",
},
},
]
`;

exports[`require-dependencies-declared-at-appropriate-level when projectType is module succeeds when there are no unnecessary dependencies/peerDependencies 1`] = `Array []`;

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const requireNoUnnecessaryDependency = require('../../../src/rules/require-no-unnecessary-dependency');
const requireDependenciesDeclaredAtAppropriateLevel = require('../../../src/rules/require-dependencies-declared-at-appropriate-level');

describe('require-no-unnecessary-dependency', () => {
describe('require-dependencies-declared-at-appropriate-level', () => {
describe('when projectType is application', () => {
it('fails as a warning when there unnecessary dependencies/peerDependencies', () => {
const results = [];
const rule = requireNoUnnecessaryDependency.create({
const rule = requireDependenciesDeclaredAtAppropriateLevel.create({
ruleConfig: {
severity: {
severityType: 'warn',
Expand All @@ -16,7 +16,7 @@ describe('require-no-unnecessary-dependency', () => {
},
});
rule.dependencies({
webpack: '^4.30.0',
'@cerner/webpack-config-terra': '^2.0.0',
});
rule.peerDependencies({
jest: '^26.6.2',
Expand All @@ -25,7 +25,7 @@ describe('require-no-unnecessary-dependency', () => {
});
it('succeeds when there are no unnecessary dependencies/peerDependencies', () => {
const results = [];
const rule = requireNoUnnecessaryDependency.create({
const rule = requireDependenciesDeclaredAtAppropriateLevel.create({
ruleConfig: {
severity: {
severityType: 'warn',
Expand All @@ -46,11 +46,11 @@ describe('require-no-unnecessary-dependency', () => {
});
it('succeeds when unnecessary dependencies/peerDependencies are passed in the allowList', () => {
const results = [];
const rule = requireNoUnnecessaryDependency.create({
const rule = requireDependenciesDeclaredAtAppropriateLevel.create({
ruleConfig: {
severity: {
severityType: 'warn',
allowList: ['webpack', 'jest'],
allowList: ['@cerner/webpack-config-terra', 'jest'],
},
},
projectType: 'application',
Expand All @@ -59,7 +59,7 @@ describe('require-no-unnecessary-dependency', () => {
},
});
rule.dependencies({
webpack: '^4.30.0',
'@cerner/webpack-config-terra': '^2.0.0',
});
rule.peerDependencies({
jest: '^26.6.2',
Expand All @@ -71,7 +71,7 @@ describe('require-no-unnecessary-dependency', () => {
describe('when projectType is module', () => {
it('fails as a warning when there unnecessary dependencies/peerDependencies', () => {
const results = [];
const rule = requireNoUnnecessaryDependency.create({
const rule = requireDependenciesDeclaredAtAppropriateLevel.create({
ruleConfig: {
severity: {
severityType: 'warn',
Expand All @@ -92,7 +92,7 @@ describe('require-no-unnecessary-dependency', () => {
});
it('succeeds when there are no unnecessary dependencies/peerDependencies', () => {
const results = [];
const rule = requireNoUnnecessaryDependency.create({
const rule = requireDependenciesDeclaredAtAppropriateLevel.create({
ruleConfig: {
severity: {
severityType: 'warn',
Expand All @@ -116,7 +116,7 @@ describe('require-no-unnecessary-dependency', () => {
describe('when projectType is devModule', () => {
it('succeeds when there unnecessary dependencies/peerDependencies', () => {
const results = [];
const rule = requireNoUnnecessaryDependency.create({
const rule = requireDependenciesDeclaredAtAppropriateLevel.create({
ruleConfig: {
severity: {
severityType: 'warn',
Expand All @@ -128,7 +128,7 @@ describe('require-no-unnecessary-dependency', () => {
},
});
rule.dependencies({
webpack: '^4.30.0',
'@cerner/webpack-config-terra': '^2.0.0',
});
rule.peerDependencies({
jest: '^26.6.2',
Expand All @@ -137,7 +137,7 @@ describe('require-no-unnecessary-dependency', () => {
});
it('succeeds when there no unnecessary dependencies/peerDependencies', () => {
const results = [];
const rule = requireNoUnnecessaryDependency.create({
const rule = requireDependenciesDeclaredAtAppropriateLevel.create({
ruleConfig: {
severity: {
severityType: 'warn',
Expand Down
6 changes: 3 additions & 3 deletions packages/terra-toolkit-docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## Unreleased

* Added
* Added documentation for new rule `require-dependencies-declared-at-appropriate-level`.

## 2.5.2 - (September 30, 2021)

* Added
Expand All @@ -14,9 +17,6 @@

## 2.5.0 - (September 28, 2021)

* Added
* Added documentation for new rule `require-no-unnecessary-dependency`.

* Added
* Added documentation for `package-json-lint`.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Badge } from '@cerner/package-json-lint/package.json?dev-site-package';

| Rule Name | Severity Type | Description |
| --- | --- |--- |
| __require-dependencies-declared-at-appropriate-level__ | warn| Notifies when there are unnecessary dependencies and peerDependencies being passed in the package.json. Doesn't apply for devModule. |
| __require-no-hard-coded-dependency-versions__ | error | Prevents hard-coded dependencies from being specified in the package.json. Only applies for module and devModule. |
| __require-no-terra-base-peer-dependency-versions__ | warn| Notifies when using terra packages that require terra-base as a peerDependency. |
| __require-no-unnecessary-dependency__ | warn| Notifies when there are unnecessary dependencies and peerDependencies being passed in the package.json. Doesn't apply for devModule. |
| __require-theme-context-versions__ | warn| Notifies when using terra packages that don't use terra-theme-context as a dependency. |

0 comments on commit 71a07f7

Please sign in to comment.