Skip to content

Commit 92a3370

Browse files
AbhiPrasadkamilogorek
authored andcommitted
feat: Create packages for sentry eslint config
1 parent 8eb7286 commit 92a3370

File tree

13 files changed

+258
-36
lines changed

13 files changed

+258
-36
lines changed

.eslintignore

Lines changed: 0 additions & 4 deletions
This file was deleted.

eslint-plugin-sentry-sdks/package.json

Lines changed: 0 additions & 11 deletions
This file was deleted.

packages/eslint-config/.npmignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*
2+
!/index.js

packages/eslint-config/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 Sentry (https://sentry.io/) and individual contributors.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

packages/eslint-config/README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<p align="center">
2+
<a href="https://sentry.io" target="_blank" align="center">
3+
<img src="https://sentry-brand.storage.googleapis.com/sentry-logo-black.png" width="280">
4+
</a>
5+
<br />
6+
</p>
7+
8+
# Official Sentry SDK eslint config
9+
10+
[![npm version](https://img.shields.io/npm/v/@sentry/integrations.svg)](https://www.npmjs.com/package/@sentry/integrations)
11+
[![npm dm](https://img.shields.io/npm/dm/@sentry/integrations.svg)](https://www.npmjs.com/package/@sentry/integrations)
12+
[![npm dt](https://img.shields.io/npm/dt/@sentry/integrations.svg)](https://www.npmjs.com/package/@sentry/integrations)
13+
[![typedoc](https://img.shields.io/badge/docs-typedoc-blue.svg)](http://getsentry.github.io/sentry-javascript/)
14+
15+
## Links
16+
17+
- [Official SDK Docs](https://docs.sentry.io/quickstart/)
18+
- [TypeDoc](http://getsentry.github.io/sentry-javascript/)
19+
20+
## General
21+
22+
Install with `yarn add -D @sentry/eslint-config`
23+
24+
## Configuration
25+
26+
Use `sentry-sdks` for base rules. Make sure to specify your tsconfig under `parserOptions.project` so that you can
27+
correctly use the typescript rules. This configuration comes with
28+
29+
```json
30+
{
31+
"extends": ["sentry-sdks"],
32+
"overrides": [
33+
{
34+
"files": ["*.ts", "*.tsx", "*.d.ts"],
35+
"parserOptions": {
36+
"project": "./tsconfig.json"
37+
}
38+
}
39+
]
40+
}
41+
```

.eslintrc.js renamed to packages/eslint-config/index.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ module.exports = {
44
node: true,
55
},
66
extends: ['prettier', 'eslint:recommended', 'plugin:import/errors', 'plugin:import/warnings'],
7-
plugins: ['sentry-sdks', 'simple-import-sort'],
8-
ignorePatterns: ['eslint-plugin-sentry-sdks'],
7+
plugins: ['@sentry', 'simple-import-sort'],
98
overrides: [
109
{
1110
// Configuration for JavaScript files
@@ -20,9 +19,6 @@ module.exports = {
2019
extends: ['plugin:@typescript-eslint/recommended', 'prettier/@typescript-eslint', 'plugin:import/typescript'],
2120
plugins: ['@typescript-eslint', 'jsdoc', 'deprecation'],
2221
parser: '@typescript-eslint/parser',
23-
parserOptions: {
24-
project: './tsconfig.json',
25-
},
2622
rules: {
2723
// Unused variables should be removed unless they are marked with and underscore (ex. _varName).
2824
'@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_' }],
@@ -105,13 +101,16 @@ module.exports = {
105101
files: ['src/**/*'],
106102
rules: {
107103
// We want to prevent async await usage in our files to prevent uncessary bundle size.
108-
'sentry-sdks/no-async-await': 'error',
104+
'@sentry/no-async-await': 'error',
109105

110106
// JSDOC comments are required for classes and methods. As we have a public facing codebase, documentation,
111107
// even if it may seems excessive at times, is important to emphasize. Turned off in tests.
112108
'jsdoc/require-jsdoc': [
113109
'error',
114-
{ require: { ClassDeclaration: true, MethodDefinition: true }, checkConstructors: false },
110+
{
111+
require: { ClassDeclaration: true, MethodDefinition: true },
112+
checkConstructors: false,
113+
},
115114
],
116115

117116
// All imports should be accounted for
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"name": "@sentry/eslint-config",
3+
"version": "5.20.1",
4+
"description": "Official Sentry SDK eslint config",
5+
"repository": "git://github.com/getsentry/sentry-javascript.git",
6+
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/eslint-config",
7+
"author": "Sentry",
8+
"license": "MIT",
9+
"keywords": [
10+
"eslint",
11+
"eslint-config",
12+
"sentry"
13+
],
14+
"engines": {
15+
"node": ">=6"
16+
},
17+
"main": "index.js",
18+
"files": [
19+
"index.js"
20+
],
21+
"publishConfig": {
22+
"access": "public"
23+
},
24+
"dependencies": {
25+
"@sentry/eslint-plugin": "5.20.1",
26+
"@sentry/typescript": "5.20.1",
27+
"@typescript-eslint/eslint-plugin": "^3.9.0",
28+
"@typescript-eslint/parser": "^3.9.0",
29+
"eslint-config-prettier": "^6.11.0",
30+
"eslint-plugin-deprecation": "^1.1.0",
31+
"eslint-plugin-import": "^2.22.0",
32+
"eslint-plugin-jsdoc": "^30.0.3",
33+
"eslint-plugin-simple-import-sort": "^5.0.3"
34+
},
35+
"devDependencies": {
36+
"eslint": ">=5",
37+
"prettier": "^1.17.0"
38+
},
39+
"scripts": {
40+
"link:yarn": "yarn link",
41+
"lint": "prettier-check \"{src,test}/**/*.ts\"",
42+
"fix": "prettier --write \"{src,test}/**/*.ts\""
43+
}
44+
}

packages/eslint-plugin/.npmignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*
2+
!/lib/**/*

packages/eslint-plugin/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 Sentry (https://sentry.io/) and individual contributors.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* @fileoverview eslint plugins for Sentry SDKs
3+
* @author Abhijeet Prasad
4+
*/
5+
'use strict';
6+
7+
//------------------------------------------------------------------------------
8+
// Plugin Definition
9+
//------------------------------------------------------------------------------
10+
11+
module.exports = {
12+
rules: {
13+
'no-async-await': require('./rules/no-async-await'),
14+
},
15+
};

0 commit comments

Comments
 (0)