@takurinton/tsserver-plugin-limit-import-scope
What
A plugin that follows the fluct_ms code convention. Prevents modules from being imported from patterns other than the specified pattern. Completion does not work when importing from a path other than the specified path.
Install
npm
npm i --save-dev @takurinton/tsserrver-plugin-limit-import-scope
yarn
yarn add -D @takurinton/tsserrver-plugin-limit-import-scope
Usage
In tsconfig.json
{
"compilerOptions": {
"plugins": [
{
"name": "@takurinton/tsserver-plugin-limit-import-scope",
"patterns": ["./internal/**", "./styled", "utils"]
}
]
}
}
Example
Specify the paths you want to allow in patterns.
// tsconfig.json
{
"compilerOptions": {
"plugins": [
{
"name": "@takurinton/tsserver-plugin-limit-import-scope",
"patterns": ["./internal/**", "./styled", "utils"]
}
]
}
}
Allowed Patterns and modules contained in node_modules are allowed.
Not allowed ../Piyo/internal/useForm
will not be completed.
// app/src/Home/index.tsx
import React from "react"; // completion work
import { useForm } from "../Piyo/internal/useForm"; // completion doesn't work
import { Component } from "./internal/Components"; // completion work
import { hoge } from "../../../utils/hoge"; // completion work
import * as Styled from "./styled"; // completion work
export const Home = () => {
return (
<div>
<p>hello world</p>
<Component />
</div>
);
};