-
-
Notifications
You must be signed in to change notification settings - Fork 928
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
Typescript config support #4947
Typescript config support #4947
Conversation
Maybe system tests will help you |
Does this change require users to install "typescript" due to "peerDependencies" of "ts-node"? |
I think we need to add "typescript" to "dependencies" to not require the user to install it. |
Installing TypeScript for 99.999% of users, who don't need it is bad. Also showing peer dependency warning about it. We need different solution, probably. |
I agree with @ota-meshi and @hudochenkov. So, I suggest another solution as follows:
diff --git a/lib/createStylelint.js b/lib/createStylelint.js
index 3d0b17aa..39a6c438 100644
--- a/lib/createStylelint.js
+++ b/lib/createStylelint.js
@@ -8,9 +8,13 @@ const getPostcssResult = require('./getPostcssResult');
const isPathIgnored = require('./isPathIgnored');
const lintSource = require('./lintSource');
const path = require('path');
-const typescriptLoader = require('@endemolshinegroup/cosmiconfig-typescript-loader').default;
const { cosmiconfig } = require('cosmiconfig');
+const typescriptLoader = (...args) => {
+ const loader = require('@endemolshinegroup/cosmiconfig-typescript-loader').default;
+ return loader(...args);
+}
+
const IS_TEST = process.env.NODE_ENV === 'test';
const STOP_DIR = IS_TEST ? path.resolve(__dirname, '..') : undefined;
diff --git a/package.json b/package.json
index 841913d6..7510b222 100644
--- a/package.json
+++ b/package.json
@@ -110,7 +110,6 @@
]
},
"dependencies": {
- "@endemolshinegroup/cosmiconfig-typescript-loader": "^3.0.2",
"@stylelint/postcss-css-in-js": "^0.37.2",
"@stylelint/postcss-markdown": "^0.36.1",
"autoprefixer": "^9.8.6",
@@ -161,6 +160,7 @@
"write-file-atomic": "^3.0.3"
},
"devDependencies": {
+ "@endemolshinegroup/cosmiconfig-typescript-loader": "^3.0.2",
"@stylelint/prettier-config": "^2.0.0",
"@stylelint/remark-preset": "^1.0.0",
"@types/balanced-match": "^1.0.1",
@@ -196,6 +196,14 @@
"remark-cli": "^8.0.1",
"typescript": "^3.9.6"
},
+ "peerDependencies": {
+ "@endemolshinegroup/cosmiconfig-typescript-loader": ">=3.0.2"
+ },
+ "peerDependenciesMeta": {
+ "@endemolshinegroup/cosmiconfig-typescript-loader": {
+ "optional": true
+ }
+ },
"engines": {
"node": ">=10.13.0"
} |
0f41be6
to
2f7bbbf
Compare
Thank you for your comment @ybiquitous! I have just pushed the changes, but it seems like I need to work on this a little more because some checks are failing. |
@jesusbotella I think the following ways can resolve the errors:
Explicitly set the missing types as follows: --- a/lib/createStylelint.js
+++ b/lib/createStylelint.js
@@ -10,10 +10,14 @@ const lintSource = require('./lintSource');
const path = require('path');
const { cosmiconfig } = require('cosmiconfig');
-const typescriptLoader = (...args) => {
+/**
+ * @param {string} filepath
+ * @param {string} content
+ */
+const typescriptLoader = (filepath, content) => {
const loader = require('@endemolshinegroup/cosmiconfig-typescript-loader').default;
- return loader(...args);
+ return loader(filepath, content);
};
const IS_TEST = process.env.NODE_ENV === 'test';
Add the package also to --- a/package.json
+++ b/package.json
@@ -160,6 +160,7 @@
"write-file-atomic": "^3.0.3"
},
"devDependencies": {
+ "@endemolshinegroup/cosmiconfig-typescript-loader": "^3.0.2",
"@stylelint/prettier-config": "^2.0.0",
"@stylelint/remark-preset": "^1.0.0",
"@types/balanced-match": "^1.0.1", |
Closing following discussion in #4940 and solution prorposed in #4940 (comment) |
Closes #4940.
I think it is self-explanatory, but I have two doubts: