Skip to content

Commit

Permalink
Merge pull request #64 from microsoft/dev/mkacmar/code-formatting
Browse files Browse the repository at this point in the history
Enforce consistent code formatting
  • Loading branch information
mkacmar authored Oct 1, 2024
2 parents 5b9b57b + 5974046 commit 8c106fe
Show file tree
Hide file tree
Showing 71 changed files with 1,024 additions and 976 deletions.
24 changes: 13 additions & 11 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

title: ""
labels: ""
assignees: ""
---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:

1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
Expand All @@ -24,15 +24,17 @@ A clear and concise description of what you expected to happen.
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

**Additional context**
Add any other context about the problem here.
7 changes: 3 additions & 4 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''

title: ""
labels: ""
assignees: ""
---

**Is your feature request related to a problem? Please describe.**
Expand Down
19 changes: 19 additions & 0 deletions .github/workflows/code-formatting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

name: Code formatting

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- run: npm install
- run: npm run check-fmt
26 changes: 13 additions & 13 deletions .github/workflows/e2e-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
npm i typescript
npm i @microsoft/eslint-formatter-sarif
working-directory: ${{env.TEST_RUN_DIR}}

- uses: actions/checkout@v4
with:
repository: ${{env.GITHUB_REPO}}
Expand All @@ -55,12 +55,12 @@ jobs:
- name: Install plugin dependencies
run: npm install --production
working-directory: ${{env.PLUGIN_DIR}}

- name: Link plugin
run: sudo npm link ../${{env.PLUGIN_DIR}}
working-directory: ${{env.TEST_RUN_DIR}}
if: runner.os == 'Linux'

- name: Link plugin
run: npm link ../${{env.PLUGIN_DIR}}
working-directory: ${{env.TEST_RUN_DIR}}
Expand All @@ -69,18 +69,18 @@ jobs:
- name: Create ESLint config file
run: echo 'module.exports = [...require("@microsoft/eslint-plugin-sdl").configs.recommended];' > eslint.config.js
working-directory: ${{env.TEST_RUN_DIR}}

- name: Run ESLint
run: npx eslint
--config eslint.config.js
--no-config-lookup
${{env.TEST_TARGET_DIR}}/${{env.GITHUB_REPO_ESLINT_GLOB}}
--parser-options=project:${{env.TEST_TARGET_DIR}}/${{env.GITHUB_REPO_TSCONFIG}}
--format @microsoft/eslint-formatter-sarif
--output-file eslint-result-${{ matrix.os }}-${{github.run_id}}.sarif
run: npx eslint
--config eslint.config.js
--no-config-lookup
${{env.TEST_TARGET_DIR}}/${{env.GITHUB_REPO_ESLINT_GLOB}}
--parser-options=project:${{env.TEST_TARGET_DIR}}/${{env.GITHUB_REPO_TSCONFIG}}
--format @microsoft/eslint-formatter-sarif
--output-file eslint-result-${{ matrix.os }}-${{github.run_id}}.sarif
working-directory: ${{env.TEST_RUN_DIR}}
continue-on-error: true
continue-on-error: true

- name: Upload ESLint results as artifact
uses: actions/upload-artifact@v4
with:
Expand Down
15 changes: 7 additions & 8 deletions .github/workflows/node-version-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ on:

jobs:
build:

runs-on: ${{ matrix.os }}

strategy:
Expand All @@ -20,10 +19,10 @@ jobs:
node-version: [18.x, 20.x, 22.x]

steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: npm test
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: npm test
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
SECURITY.md
CODE_OF_CONDUCT.md
package.json
package-lock.json
4 changes: 4 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"printWidth": 100,
"trailingComma": "none"
}
62 changes: 31 additions & 31 deletions README.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions config/angular.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

"use strict";

// Generates shareable config for modern Angular (https://angular.dev/) apps.
// Generates shareable config for modern Angular (https://angular.dev/) apps.
module.exports = (pluginSdl) => {
return [
{
Expand All @@ -15,4 +15,4 @@ module.exports = (pluginSdl) => {
}
}
];
};
};
4 changes: 2 additions & 2 deletions config/angularjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

"use strict";

