Permalink
Cannot retrieve contributors at this time
39 lines (25 sloc)
1.06 KB
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
codeql-action/node_modules/eslint-plugin-import/docs/rules/no-webpack-loader-syntax.md
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# import/no-webpack-loader-syntax | |
<!-- end auto-generated rule header --> | |
Forbid Webpack loader syntax in imports. | |
[Webpack](https://webpack.js.org) allows specifying the [loaders](https://webpack.js.org/concepts/loaders/) to use in the import source string using a special syntax like this: | |
```js | |
var moduleWithOneLoader = require("my-loader!./my-awesome-module"); | |
``` | |
This syntax is non-standard, so it couples the code to Webpack. The recommended way to specify Webpack loader configuration is in a [Webpack configuration file](https://webpack.js.org/concepts/loaders/#configuration). | |
## Rule Details | |
### Fail | |
```js | |
import myModule from 'my-loader!my-module'; | |
import theme from 'style!css!./theme.css'; | |
var myModule = require('my-loader!./my-module'); | |
var theme = require('style!css!./theme.css'); | |
``` | |
### Pass | |
```js | |
import myModule from 'my-module'; | |
import theme from './theme.css'; | |
var myModule = require('my-module'); | |
var theme = require('./theme.css'); | |
``` | |
## When Not To Use It | |
If you have a project that doesn't use Webpack you can safely disable this rule. |