Compare commits

...

3 commits

Author SHA1 Message Date
Ananth Venkatesh
929360cd30
fix(elm-review): eliminate all issues 2025-02-01 03:44:59 -05:00
Ananth Venkatesh
f9d6147658
chore(elm): add elm-review config 2025-02-01 03:44:20 -05:00
Ananth Venkatesh
be8e419f66
chore(nix): add pre-commit checks 2025-02-01 03:42:40 -05:00
6 changed files with 211 additions and 17 deletions

1
.pre-commit-config.yaml Symbolic link
View file

@ -0,0 +1 @@
/nix/store/gnnangzf73g2b665rmhwblqydx18hjlm-pre-commit-config.json

View file

@ -44,6 +44,43 @@
"type": "github"
}
},
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1696426674,
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"gitignore": {
"inputs": {
"nixpkgs": [
"pre-commit-hooks",
"nixpkgs"
]
},
"locked": {
"lastModified": 1709087332,
"narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=",
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "gitignore.nix",
"type": "github"
}
},
"mkElmDerivation": {
"inputs": {
"elm-spa": "elm-spa",
@ -51,11 +88,11 @@
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1737249952,
"narHash": "sha256-bWOrcJUIW5q9BEmdeaE5XPnHiWuhujeFM23EweNMuO0=",
"lastModified": 1737854574,
"narHash": "sha256-GIh8IAIjJ3BkqSKifdXcnrkJgY4diipcMZ1itmwiFyw=",
"owner": "jeslie0",
"repo": "mkElmDerivation",
"rev": "dd8538d8bcddcb7245cfdffffdf8118b0013dc64",
"rev": "88b3923af364826b39428aff3431857a2b9d8699",
"type": "github"
},
"original": {
@ -82,11 +119,11 @@
},
"nixpkgs_2": {
"locked": {
"lastModified": 1737632463,
"narHash": "sha256-38J9QfeGSej341ouwzqf77WIHAScihAKCt8PQJ+NH28=",
"lastModified": 1738142207,
"narHash": "sha256-NGqpVVxNAHwIicXpgaVqJEJWeyqzoQJ9oc8lnK9+WC4=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "0aa475546ed21629c4f5bbf90e38c846a99ec9e9",
"rev": "9d3ae807ebd2981d593cddd0080856873139aa40",
"type": "github"
},
"original": {
@ -96,6 +133,22 @@
"type": "github"
}
},
"nixpkgs_3": {
"locked": {
"lastModified": 1730768919,
"narHash": "sha256-8AKquNnnSaJRXZxc5YmF/WfmxiHX6MMZZasRP6RRQkE=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "a04d33c0c3f1a59a2c1cb0c6e34cd24500e5a1dc",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"npm-fix": {
"inputs": {
"nixpkgs": [
@ -134,10 +187,31 @@
"type": "github"
}
},
"pre-commit-hooks": {
"inputs": {
"flake-compat": "flake-compat",
"gitignore": "gitignore",
"nixpkgs": "nixpkgs_3"
},
"locked": {
"lastModified": 1737465171,
"narHash": "sha256-R10v2hoJRLq8jcL4syVFag7nIGE7m13qO48wRIukWNg=",
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"rev": "9364dc02281ce2d37a1f55b6e51f7c0f65a75f17",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"type": "github"
}
},
"root": {
"inputs": {
"mkElmDerivation": "mkElmDerivation",
"nixpkgs": "nixpkgs_2",
"pre-commit-hooks": "pre-commit-hooks",
"utils": "utils"
}
},

View file

@ -5,6 +5,7 @@
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
utils.url = "github:numtide/flake-utils";
mkElmDerivation.url = "github:jeslie0/mkElmDerivation";
pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";
};
outputs =
@ -13,6 +14,7 @@
nixpkgs,
utils,
mkElmDerivation,
pre-commit-hooks,
}:
utils.lib.eachDefaultSystem (
system:
@ -26,10 +28,13 @@
devShells.default =
with pkgs;
mkShell {
buildInputs = [
inherit (self.checks.${system}.pre-commit-check) shellHook;
buildInputs = self.checks.${system}.pre-commit-check.enabledPackages ++ [
elmPackages.elm
elmPackages.elm-test
elmPackages.elm-format
elmPackages.elm-review
entr
];
};
@ -50,6 +55,18 @@
};
};
checks = {
pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = {
nixfmt-rfc-style.enable = true;
elm-format.enable = true;
# elm-review.enable = true;
# elm-test.enable = true;
};
};
};
formatter = nixpkgs.legacyPackages.${system}.nixfmt-rfc-style;
}
);

41
review/elm.json Normal file
View file

