All Projects → uhyo → eslint-plugin-import-access

uhyo / eslint-plugin-import-access

Licence: MIT license
www.npmjs.com/package/eslint-plugin-import-access

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to eslint-plugin-import-access

Eslint Plugin Unicorn
Various awesome ESLint rules
Stars: ✭ 2,157 (+957.35%)
Mutual labels:  eslint-plugin
Eslint Plugin Ember
An ESlint plugin that provides set of rules for Ember Applications based on commonly known good practices.
Stars: ✭ 240 (+17.65%)
Mutual labels:  eslint-plugin
eslint-plugin-gridsome
ESLint plugin for Gridsome
Stars: ✭ 45 (-77.94%)
Mutual labels:  eslint-plugin
Eslint Plugin Prettier
ESLint plugin for Prettier formatting
Stars: ✭ 2,228 (+992.16%)
Mutual labels:  eslint-plugin
Eslint Plugin Eslint Comments
Additional ESLint rules for directive comments of ESLint.
Stars: ✭ 221 (+8.33%)
Mutual labels:  eslint-plugin
Eslint Plugin Mocha
ESLint rules for mocha
Stars: ✭ 249 (+22.06%)
Mutual labels:  eslint-plugin
Eslint Plugin Css Modules
Project status: NOT MAINTAINED; Checks that you are using the existent css/scss classes, no more no less
Stars: ✭ 115 (-43.63%)
Mutual labels:  eslint-plugin
eslint-plugin-strict-dependencies
ESlint plugin to define custom module dependency rules.
Stars: ✭ 142 (-30.39%)
Mutual labels:  eslint-plugin
Eslint Import Resolver Babel Module
Custom eslint resolve for babel-plugin-module-resolver
Stars: ✭ 236 (+15.69%)
Mutual labels:  eslint-plugin
eslint-plugin-no-only-tests
ESLint rule for catching focused/only test blocks
Stars: ✭ 67 (-67.16%)
Mutual labels:  eslint-plugin
You Dont Need Lodash Underscore
List of JavaScript methods which you can use natively + ESLint Plugin
Stars: ✭ 13,915 (+6721.08%)
Mutual labels:  eslint-plugin
Eslint Plugin Ava
ESLint rules for AVA
Stars: ✭ 209 (+2.45%)
Mutual labels:  eslint-plugin
ultimate-hot-boilerplate
🚀 node-react universal app boilerplate with everything on hot reload, SSR, GraphQL, Flow included
Stars: ✭ 35 (-82.84%)
Mutual labels:  eslint-plugin
Eslint Plugin Boundaries
Eslint plugin checking architecture boundaries between elements
Stars: ✭ 157 (-23.04%)
Mutual labels:  eslint-plugin
eslint-plugin-aura
Salesforce Lightning (Aura) specific linting rules for ESLint
Stars: ✭ 24 (-88.24%)
Mutual labels:  eslint-plugin
Eslint Import Resolver Alias
a simple Node behavior import resolution plugin for eslint-plugin-import, supporting module alias
Stars: ✭ 121 (-40.69%)
Mutual labels:  eslint-plugin
Eslint Plugin Svelte3
An ESLint plugin for Svelte v3 components.
Stars: ✭ 248 (+21.57%)
Mutual labels:  eslint-plugin
eslint-plugin-header
ESLint plugin to ensure that files begin with given comment
Stars: ✭ 65 (-68.14%)
Mutual labels:  eslint-plugin
eslint-plugin-array-func
Rules for Array functions and methods.
Stars: ✭ 77 (-62.25%)
Mutual labels:  eslint-plugin
eslint-plugin-license-header
Rules to validate the presence of license headers in source files.
Stars: ✭ 21 (-89.71%)
Mutual labels:  eslint-plugin

eslint-plugin-import-access

What?

This package provides a typescript-eslint rule that restricts importing variables marked as @package from a file outside the same directory. Also, this package serves as a TypeScript Language Service Plugin that prevents auto-completion of such imports.

Why?

The largest encapsulation unit available for a TypeScript project is a file. That is, variables not exported from a file is only visible to code in the same file. Once a variable is exported, it is visible from the entire project.

Sometimes this is insufficient. A rational effort for proper encapsulation may result in a large file that is hard to maintain.

This package solves this problem by providing a new directory-level layer and enabling a “package-private” export that is only visible to files in the same directory.

Installation

npm i -D eslint-plugin-import-access

In .eslintrc.js:

  "plugins": [
    "import-access",
    // ...
  ],
  "rules": {
    "import-access/jsdoc": ["error"],
  }

In tsconfig.json:

{
  "compilerOptions": {
    // ...
    "plugins": [
      // ...
      {
        "name": "eslint-plugin-import-access"
      }
    ]
  }
}

Note: to enable TypeScript language service plugins installed locally, you must use TypeScript in node_modules, not the one bundled with VSCode.

Example

// ----- sub/foo.ts -----

/**
 * @package
 */
export const fooPackageVariable = "I am package-private export";

// ----- sub/bar.ts -----
// This is correct because foo.ts is in the same directory
import { fooPackageVariable } from "./foo";

// ----- baz.ts -----
// This is INCORRECT because package-private exports
// cannot be imported from outside the sub directory
import { fooPackageVariable } from "./sub/foo";

Rule References

Contributing

Welcome

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].