Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ts part 5 #567

Merged
merged 2 commits into from
Feb 26, 2022
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
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
const LintIssue = require('../LintIssue');
const {isString} = require('../validators/type');
import {LintIssue} from '../lint-issue';
import {RuleType} from '../types/rule-type';
import {Severity} from '../types/severity';
import {PackageJson} from 'type-fest';

const lintId = 'description-format';
const nodeName = 'description';
const ruleType = 'object';
export const ruleType = RuleType.Object;

// eslint-disable-next-line complexity
const lint = (packageJsonData, severity, config) => {
export const lint = (packageJsonData: PackageJson, severity: Severity, config: any): LintIssue | boolean => {
if (!packageJsonData.hasOwnProperty(nodeName)) {
return true;
}
Expand Down Expand Up @@ -45,8 +48,3 @@ const lint = (packageJsonData, severity, config) => {

return true;
};

module.exports = {
lint,
ruleType,
};
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
const {areVersionsAbsolute} = require('../validators/dependency-audit');
const LintIssue = require('../LintIssue');
import {LintIssue} from '../lint-issue';
import {RuleType} from '../types/rule-type';
import {Severity} from '../types/severity';
import {PackageJson} from 'type-fest';

const lintId = 'no-absolute-version-dependencies';
const nodeName = 'dependencies';
const message = 'You are using an invalid version range. Please do not use absolute versions.';
const ruleType = 'optionalObject';
export const ruleType = RuleType.OptionalObject;

const lint = (packageJsonData, severity, config) => {
export const lint = (packageJsonData: PackageJson, severity: Severity, config: any): LintIssue | boolean => {
if (packageJsonData.hasOwnProperty(nodeName) && areVersionsAbsolute(packageJsonData, nodeName, config)) {
return new LintIssue(lintId, severity, nodeName, message);
}

return true;
};

module.exports = {
lint,
ruleType,
};
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
const {areVersionsAbsolute} = require('../validators/dependency-audit');
const LintIssue = require('../LintIssue');
import {LintIssue} from '../lint-issue';
import {RuleType} from '../types/rule-type';
import {Severity} from '../types/severity';
import {PackageJson} from 'type-fest';

const lintId = 'no-absolute-version-devDependencies';
const nodeName = 'devDependencies';
const message = 'You are using an invalid version range. Please do not use absolute versions.';
const ruleType = 'optionalObject';
export const ruleType = RuleType.OptionalObject;

const lint = (packageJsonData, severity, config) => {
export const lint = (packageJsonData: PackageJson, severity: Severity, config: any): LintIssue | boolean => {
if (packageJsonData.hasOwnProperty(nodeName) && areVersionsAbsolute(packageJsonData, nodeName, config)) {
return new LintIssue(lintId, severity, nodeName, message);
}

return true;
};

module.exports = {
lint,
ruleType,
};
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
const {doVersContainArchiveUrl} = require('../validators/dependency-audit');
const LintIssue = require('../LintIssue');
import {LintIssue} from '../lint-issue';
import {RuleType} from '../types/rule-type';
import {Severity} from '../types/severity';
import {PackageJson} from 'type-fest';

const lintId = 'no-archive-dependencies';
const nodeName = 'dependencies';
const message = 'You are using dependencies via url to archive file. Please use dependencies from npm.';
const ruleType = 'optionalObject';
export const ruleType = RuleType.OptionalObject;

const lint = (packageJsonData, severity, config) => {
export const lint = (packageJsonData: PackageJson, severity: Severity, config: any): LintIssue | boolean => {
if (packageJsonData.hasOwnProperty(nodeName) && doVersContainArchiveUrl(packageJsonData, nodeName, config)) {
return new LintIssue(lintId, severity, nodeName, message);
}

return true;
};

module.exports = {
lint,
ruleType,
};
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
const {doVersContainArchiveUrl} = require('../validators/dependency-audit');
const LintIssue = require('../LintIssue');
import {LintIssue} from '../lint-issue';
import {RuleType} from '../types/rule-type';
import {Severity} from '../types/severity';
import {PackageJson} from 'type-fest';

const lintId = 'no-archive-devDependencies';
const nodeName = 'devDependencies';
const message = 'You are using devDependencies via url to archive file. Please use devDependencies from npm.';
const ruleType = 'optionalObject';
export const ruleType = RuleType.OptionalObject;

const lint = (packageJsonData, severity, config) => {
export const lint = (packageJsonData: PackageJson, severity: Severity, config: any): LintIssue | boolean => {
if (packageJsonData.hasOwnProperty(nodeName) && doVersContainArchiveUrl(packageJsonData, nodeName, config)) {
return new LintIssue(lintId, severity, nodeName, message);
}

return true;
};

module.exports = {
lint,
ruleType,
};
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
const {doVersContainInvalidRange} = require('../validators/dependency-audit');
const LintIssue = require('../LintIssue');
import {LintIssue} from '../lint-issue';
import {RuleType} from '../types/rule-type';
import {Severity} from '../types/severity';
import {PackageJson} from 'type-fest';

const lintId = 'no-caret-version-dependencies';
const nodeName = 'dependencies';
const message = 'You are using an invalid version range. Please do not use ^.';
const ruleType = 'optionalObject';
export const ruleType = RuleType.OptionalObject;

const lint = (packageJsonData, severity, config) => {
export const lint = (packageJsonData: PackageJson, severity: Severity, config: any): LintIssue | boolean => {
const rangeSpecifier = '^';

if (
Expand All @@ -18,8 +21,3 @@ const lint = (packageJsonData, severity, config) => {

return true;
};

module.exports = {
lint,
ruleType,
};
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
const {doVersContainInvalidRange} = require('../validators/dependency-audit');
const LintIssue = require('../LintIssue');
import {LintIssue} from '../lint-issue';
import {RuleType} from '../types/rule-type';
import {Severity} from '../types/severity';
import {PackageJson} from 'type-fest';

const lintId = 'no-caret-version-devDependencies';
const nodeName = 'devDependencies';
const message = 'You are using an invalid version range. Please do not use ^.';
const ruleType = 'optionalObject';
export const ruleType = RuleType.OptionalObject;

const lint = (packageJsonData, severity, config) => {
export const lint = (packageJsonData: PackageJson, severity: Severity, config: any): LintIssue | boolean => {
const rangeSpecifier = '^';

if (
Expand All @@ -18,8 +21,3 @@ const lint = (packageJsonData, severity, config) => {

return true;
};

module.exports = {
lint,
ruleType,
};
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
const Parser = require('../Parser');
const {findDuplicatePropNames} = require('../validators/property');
const LintIssue = require('../LintIssue');
import {LintIssue} from '../lint-issue';
import {RuleType} from '../types/rule-type';
import {Severity} from '../types/severity';
import {PackageJson} from 'type-fest';

const lintId = 'no-duplicate-properties';
const nodeName = '';
const ruleType = 'standard';
export const ruleType = RuleType.Standard;

const lint = (packageJsonData, severity) => {
export const lint = (packageJsonData: PackageJson, severity: Severity): LintIssue | boolean => {
/**
* If we send package json straight to npm-package-json-lint, fallback to empty string.
* Because we already lose information about duplicate properties.
Expand All @@ -22,8 +25,3 @@ const lint = (packageJsonData, severity) => {

return true;
};

module.exports = {
lint,
ruleType,
};
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
const {doVersContainFileUrl} = require('../validators/dependency-audit');
const LintIssue = require('../LintIssue');
import {LintIssue} from '../lint-issue';
import {RuleType} from '../types/rule-type';
import {Severity} from '../types/severity';
import {PackageJson} from 'type-fest';

const lintId = 'no-file-dependencies';
const nodeName = 'dependencies';
const message = 'You are using dependencies via url to local file. Please use dependencies from npm.';
const ruleType = 'optionalObject';
export const ruleType = RuleType.OptionalObject;

const lint = (packageJsonData, severity, config) => {
export const lint = (packageJsonData: PackageJson, severity: Severity, config: any): LintIssue | boolean => {
if (packageJsonData.hasOwnProperty(nodeName) && doVersContainFileUrl(packageJsonData, nodeName, config)) {
return new LintIssue(lintId, severity, nodeName, message);
}

return true;
};

module.exports = {
lint,
ruleType,
};
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
const {doVersContainFileUrl} = require('../validators/dependency-audit');
const LintIssue = require('../LintIssue');
import {LintIssue} from '../lint-issue';
import {RuleType} from '../types/rule-type';
import {Severity} from '../types/severity';
import {PackageJson} from 'type-fest';

const lintId = 'no-file-devDependencies';
const nodeName = 'devDependencies';
const message = 'You are using devDependencies via url to local file. Please use devDependencies from npm.';
const ruleType = 'optionalObject';
export const ruleType = RuleType.OptionalObject;

const lint = (packageJsonData, severity, config) => {
export const lint = (packageJsonData: PackageJson, severity: Severity, config: any): LintIssue | boolean => {
if (packageJsonData.hasOwnProperty(nodeName) && doVersContainFileUrl(packageJsonData, nodeName, config)) {
return new LintIssue(lintId, severity, nodeName, message);
}

return true;
};

module.exports = {
lint,
ruleType,
};
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
const {doVersContainGitRepository} = require('../validators/dependency-audit');
const LintIssue = require('../LintIssue');
import {LintIssue} from '../lint-issue';
import {RuleType} from '../types/rule-type';
import {Severity} from '../types/severity';
import {PackageJson} from 'type-fest';

const lintId = 'no-git-dependencies';
const nodeName = 'dependencies';
const message = 'You are using dependencies from git repository. Please use dependencies from npm.';
const ruleType = 'optionalObject';
export const ruleType = RuleType.OptionalObject;

const lint = (packageJsonData, severity, config) => {
export const lint = (packageJsonData: PackageJson, severity: Severity, config: any): LintIssue | boolean => {
if (packageJsonData.hasOwnProperty(nodeName) && doVersContainGitRepository(packageJsonData, nodeName, config)) {
return new LintIssue(lintId, severity, nodeName, message);
}

return true;
};

module.exports = {
lint,
ruleType,
};
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
const {doVersContainGitRepository} = require('../validators/dependency-audit');
const LintIssue = require('../LintIssue');
import {LintIssue} from '../lint-issue';
import {RuleType} from '../types/rule-type';
import {Severity} from '../types/severity';
import {PackageJson} from 'type-fest';

const lintId = 'no-git-devDependencies';
const nodeName = 'devDependencies';
const message = 'You are using devDependencies from git repository. Please use devDependencies from npm.';
const ruleType = 'optionalObject';
export const ruleType = RuleType.OptionalObject;

const lint = (packageJsonData, severity, config) => {
export const lint = (packageJsonData: PackageJson, severity: Severity, config: any): LintIssue | boolean => {
if (packageJsonData.hasOwnProperty(nodeName) && doVersContainGitRepository(packageJsonData, nodeName, config)) {
return new LintIssue(lintId, severity, nodeName, message);
}

return true;
};

module.exports = {
lint,
ruleType,
};
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
const {exists} = require('../validators/property');
const LintIssue = require('../LintIssue');
import {exists} from '../validators/property';
import {LintIssue} from '../lint-issue';
import {RuleType} from '../types/rule-type';
import {Severity} from '../types/severity';
import {PackageJson} from 'type-fest';

const lintId = 'no-repeated-dependencies';
const ruleType = 'standard';
export const ruleType = RuleType.Standard;

const dependenciesNode = 'dependencies';
const devDependenciesNode = 'devDependencies';

const lint = (packageJsonData, severity) => {
export const lint = (packageJsonData: PackageJson, severity: Severity): LintIssue | boolean => {
if (!exists(packageJsonData, dependenciesNode)) {
return true;
}
Expand All @@ -33,8 +36,3 @@ const lint = (packageJsonData, severity) => {

return true;
};

module.exports = {
lint,
ruleType,
};
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
const {hasDependency} = require('../validators/dependency-audit');
const LintIssue = require('../LintIssue');
import {LintIssue} from '../lint-issue';
import {RuleType} from '../types/rule-type';
import {Severity} from '../types/severity';
import {PackageJson} from 'type-fest';

const lintId = 'no-restricted-dependencies';
const nodeName = 'dependencies';
const message = 'You are using a restricted dependency. Please remove it.';
const ruleType = 'array';
const minItems = 1;
export const ruleType = RuleType.Array;
export const minItems = 1;

const lint = (packageJsonData, severity, invalidDependencies) => {
export const lint = (packageJsonData: PackageJson, severity: Severity, invalidDependencies: string[]): LintIssue | boolean => {
if (hasDependency(packageJsonData, nodeName, invalidDependencies)) {
return new LintIssue(lintId, severity, nodeName, message);
}

return true;
};

module.exports = {
lint,
ruleType,
minItems,
};
Loading