Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include files from a source-directory if that source-directory is in elm-stuff #321

Merged
merged 1 commit into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/Util.elm
temporary
build/

Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- The `--compiler` flag now additionally resolves the compiler path using the `PATH` environment variable (more easily enabling `elm-review --compiler lamdera` for instance).
- The `--elm-format-path` flag now additionally resolves the path to `elm-format` using the `PATH` environment variable.
- Fixed an issue where the initial rule created with `elm-review new-package` was always a module rule, even when it was requested to be a project rule. Thanks to [@mateusfpleite](https://github.com/mateusfpleite)!
- Fixed an issue where files in source-directories under `elm-stuff/` would not be included in the analysis.
- Plenty of behind the scenes improvement to the maintenance of the repository. Thanks to [@lishaduck](https://github.com/lishaduck) for all of those.

## [2.12.0] - 2024-06-14
Expand Down
6 changes: 2 additions & 4 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 All @@ -309,7 +307,7 @@ async function findForCliArguments(directory, path_) {
return {
files: await glob(path_, {
nocase: true,
ignore: globIgnore,
ignore: [`${path_}/**/elm-stuff/**`],
nodir: true
}),
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
6 changes: 6 additions & 0 deletions test/project-with-files-in-elm-stuff/elm-stuff/src/Util.elm
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module Util exposing (test)

test : a -> a
test x = x

unused = 1
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
9 changes: 9 additions & 0 deletions test/review.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,12 @@ 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.
Loading