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

Fix CSV creation #67

Merged
merged 3 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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: 1 addition & 3 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,4 @@
# review when someone opens a pull request.

# Assign ownership of the entire repository to
* @paulius-valiunas @MichaelBelousov @ben-polinsky @aruniverse


* @paulius-valiunas @ben-polinsky @aruniverse @anmolshres98
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ package-lock.json

# Mac specfic
**/.DS_Store

# tests - when testing for csv output, we write the actual file because we cannot mock in eslint tests
lib/*.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "fix csv output generation",
"packageName": "@itwin/eslint-plugin",
"email": "ben-polinsky@users.noreply.github.com",
"dependentChangeType": "patch"
}
13 changes: 5 additions & 8 deletions dist/rules/public-extension-exports.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,12 @@ module.exports = {
}
}

function addToApiList(declaration, tags) {
function addToApiList(declaration) {
if (!outputApiFile) {
return;
}
const validReleaseTag = tags.find((tag) =>
releaseTags.includes(tag.tagName.escapedText)
);

const createCsvString = (name, kind) =>
`${name},${kind},${validReleaseTag}\n`;
const createCsvString = (name, kind) => `${name},${kind},Public\n`;
ben-polinsky marked this conversation as resolved.
Show resolved Hide resolved

const names =
declaration.kind === ts.SyntaxKind.VariableStatement
Expand Down Expand Up @@ -184,12 +180,13 @@ module.exports = {
};

if (hasExtensionTag) {
addToApiList(declaration, tags);
if (!hasPublicTag)
if (!hasPublicTag) {
context.report({
...commonReport,
messageId: "missingExtensionReleaseTag",
});
}
addToApiList(declaration);
return true;
}
return false;
Expand Down
Empty file added lib/.gitkeep
Empty file.
16 changes: 16 additions & 0 deletions tests/public-extension-exports.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,22 @@ tester.run("public-extension-exports", PublicExtensionsExports, {
}
`,
},
/**
* CSV Output:
* NOTE: There's not a great way to test this programmatically from within the eslint test runner.
* Please check that the lib/GeneratedExtensionApi.csv file is created and contains the expected data after your test runs.
*/
{
code: `
/**
* @extensions
* @public
*/
export function destroyAllIModels(): void{
}
`,
options: [{ outputApiFile: true }],
},
],
invalid: [
// extensions require public tag.
Expand Down
Loading