Need help with configuring my TSLint rule ordered-imports
. I want the import order to be like this:
// React
import React from 'react';
import { View } from 'react-native';
// Libs
import * as _ from 'lodash';
import * as moment from 'moment';
// Internal libs
import Bar from '@app/bar';
import Foo from '@app/foo';
// Relative paths
import { Element } from './my-element';
import MyFunction from './my-function';
Even though I've tried creating a rule, it's not working as expected.
I'm having trouble matching absolute imports other than react
, using null
or non-react matches like ^!react
doesn't seem to work.
Here are my rules
{
"ordered-imports": [
true,
{
"module-source-path": "full",
"grouped-imports": true,
"groups": [
{
"name": "react",
"match": "^react",
"order": 1
},
{
"name": "node_modules",
"match": null,
"order": 2
},
{
"name": "internal modules",
"match": "^@app",
"order": 3
},
{
"name": "relative dir",
"match": "^[.]",
"order": 4
}
]
}
]
}
If anyone can point out what I'm missing, that would be greatly appreciated. Thank you!