-
Notifications
You must be signed in to change notification settings - Fork 198
Consider improving config options for import-name #452
Comments
Since dependency names are unique, I would use those as keys in the config object. The values in the config object would be the allowed name it can be imported as. |
I agree with levithomason Other things to consider (and possibly get feedback on) would be:
{
"sequelize-typescript": "sequelize"
} Then in the code: import sequelizeTypescript from "sequelize-typescript";
import sequelize from "sequelize";
sequelizeTypescript.configure(sequelize) And elsewhere import sequelize from "sequelize-typescript"; So, all in all, my personal vote is for what @levithomason suggested in the other issue, but to still also allow the default name of the module too so that we can deal with the above scenarios. Edit: However, it might also be possible to deal with the above scenarios using tslint ignores. Maybe allowing the default name should be configurable? |
I would also say no, as it goes against the heart of the rule which is to standardize import names.
Also no, for the same reason as above. I would lean toward making it very explicit with no special casing. In my experience, special cases tend to stack up and lead to complications whereas explicit and simple code is more maintainable. One last idea I had while setting this up was about allowing pattern matching or someway to say "camelCase" as the import style. Specifically, I was mapping lots modules that started with the same prefix (e.g. |
Please consider an option to ignore file extensions. In this example: import example from './example.svg'; the suggested name is |
Not too much magic, it's a common use case IMO.
I don't think these are special cases; I agree it should be explicit, but there is much to consider IRT import names and it should have robust configuration. The way I see it, there are a few separate concerns being discussed here: Renaming/Collisions {
"rename": {
"server": "srv",
"react-dom/server": "ReactDOMServer"
}
} I think it should accept the existing behavior and allow for longer path matches, choosing the longest match as the winner. IRT, example code: import sequelizeTypescript from "sequelize-typescript";
import sequelize from "sequelize";
sequelizeTypescript.configure(sequelize) I think tslint ignore is satisfactory in this case. Prefixes/Suffixes {
"ignore-prefix": [
"babel-plugin-",
"gulp-"
],
"ignore-suffix": [
".json",
".svg",
"-ts",
"-typescript"
]
} I found this discussion in the process of creating a feature request for the Edge Cases/Bulk Behavior {
"overrides": {
"gulp-*": {},
"sequelize-typescript": {},
}
} This configuration would have a pattern as the key and accept the entire rule schema as the value. I'm not sure how I feel about this one, but it was an idea to address the wildcard matching mentioned earlier. It can be pretty powerful in handling unknown corner cases and would pair nicely with something like an Edit I was thinking something like a tandem set of rules auth-service/index.ts const AuthService = {};
export default AuthService; auth-service/violation.ts import Service from '.'; auth-service/good.ts import AuthService from '.'; |
☠️ It's time! ☠️ Per #876, this repository is no longer accepting feature pull requests. TSLint is being deprecated and we recommend you switch to https://typescript-eslint.io. Thanks for open sourcing with us, everyone! |
Continuing discussion from #429: how do we allow full import names, such as
"react-dom/server"
?/cc @massimonewsuk @levithomason
The text was updated successfully, but these errors were encountered: