Skip to content

Commit

Permalink
Include files from a source-directory if that source-directory is in …
Browse files Browse the repository at this point in the history
…elm-stuff
  • Loading branch information
jfmengels committed Nov 29, 2024
1 parent a9cbfa8 commit 181d721
Show file tree
Hide file tree
Showing 11 changed files with 137 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ build/Release
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
node_modules
elm-stuff
!test/project-with-files-in-elm-stuff/elm-stuff/src
temporary
build/

Expand Down
4 changes: 1 addition & 3 deletions lib/elm-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,6 @@ async function findFiles(isFromCliArguments, directory) {
return await findFromFolder(directory, path_);
}

const globIgnore = ['**/elm-stuff/**'];

/**
* Find Elm files in directory
*
Expand Down Expand Up @@ -343,7 +341,7 @@ async function findFromFolder(directory, path_) {
return {
files: await glob(`${path_}/**/*.elm`, {
nocase: true,
ignore: globIgnore,
ignore: [`${path_}/**/elm-stuff/**`],
nodir: false
}),
directory
Expand Down
25 changes: 25 additions & 0 deletions test/project-with-files-in-elm-stuff/elm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"type": "application",
"source-directories": [
"src",
"elm-stuff/src"
],
"elm-version": "0.19.1",
"dependencies": {
"direct": {
"elm/browser": "1.0.2",
"elm/core": "1.0.5",
"elm/html": "1.0.0"
},
"indirect": {
"elm/json": "1.1.3",
"elm/time": "1.0.0",
"elm/url": "1.0.0",
"elm/virtual-dom": "1.0.3"
}
},
"test-dependencies": {
"direct": {},
"indirect": {}
}
}
33 changes: 33 additions & 0 deletions test/project-with-files-in-elm-stuff/review/elm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"type": "application",
"source-directories": [
"src"
],
"elm-version": "0.19.1",
"dependencies": {
"direct": {
"elm/core": "1.0.5",
"elm/json": "1.1.3",
"elm/project-metadata-utils": "1.0.2",
"jfmengels/elm-review": "2.14.1",
"jfmengels/elm-review-unused": "1.2.3",
"stil4m/elm-syntax": "7.3.7"
},
"indirect": {
"elm/bytes": "1.0.8",
"elm/html": "1.0.0",
"elm/parser": "1.1.0",
"elm/random": "1.0.0",
"elm/regex": "1.0.0",
"elm/time": "1.0.0",
"elm/virtual-dom": "1.0.3",
"elm-explorations/test": "2.2.0",
"rtfeldman/elm-hex": "1.0.0",
"stil4m/structured-writer": "1.0.3"
}
},
"test-dependencies": {
"direct": {},
"indirect": {}
}
}
21 changes: 21 additions & 0 deletions test/project-with-files-in-elm-stuff/review/src/ReviewConfig.elm
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module ReviewConfig exposing (config)

{-| Do not rename the ReviewConfig module or the config function, because
`elm-review` will look for these.
To add packages that contain rules, add them to this review project using
`elm install author/packagename`
when inside the directory containing this file.
-}

import NoUnused.Variables
import Review.Rule exposing (Rule)


config : List Rule
config =
[ NoUnused.Variables.rule
]
5 changes: 5 additions & 0 deletions test/project-with-files-in-elm-stuff/src/Folder/Unused.elm
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module Folder.Unused exposing (..)


a =
1
6 changes: 6 additions & 0 deletions test/project-with-files-in-elm-stuff/src/Folder/Used.elm
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module Folder.Used exposing (one)


one : Int
one =
1
6 changes: 6 additions & 0 deletions test/project-with-files-in-elm-stuff/src/Main.elm
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module Main exposing (..)

import Util as List
import UtilNotUsed as List

useImportAliasFromElmstuff x = List.test x
3 changes: 3 additions & 0 deletions test/project-with-files-in-elm-stuff/src/UtilNotUsed.elm
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module UtilNotUsed exposing (x)

x = 1
7 changes: 7 additions & 0 deletions test/review.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,10 @@ test('Running on project with a directory ending in .elm (with arg)', async () =
);
expect(output).toMatchFile(testName('src.elm-project-with-arg'));
});

test('Includes files from a source-directory if that source-directory is in elm-stuff', async () => {
const output = await TestCli.runAndExpectError('',
{project: 'project-with-files-in-elm-stuff'}
);
expect(output).toMatchFile(testName('src.elm-project-with-files-in-elm-stuff'));
});
29 changes: 29 additions & 0 deletions test/snapshots/review/src.elm-project-with-files-in-elm-stuff.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
-- ELM-REVIEW ERROR --------------------------------- elm-stuff/src/Util.elm:6:1

(fix) NoUnused.Variables: Top-level variable `unused` is not used

6| unused = 1
^^^^^^

You should either use this value somewhere, or remove it at the location I
pointed at.

elm-stuff/src/Util.elm ↑
====o======================================================================o====
↓ src/Main.elm


-- ELM-REVIEW ERROR ------------------------------------------ src/Main.elm:4:23

(fix) NoUnused.Variables: Module alias `List` is not used

3| import Util as List
4| import UtilNotUsed as List
^^^^

You should either use this value somewhere, or remove it at the location I
pointed at.

Errors marked with (fix) can be fixed automatically using `elm-review --fix`.

I found 2 errors in 2 files.

0 comments on commit 181d721

Please sign in to comment.