Skip to content

Commit fc629be

Browse files
committed
Add common Sass TypeScript configuration to the analysis package
1 parent a42925c commit fc629be

File tree

13 files changed

+112
-24
lines changed

13 files changed

+112
-24
lines changed

.github/dependabot.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
version: 2
22
updates:
33
- package-ecosystem: "pub"
4-
directory: "/"
4+
directories:
5+
- "/"
6+
- "/analysis"
57
schedule:
68
interval: "weekly"
79
- package-ecosystem: "github-actions"
@@ -13,6 +15,7 @@ updates:
1315
- package-ecosystem: "npm"
1416
directories:
1517
- "/"
18+
- "/analysis"
1619
- "/package"
1720
- "/pkg/sass-parser"
1821
ignore:

analysis/.eslintrc

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"extends": "./node_modules/gts/",
3+
"plugins": ["import"],
4+
"rules": {
5+
"@typescript-eslint/explicit-function-return-type": [
6+
"error",
7+
{"allowExpressions": true}
8+
],
9+
"func-style": ["error", "declaration"],
10+
"prefer-const": ["error", {"destructuring": "all"}],
11+
// It would be nice to sort import declaration order as well, but that's not
12+
// autofixable and it's not worth the effort of handling manually.
13+
"sort-imports": ["error", {"ignoreDeclarationSort": true}],
14+
},
15+
"overrides": [
16+
{
17+
"files": ["**/*.ts"],
18+
"rules": {
19+
"import/no-commonjs": "error"
20+
}
21+
}
22+
]
23+
}

analysis/.prettierrc.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
...require('gts/.prettierrc.json'),
3+
};

analysis/README.md

Lines changed: 54 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,65 @@
1-
This package provides a shared set of analysis options for use by Sass team
2-
packages. To use it, add it as a Git dependency to your `pubspec.yaml`:
1+
This package provides a shared static analysis configuration for use by Sass
2+
team Dart and TypeScript packages.
3+
4+
## Use from Dart
5+
6+
Add this as a Git dependency to your `pubspec.yaml`:
37

48
```yaml
59
dev_dependencies:
610
sass_analysis:
7-
git: {url:
8-
https://github.com/sass/dart-sass.git, path: analysis}
11+
git: {url: https://github.com/sass/dart-sass.git, path: analysis}
912
```
1013
1114
and include it in your `analysis_options.yaml`:
1215

1316
```yaml
1417
include: package:sass_analysis/analysis_options.yaml
1518
```
19+
20+
## Use from TypeScript
21+
22+
Add this and [gts] as Git dependencies to your `package.json`, then initialize
23+
gts:
24+
25+
[gts]: https://github.com/google/gts
26+
27+
```sh
28+
$ npm i --save-dev gts 'https://gitpkg.vercel.app/sass/dart-sass/analysis?main'
29+
$ npx gts init
30+
```
31+
32+
Then edit the configuration files to use Sass-specific customizations instead of
33+
the gts defaults:
34+
35+
* `eslintrc.json`:
36+
37+
```json
38+
{
39+
"extends": "./node_modules/sass-analysis/"
40+
}
41+
```
42+
43+
* `.prettierrc.js`:
44+
45+
```json
46+
module.exports = {
47+
...require(sass-analysis/.prettierrc.js')
48+
}
49+
```
50+
51+
* `tsconfig.json`:
52+
53+
```json
54+
{
55+
"extends": "./node_modules/sass-analysis/tsconfig.json",
56+
"compilerOptions": {
57+
"rootDir": ".",
58+
"outDir": "build"
59+
},
60+
"include": [
61+
"src/**/*.ts",
62+
"test/**/*.ts"
63+
]
64+
}
65+
```

analysis/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
const fs = require('node:fs');
2+
const jsonc = require('jsonc-parser');
3+
4+
module.exports = jsonc.parse(
5+
fs.readFileSync(require.resolve('./.eslintrc'), 'utf8')
6+
);

analysis/package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "sass-analysis",
3+
"version": "0.0.0",
4+
"description": "Shared static analysis options for Sass team packages.",
5+
"dependencies": {
6+
"eslint-plugin-import": "^2.30.0",
7+
"gts": "^5.0.0",
8+
"jsonc-parser": "^3.3.1"
9+
}
10+
}

analysis/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: sass_analysis
22
version: 0.0.0
33
description: Shared analysis options for Sass team packages.
4-
homepage: https://github.com/sass/dart-sass/tree/master/analysis
4+
homepage: https://github.com/sass/dart-sass/tree/main/analysis
55

66
publish_to: none
77

analysis/tsconfig.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "./node_modules/gts/tsconfig-google.json"
3+
}

pkg/sass-parser/.eslintrc

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,3 @@
11
{
2-
"extends": "./node_modules/gts/",
3-
"rules": {
4-
"@typescript-eslint/explicit-function-return-type": [
5-
"error",
6-
{"allowExpressions": true}
7-
],
8-
"func-style": ["error", "declaration"],
9-
"prefer-const": ["error", {"destructuring": "all"}],
10-
// It would be nice to sort import declaration order as well, but that's not
11-
// autofixable and it's not worth the effort of handling manually.
12-
"sort-imports": ["error", {"ignoreDeclarationSort": true}],
13-
}
2+
"extends": "./node_modules/sass-analysis/"
143
}

pkg/sass-parser/.prettierrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module.exports = {
2-
...require('gts/.prettierrc.json'),
2+
...require('sass-analysis/.prettierrc.js'),
33
};

0 commit comments

Comments
 (0)