// Generates shareable config for legacy AngularJS (https://angularjs.org/) apps.
// Generates shareable config for legacy AngularJS (https://angularjs.org/) apps.
module.exports = (pluginSdl) => {
return [
{
Expand All @@ -17,4 +17,4 @@ module.exports = (pluginSdl) => {
}
}
];
};
};
2 changes: 1 addition & 1 deletion config/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ module.exports = (pluginSdl) => {
}
}
];
};
};
2 changes: 1 addition & 1 deletion config/electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ module.exports = (pluginSdl) => {
}
}
];
};
};
4 changes: 2 additions & 2 deletions config/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ module.exports = (pluginSdl) => {
rules: {
"@microsoft/sdl/no-unsafe-alloc": "error"
}
},
}
];
};
};
11 changes: 6 additions & 5 deletions config/react.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,27 @@ module.exports = (pluginSdl) => {
},
{
plugins: {
"react": pluginReact
react: pluginReact
},
rules: {
"react/no-danger": "error",
"react/jsx-no-target-blank": ["error",
"react/jsx-no-target-blank": [
"error",
{
allowReferrer: false,
enforceDynamicLinks: "always",
warnOnSpreadAttributes: true,
warnOnSpreadAttributes: true
}
]
}
},
{
plugins: {
"@microsoft/sdl": pluginSdl,
"@microsoft/sdl": pluginSdl
},
rules: {
"@microsoft/sdl/react-iframe-missing-sandbox": "error"
}
}
];
};
};
4 changes: 2 additions & 2 deletions config/typescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module.exports = () => {
files: ["**/*.{ts,tsx}"],
languageOptions: {
parserOptions: {
parser: "@typescript-eslint/parser",
parser: "@typescript-eslint/parser"
}
},
plugins: {
Expand All @@ -37,4 +37,4 @@ module.exports = () => {
}
}
];
};
};
2 changes: 1 addition & 1 deletion docs/rules/no-angularjs-bypass-sce.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ Calls to `$sceProvider.enabled(false)`, `$sceDelegate.trustAs()`, `$sce.trustAs(

SCE should be bypassed only in very rare and justifiable cases after careful review so that the risk of introducing Cross-Site-Scripting (XSS) vulnerability is minimized.

See [official documentation](https://docs.angularjs.org/api/ng/service/$sce#strict-contextual-escaping) for more details.
See [official documentation](https://docs.angularjs.org/api/ng/service/$sce#strict-contextual-escaping) for more details.
4 changes: 2 additions & 2 deletions docs/rules/no-cookies.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ Cookies should be used only in rare and justifiable cases after thorough securit

## Further Reading

* [Using HTTP cookies](https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies)
- [Using HTTP cookies](https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies)

## Related Rules

* [tslint-microsoft-contrib/no-cookies](https://github.com/microsoft/tslint-microsoft-contrib/blob/master/src/noCookiesRule.ts)
- [tslint-microsoft-contrib/no-cookies](https://github.com/microsoft/tslint-microsoft-contrib/blob/master/src/noCookiesRule.ts)
2 changes: 1 addition & 1 deletion docs/rules/no-document-domain.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ Writes to [`document.domain`](https://developer.mozilla.org/en-US/docs/Web/API/D

## Related Rules

* [tslint-microsoft-contrib/no-document-domain](https://github.com/microsoft/tslint-microsoft-contrib/blob/master/src/noDocumentDomainRule.ts)
- [tslint-microsoft-contrib/no-document-domain](https://github.com/microsoft/tslint-microsoft-contrib/blob/master/src/noDocumentDomainRule.ts)
2 changes: 1 addition & 1 deletion docs/rules/no-document-write.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ Calls to document.write or document.writeln manipulate DOM directly without any

## Related Rules

* [tslint-microsoft-contrib/no-document-write](https://github.com/microsoft/tslint-microsoft-contrib/blob/master/src/noDocumentWriteRule.ts)
- [tslint-microsoft-contrib/no-document-write](https://github.com/microsoft/tslint-microsoft-contrib/blob/master/src/noDocumentWriteRule.ts)
2 changes: 1 addition & 1 deletion docs/rules/no-electron-node-integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@

## Related Rules

* [codeql/js/enabling-electron-renderer-node-integration](https://help.semmle.com/wiki/display/JS/Enabling+Node.js+integration+for+Electron+web+content+renderers)
- [codeql/js/enabling-electron-renderer-node-integration](https://help.semmle.com/wiki/display/JS/Enabling+Node.js+integration+for+Electron+web+content+renderers)
2 changes: 1 addition & 1 deletion docs/rules/no-html-method.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ Direct calls to method `html()` often (e.g. in jQuery framework) manipulate DOM

## Related Rules

* [tslint-microsoft-contrib/no-inner-html](https://github.com/microsoft/tslint-microsoft-contrib/blob/master/src/noInnerHtml.ts)
- [tslint-microsoft-contrib/no-inner-html](https://github.com/microsoft/tslint-microsoft-contrib/blob/master/src/noInnerHtml.ts)
8 changes: 4 additions & 4 deletions docs/rules/no-inner-html.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

Assignments to [innerHTML](https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML)/[outerHTML](https://developer.mozilla.org/en-US/docs/Web/API/Element/outerHTML) properties or calls to [insertAdjacentHTML](https://developer.mozilla.org/en-US/docs/Web/API/Element/insertAdjacentHTML) method manipulate DOM directly without any sanitization and should be avoided. Use document.createElement() or similar methods instead.

* [Rule Source](../../lib/rules/no-inner-html.js)
* [Rule Test](../../tests/lib/rules/no-inner-html.js)
- [Rule Source](../../lib/rules/no-inner-html.js)
- [Rule Test](../../tests/lib/rules/no-inner-html.js)

## Related Rules

* [tslint-microsoft-contrib/no-inner-html](https://github.com/microsoft/tslint-microsoft-contrib/blob/master/src/noInnerHtml.ts)
* [eslint-plugin-no-unsanitized](https://github.com/mozilla/eslint-plugin-no-unsanitized/blob/master/docs/rules/method.md)
- [tslint-microsoft-contrib/no-inner-html](https://github.com/microsoft/tslint-microsoft-contrib/blob/master/src/noInnerHtml.ts)
- [eslint-plugin-no-unsanitized](https://github.com/mozilla/eslint-plugin-no-unsanitized/blob/master/docs/rules/method.md)
14 changes: 7 additions & 7 deletions docs/rules/no-insecure-random.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ Use crypto.randomBytes() or window.crypto.getRandomValues() instead.

## Related Rules

* [tslint-microsoft-contrib/no-insecure-random](https://github.com/microsoft/tslint-microsoft-contrib/blob/master/src/insecureRandomRule.ts)
- https://help.semmle.com/wiki/display/JS/Insecure+randomness
- [tslint-microsoft-contrib/no-insecure-random](https://github.com/microsoft/tslint-microsoft-contrib/blob/master/src/insecureRandomRule.ts)

* https://help.semmle.com/wiki/display/JS/Insecure+randomness
- [source](https://github.com/github/codeql/blob/master/javascript/ql/src/semmle/javascript/security/dataflow/InsecureRandomnessCustomizations.qll)
- https://vulncat.fortify.com/en/detail?id=desc.semantic.abap.insecure_randomness#JavaScript
- https://rules.sonarsource.com/javascript/RSPEC-2245
* https://vulncat.fortify.com/en/detail?id=desc.semantic.abap.insecure_randomness#JavaScript
* https://rules.sonarsource.com/javascript/RSPEC-2245
- [source](https://github.com/SonarSource/SonarJS/blob/master/eslint-bridge/src/rules/pseudo-random.ts)
- https://github.com/nodesecurity/eslint-plugin-security/blob/master/rules/detect-pseudoRandomBytes.js
- https://github.com/gkouziik/eslint-plugin-security-node/blob/master/lib/rules/detect-insecure-randomness.js

* https://github.com/nodesecurity/eslint-plugin-security/blob/master/rules/detect-pseudoRandomBytes.js
* https://github.com/gkouziik/eslint-plugin-security-node/blob/master/lib/rules/detect-insecure-randomness.js
Loading

0 comments on commit 8c106fe

Please sign in to comment.