|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
1.1 KB
|
| Line | |
|---|
| 1 | # import/no-webpack-loader-syntax
|
|---|
| 2 |
|
|---|
| 3 | <!-- end auto-generated rule header -->
|
|---|
| 4 |
|
|---|
| 5 | Forbid Webpack loader syntax in imports.
|
|---|
| 6 |
|
|---|
| 7 | [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:
|
|---|
| 8 |
|
|---|
| 9 | ```js
|
|---|
| 10 | var moduleWithOneLoader = require("my-loader!./my-awesome-module");
|
|---|
| 11 | ```
|
|---|
| 12 |
|
|---|
| 13 | 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).
|
|---|
| 14 |
|
|---|
| 15 | ## Rule Details
|
|---|
| 16 |
|
|---|
| 17 | ### Fail
|
|---|
| 18 |
|
|---|
| 19 | ```js
|
|---|
| 20 | import myModule from 'my-loader!my-module';
|
|---|
| 21 | import theme from 'style!css!./theme.css';
|
|---|
| 22 |
|
|---|
| 23 | var myModule = require('my-loader!./my-module');
|
|---|
| 24 | var theme = require('style!css!./theme.css');
|
|---|
| 25 | ```
|
|---|
| 26 |
|
|---|
| 27 | ### Pass
|
|---|
| 28 |
|
|---|
| 29 | ```js
|
|---|
| 30 | import myModule from 'my-module';
|
|---|
| 31 | import theme from './theme.css';
|
|---|
| 32 |
|
|---|
| 33 | var myModule = require('my-module');
|
|---|
| 34 | var theme = require('./theme.css');
|
|---|
| 35 | ```
|
|---|
| 36 |
|
|---|
| 37 | ## When Not To Use It
|
|---|
| 38 |
|
|---|
| 39 | If you have a project that doesn't use Webpack you can safely disable this rule.
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.