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

chore: patterns test #204

Merged
merged 1 commit into from
May 29, 2024
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
21 changes: 21 additions & 0 deletions .grit/patterns/js/sonar_autorepair.grit
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
pattern sonar_autorepair() {
or {
`class App extends $comp { $props }` where {
$props <: contains bubble or {
`static $var = $value` => `static readonly $var = $value`,
comment() => .,
`await alert($alert)` => `alert($alert)`
},
},
`function MyApp($_) { $_}` as $base where {
$base += `MyApp.propTypes = {
Component: PropTypes.elementType.isRequired,
pageProps: PropTypes.object
}`,
$propTypes = `PropTypes`,
$program <: contains import_statement() as $import where {
$import += `import PropTypes from 'prop-types'`
}
}
}
}
55 changes: 55 additions & 0 deletions .grit/patterns/js/sonar_fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# SonarCloud Integration

Improve code quality by automatically remediating issues found by SonarCloud.

```grit
language js

sonar_autorepair()
```

## Sample

```js
import { Component } from 'react';
class App extends Component {
static readonly oneProp = "hi";

alertName = () => {
await alert(this.state.name);
};

render() {
return (
<div>
<h3>This is a somewhat bad component</h3>
<button onClick={this.alertName}>
Alarm!
</button>
</div>
);
}
}
```

```js
import { Component } from 'react';
class App extends Component {
static readonly oneProp = "hi";

alertName = () => {
alert(this.state.name);
};

render() {
return (
<div>
<h3>This is a somewhat bad component</h3>
<button onClick={this.alertName}>
Alarm!
</button>
</div>
);
}
}
```
Loading