I'm trying to configure my TSLint rule ordered-imports
to get the import order looking 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';
This is the rule I've tried to create but I still can't get to a point where the above works.
I don't seem to be able to match with absolute imports other than react
ones, I've tried to use null
as well as non-react match like ^!react
but it doesn't work.
This is 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
}
]
}
]
}
Can someone help me figuring out what I'm doing wrong?
Thanks