@ -0,0 +1,41 @@
{
"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-code-style": "1.2.0",
"jfmengels/elm-review-common": "1.3.3",
"jfmengels/elm-review-debug": "1.0.8",
"jfmengels/elm-review-documentation": "2.0.4",
"jfmengels/elm-review-simplify": "2.1.6",
"jfmengels/elm-review-unused": "1.2.3",
"stil4m/elm-syntax": "7.3.8"
},
"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",
"pzp1997/assoc-list": "1.0.0",
"rtfeldman/elm-hex": "1.0.0",
"stil4m/structured-writer": "1.0.3"
}
},
"test-dependencies": {
"direct": {
"elm-explorations/test": "2.2.0"
},
"indirect": {}
}
}

View file

@ -0,0 +1,57 @@
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 Docs.ReviewAtDocs
import NoConfusingPrefixOperator
import NoDebug.Log
import NoDebug.TodoOrToString
import NoExposingEverything
import NoImportingEverything
import NoMissingTypeAnnotation
import NoMissingTypeAnnotationInLetIn
import NoMissingTypeExpose
import NoPrematureLetComputation
import NoSimpleLetBody
import NoUnused.CustomTypeConstructorArgs
import NoUnused.CustomTypeConstructors
import NoUnused.Dependencies
import NoUnused.Exports
import NoUnused.Parameters
import NoUnused.Patterns
import NoUnused.Variables
import Review.Rule as Rule exposing (Rule)
import Simplify
config : List Rule
config =
[ Docs.ReviewAtDocs.rule
, NoConfusingPrefixOperator.rule
, NoDebug.Log.rule
, NoDebug.TodoOrToString.rule
|> Rule.ignoreErrorsForDirectories [ "tests/" ]
, NoExposingEverything.rule
, NoMissingTypeAnnotation.rule
, NoMissingTypeAnnotationInLetIn.rule
, NoMissingTypeExpose.rule
, NoSimpleLetBody.rule
, NoPrematureLetComputation.rule
, NoUnused.CustomTypeConstructors.rule []
, NoUnused.CustomTypeConstructorArgs.rule
, NoUnused.Dependencies.rule
, NoUnused.Exports.rule
, NoUnused.Parameters.rule
, NoUnused.Patterns.rule
, NoUnused.Variables.rule
, Simplify.rule Simplify.defaults
]

View file

@ -1,4 +1,4 @@
module Main exposing (main)
module Main exposing (Flags, Model, Msg, Object3d, main)
import Angle
import Array
@ -11,7 +11,7 @@ import Element exposing (..)
import Element.Background as Background
import Element.Font as Font
import Html exposing (Html)
import Http exposing (Error)
import Http
import Length
import Obj.Decode
import Pixels
@ -61,11 +61,6 @@ animatedEl =
animatedUi Element.el
animatedCol : Animation -> List (Element.Attribute msg) -> List (Element msg) -> Element msg
animatedCol =
animatedUi Element.column
main : Program Flags Model Msg
main =
Browser.document { init = init, update = update, subscriptions = subscribe, view = view }
@ -81,8 +76,10 @@ type alias Flags =
init : Flags -> ( Model, Cmd Msg )
init flags =
case flags of
( width, height ) ->
let
( width, height ) =
flags
in
( { w = width, h = height, mesh = Nothing, textures = Nothing, angle = 0 }, Cmd.batch [ getMesh, getTexture ] )
@ -236,23 +233,29 @@ pyramidMesh : Mesh.Uniform coordinates
pyramidMesh =
let
-- Define the vertices of our pyramid
frontLeft : Point3d Length.Meters coordinates
frontLeft =
Point3d.centimeters 250 500 0
frontRight : Point3d Length.Meters coordinates
frontRight =
Point3d.centimeters 400 0 -500
backLeft : Point3d Length.Meters coordinates
backLeft =
Point3d.centimeters -250 500 -500
backRight : Point3d Length.Meters coordinates
backRight =
Point3d.centimeters -250 0 0
tip : Point3d Length.Meters coordinates
tip =
Point3d.centimeters 0 0 500
-- Create a TriangularMesh value from an array of vertices and list
-- of index triples defining faces (see https://package.elm-lang.org/packages/ianmackenzie/elm-triangular-mesh/latest/TriangularMesh#indexed)
triangularMesh : TriangularMesh (Point3d Length.Meters coordinates)
triangularMesh =
TriangularMesh.indexed
(Array.fromList
@ -302,6 +305,7 @@ view3D model =
{ focalPoint = Point3d.origin
, eyePoint =
let
theta : Angle.Angle
theta =
Angle.degrees model.angle
in