Skip to content

Commit

Permalink
Revert "feat(spectral): esm again (#746)" (#748)
Browse files Browse the repository at this point in the history
This reverts commit bb437f8.
  • Loading branch information
kanadgupta authored Sep 8, 2023
1 parent 5694447 commit b0bd700
Show file tree
Hide file tree
Showing 26 changed files with 9,935 additions and 11,899 deletions.
21,677 changes: 9,864 additions & 11,813 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion packages/spectral-config/.eslintignore

This file was deleted.

2 changes: 1 addition & 1 deletion packages/spectral-config/.eslintrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"extends": "@readme/eslint-config",
"rules": { "import/extensions": ["error", "always"] }
"parserOptions": { "ecmaVersion": 2020 }
}
1 change: 0 additions & 1 deletion packages/spectral-config/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
dist/
node_modules/
1 change: 0 additions & 1 deletion packages/spectral-config/.prettierignore

This file was deleted.

9 changes: 2 additions & 7 deletions packages/spectral-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,12 @@
"name": "@readme/spectral-config",
"version": "3.1.0",
"description": "ReadMe coding standards for API documentation",
"main": "dist/index.cjs",
"module": "./dist/index.js",
"type": "module",
"main": "src/index.js",
"engines": {
"node": ">=16"
},
"scripts": {
"build": "tsup",
"lint": "eslint .",
"prepack": "npm run build",
"test": "vitest run"
},
"repository": {
Expand All @@ -26,7 +22,7 @@
"homepage": "https://github.com/readmeio/standards",
"dependencies": {
"@stoplight/spectral-rulesets": "^1.15.0",
"alex": "^11.0.1"
"alex": "^9.1.1"
},
"peerDependencies": {
"@stoplight/spectral-cli": "^6.6.0"
Expand All @@ -35,7 +31,6 @@
"@ibm-cloud/openapi-ruleset": "^1.1.1",
"@readme/eslint-config": "file:../eslint-config",
"@readme/oas-examples": "^5.12.0",
"tsup": "^7.2.0",
"vitest": "^0.34.1"
},
"prettier": "@readme/eslint-config/prettier"
Expand Down
6 changes: 3 additions & 3 deletions packages/spectral-config/src/functions/alex.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { text } from 'alex';
const { text } = require('alex');

/**
* Ensure that a given string has considerate and inclusive language.
*
* @see {@link https://alexjs.com/}
* @param {string} input
*/
export default function alex(input, options, context) {
module.exports = async function alex(input, options, context) {
const errors = text(input, { profanitySureness: 1 }).messages;

return errors
Expand All @@ -23,4 +23,4 @@ export default function alex(input, options, context) {
};
})
.filter(Boolean);
}
};
5 changes: 5 additions & 0 deletions packages/spectral-config/src/functions/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/* eslint-disable global-require */
module.exports = {
alex: require('./alex'),
sentencePunctuation: require('./sentencePunctuation'),
};
4 changes: 2 additions & 2 deletions packages/spectral-config/src/functions/sentencePunctuation.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* @param {string} input
*/
export default function sentencePunctuation(input) {
module.exports = function sentencePunctuation(input) {
if (!input) {
// Minor protection for when we have a `description` property as part of an endpoint payload,
// not a `description` of a schema entry.
Expand All @@ -19,4 +19,4 @@ export default function sentencePunctuation(input) {
}

return [];
}
};
28 changes: 10 additions & 18 deletions packages/spectral-config/src/index.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,19 @@
import { oas } from '@stoplight/spectral-rulesets';
const { oas } = require('@stoplight/spectral-rulesets');

import alexComponentDescription from './rules/alex-component-description.js';
import alexComponentSummary from './rules/alex-component-summary.js';
import alexOperationDescription from './rules/alex-operation-description.js';
import alexOperationSummary from './rules/alex-operation-summary.js';
import alexParameter from './rules/alex-parameter.js';
import alexResponse from './rules/alex-response.js';
import descriptionSentencePunctuation from './rules/description-sentence-punctuation.js';
const rules = require('./rules');

const config = {
module.exports = {
extends: oas,
rules: {
'alex-component-description': alexComponentDescription,
'alex-component-summary': alexComponentSummary,
'alex-component-description': rules.alexComponentDescription,
'alex-component-summary': rules.alexComponentSummary,

'alex-operation-description': alexOperationDescription,
'alex-operation-summary': alexOperationSummary,
'alex-operation-description': rules.alexComponentDescription,
'alex-operation-summary': rules.alexOperationSummary,

'alex-parameter': alexParameter,
'alex-response': alexResponse,
'alex-parameter': rules.alexParameter,
'alex-response': rules.alexResponse,

'description-sentence-punctuation': descriptionSentencePunctuation,
'description-sentence-punctuation': rules.descriptionSentencePunctuation,
},
};

export default config;
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import alex from '../functions/alex.js';
const { alex } = require('../functions');

const rule = {
module.exports = {
description: 'Component schema description should have inclusive and considerate language.',
message: '{{error}}',
severity: 'error',
Expand All @@ -11,5 +11,3 @@ const rule = {
function: alex,
},
};

export default rule;
6 changes: 2 additions & 4 deletions packages/spectral-config/src/rules/alex-component-summary.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import alex from '../functions/alex.js';
const { alex } = require('../functions');

const rule = {
module.exports = {
description: 'Component schema summaries should have inclusive and considerate language.',
message: '{{error}}',
severity: 'error',
Expand All @@ -11,5 +11,3 @@ const rule = {
function: alex,
},
};

export default rule;
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import alex from '../functions/alex.js';
const { alex } = require('../functions');

const rule = {
module.exports = {
description: 'Operation descriptions should have inclusive and considerate language.',
message: '{{error}}',
severity: 'error',
Expand All @@ -11,5 +11,3 @@ const rule = {
function: alex,
},
};

export default rule;
6 changes: 2 additions & 4 deletions packages/spectral-config/src/rules/alex-operation-summary.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import alex from '../functions/alex.js';
const { alex } = require('../functions');

const rule = {
module.exports = {
description: 'Operation summaries should have inclusive and considerate language.',
message: '{{error}}',
severity: 'error',
Expand All @@ -11,5 +11,3 @@ const rule = {
function: alex,
},
};

export default rule;
6 changes: 2 additions & 4 deletions packages/spectral-config/src/rules/alex-parameter.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import alex from '../functions/alex.js';
const { alex } = require('../functions');

const rule = {
module.exports = {
description: 'Operation parameters should have inclusive and considerate language.',
message: '{{error}}',
severity: 'error',
Expand All @@ -11,5 +11,3 @@ const rule = {
function: alex,
},
};

export default rule;
6 changes: 2 additions & 4 deletions packages/spectral-config/src/rules/alex-response.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import alex from '../functions/alex.js';
const { alex } = require('../functions');

const rule = {
module.exports = {
description: 'Operation responses should have inclusive and considerate language.',
message: '{{error}}',
severity: 'error',
Expand All @@ -11,5 +11,3 @@ const rule = {
function: alex,
},
};

export default rule;
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import sentencePunctuation from '../functions/sentencePunctuation.js';
const { sentencePunctuation } = require('../functions');

const rule = {
module.exports = {
description: 'Descriptions should have ending punctuation.',
message: '{{description}}',
severity: 'info',
Expand All @@ -11,5 +11,3 @@ const rule = {
function: sentencePunctuation,
},
};

export default rule;
13 changes: 13 additions & 0 deletions packages/spectral-config/src/rules/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* eslint-disable global-require */
module.exports = {
alexComponentDescription: require('./alex-component-description'),
alexComponentSummary: require('./alex-component-summary'),

alexOperationDescription: require('./alex-operation-description'),
alexOperationSummary: require('./alex-operation-summary'),

alexParameter: require('./alex-parameter'),
alexResponse: require('./alex-response'),

descriptionSentencePunctuation: require('./description-sentence-punctuation'),
};
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { makeCopy, severityCodes, testRule } from '@ibm-cloud/openapi-ruleset/test/utils/index.js';
import { makeCopy, severityCodes, testRule } from '@ibm-cloud/openapi-ruleset/test/utils';
import readme from '@readme/oas-examples/3.0/json/readme.json';
import { describe, it, expect } from 'vitest';

import rule from '../src/rules/alex-component-description.js';
const { alexComponentDescription } = require('../src/rules');

const rule = alexComponentDescription;
const ruleId = 'alex-component-description';
const expectedSeverity = severityCodes.error;
const expectedErrorMsg = 'Don’t use `fucking`, it’s profane';
Expand Down
5 changes: 3 additions & 2 deletions packages/spectral-config/test/alex-component-summary.test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { makeCopy, severityCodes, testRule } from '@ibm-cloud/openapi-ruleset/test/utils/index.js';
import { makeCopy, severityCodes, testRule } from '@ibm-cloud/openapi-ruleset/test/utils';
import readme from '@readme/oas-examples/3.0/json/readme.json';
import { describe, it, expect } from 'vitest';

import rule from '../src/rules/alex-component-summary.js';
const { alexComponentSummary } = require('../src/rules');

const rule = alexComponentSummary;
const ruleId = 'alex-component-summary';
const expectedSeverity = severityCodes.error;
const expectedErrorMsg = 'Don’t use `fucking`, it’s profane';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { makeCopy, severityCodes, testRule } from '@ibm-cloud/openapi-ruleset/test/utils/index.js';
import { makeCopy, severityCodes, testRule } from '@ibm-cloud/openapi-ruleset/test/utils';
import readme from '@readme/oas-examples/3.0/json/readme.json';
import { describe, it, expect } from 'vitest';

import rule from '../src/rules/alex-operation-description.js';
const { alexOperationDescription } = require('../src/rules');

const rule = alexOperationDescription;
const ruleId = 'alex-operation-description';
const expectedSeverity = severityCodes.error;
const expectedErrorMsg = 'Don’t use `fucking`, it’s profane';
Expand Down
5 changes: 3 additions & 2 deletions packages/spectral-config/test/alex-operation-summary.test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { makeCopy, severityCodes, testRule } from '@ibm-cloud/openapi-ruleset/test/utils/index.js';
import { makeCopy, severityCodes, testRule } from '@ibm-cloud/openapi-ruleset/test/utils';
import readme from '@readme/oas-examples/3.0/json/readme.json';
import { describe, it, expect } from 'vitest';

import rule from '../src/rules/alex-operation-summary.js';
const { alexOperationSummary } = require('../src/rules');

const rule = alexOperationSummary;
const ruleId = 'alex-operation-summary';
const expectedSeverity = severityCodes.error;
const expectedErrorMsg = 'Don’t use `fucking`, it’s profane';
Expand Down
5 changes: 3 additions & 2 deletions packages/spectral-config/test/alex-parameter.test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { makeCopy, severityCodes, testRule } from '@ibm-cloud/openapi-ruleset/test/utils/index.js';
import { makeCopy, severityCodes, testRule } from '@ibm-cloud/openapi-ruleset/test/utils';
import readme from '@readme/oas-examples/3.0/json/readme.json';
import { describe, it, expect } from 'vitest';

import rule from '../src/rules/alex-parameter.js';
const { alexParameter } = require('../src/rules');

const rule = alexParameter;
const ruleId = 'alex-parameter';
const expectedSeverity = severityCodes.error;
const expectedErrorMsg = 'Don’t use `fucking`, it’s profane';
Expand Down
5 changes: 3 additions & 2 deletions packages/spectral-config/test/alex-response.test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { makeCopy, severityCodes, testRule } from '@ibm-cloud/openapi-ruleset/test/utils/index.js';
import { makeCopy, severityCodes, testRule } from '@ibm-cloud/openapi-ruleset/test/utils';
import readme from '@readme/oas-examples/3.0/json/readme.json';
import { describe, it, expect } from 'vitest';

import rule from '../src/rules/alex-response.js';
const { alexResponse } = require('../src/rules');

const rule = alexResponse;
const ruleId = 'alex-response';
const expectedSeverity = severityCodes.error;
const expectedErrorMsg = 'Don’t use `fucking`, it’s profane';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { makeCopy, severityCodes, testRule } from '@ibm-cloud/openapi-ruleset/test/utils/index.js';
import { makeCopy, severityCodes, testRule } from '@ibm-cloud/openapi-ruleset/test/utils';
import readme from '@readme/oas-examples/3.0/json/readme.json';
import { describe, it, expect } from 'vitest';

import rule from '../src/rules/description-sentence-punctuation.js';
const { descriptionSentencePunctuation } = require('../src/rules');

const rule = descriptionSentencePunctuation;
const ruleId = 'description-sentence-punctuation';
const expectedSeverity = severityCodes.info;
const expectedErrorMsg = 'Descriptions should have ending punctuation.';
Expand Down
10 changes: 0 additions & 10 deletions packages/spectral-config/tsup.config.js

This file was deleted.

0 comments on commit b0bd700

Please sign in to comment.