This repository was archived by the owner on Mar 20, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 7 files changed +69
-0
lines changed
resources/eslint-internal-rules Expand file tree Collapse file tree 7 files changed +69
-0
lines changed Original file line number Diff line number Diff line change 6
6
node : true
7
7
reportUnusedDisableDirectives : true
8
8
plugins :
9
+ - internal-rules
9
10
- flowtype
10
11
- node
11
12
- istanbul
12
13
- import
13
14
14
15
rules :
16
+ # #############################################################################
17
+ # Internal rules located in 'resources/eslint-internal-rules'.
18
+ # See './resources/eslint-internal-rules/README.md'
19
+ # #############################################################################
20
+
21
+ internal-rules/no-dir-import : error
22
+
15
23
# #############################################################################
16
24
# `eslint-plugin-flowtype` rule list based on `v5.1.x`
17
25
# https://github.com/gajus/eslint-plugin-flowtype#eslint-plugin-flowtype
Original file line number Diff line number Diff line change 63
63
"dtslint" : " 3.6.10" ,
64
64
"eslint" : " 7.1.0" ,
65
65
"eslint-plugin-flowtype" : " 5.1.3" ,
66
+ "eslint-plugin-internal-rules" : " file:./resources/eslint-internal-rules" ,
66
67
"eslint-plugin-import" : " 2.20.2" ,
67
68
"eslint-plugin-istanbul" : " 0.1.1" ,
68
69
"eslint-plugin-node" : " 11.1.0" ,
Original file line number Diff line number Diff line change
1
+ # Custom ESLint Rules
2
+
3
+ This is a dummy npm package that allows us to treat it as an ` eslint-plugin-graphql-internal ` .
4
+ It's not actually published, nor are the rules here useful for users of graphql.
5
+
6
+ ** If you modify this rule, you must re-run ` npm install ` for it to take effect.**
Original file line number Diff line number Diff line change
1
+ // @noflow
2
+
3
+ 'use strict' ;
4
+
5
+ module . exports = {
6
+ rules : {
7
+ 'no-dir-import' : require ( './no-dir-import' ) ,
8
+ } ,
9
+ } ;
Original file line number Diff line number Diff line change
1
+ // @noflow
2
+
3
+ 'use strict' ;
4
+
5
+ const fs = require ( 'fs' ) ;
6
+ const path = require ( 'path' ) ;
7
+
8
+ module . exports = function ( context ) {
9
+ return {
10
+ ImportDeclaration : checkImportPath ,
11
+ ExportNamedDeclaration : checkImportPath ,
12
+ } ;
13
+
14
+ function checkImportPath ( node ) {
15
+ const { source } = node ;
16
+
17
+ // bail if the declaration doesn't have a source, e.g. "export { foo };"
18
+ if ( ! source ) {
19
+ return ;
20
+ }
21
+
22
+ const importPath = source . value ;
23
+ if ( importPath . startsWith ( './' ) || importPath . startsWith ( '../' ) ) {
24
+ const baseDir = path . dirname ( context . getFilename ( ) ) ;
25
+ const resolvedPath = path . resolve ( baseDir , importPath ) ;
26
+
27
+ if (
28
+ fs . existsSync ( resolvedPath ) &&
29
+ fs . statSync ( resolvedPath ) . isDirectory ( )
30
+ ) {
31
+ context . report ( {
32
+ node : source ,
33
+ message : 'It is not allowed to import from directory' ,
34
+ } ) ;
35
+ }
36
+ }
37
+ }
38
+ } ;
Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " eslint-plugin-graphql-internal" ,
3
+ "version" : " 0.0.0"
4
+ }
Original file line number Diff line number Diff line change 1983
1983
read-pkg-up "^2.0.0"
1984
1984
resolve "^1.12.0"
1985
1985
1986
+ " eslint-plugin-internal-rules@file:./resources/eslint-internal-rules " :
1987
+ version "0.0.0"
1988
+
1986
1989
1987
1990
version "0.1.1"
1988
1991
resolved "https://registry.yarnpkg.com/eslint-plugin-istanbul/-/eslint-plugin-istanbul-0.1.1.tgz#6289daca3844f6ae1fc23a29093d8554fc7dc352"
You can’t perform that action at this time.
0 commit comments