Visitar URL original
Introduce a separate attribute for declaring a linter to only operate on the exact files · Issue #954 · SublimeLinter/SublimeLinter · GitHub
Skip to content

Introduce a separate attribute for declaring a linter to only operate on the exact files #954

Open

Description

@FichteFoll

Currently, you can declare a linter as a "file-only" linter setting tempfile_suffix to '-'. Its effects are that no temporary file is generated while modifying the view and instead the linter is only run on the saved file with its original path.

This API is quite unintuitive and should be replaced with a separate attribute just for that feature.

Related: #810.

Activity

  1. kaste commented on Feb 9, 2018

    @kaste
    Member

    Related #244 ? Isn't specifying a suffix yagni bc we can just use the filename suffix?

  2. kaste commented on Feb 9, 2018

    @kaste
    Member

    T.i. remove tempfile_suffix and instead expose lint_mode as a linter setting.

  3. braver commented on Feb 9, 2018

    @braver
    Member

    bc we can just use the filename suffix

    A buffer doesn't have to be associated with a file, e.g. it hasn't been saved yet. Also, if you lint embedded code by taking it out of the surrounding file and putting it in a temporary file, you can't use the original file's suffix.

    That said, especially in a unix-like context, programs that work on a file rarely care about that file's name. If a program receives a file to lint, it should usually just lint it unless the linter's author has been smoking something. I don't think you need a temp file suffix at all in 99% of cases. I do seem to remember that some php linter or other will not lint files that don't have .php at the end of their file name. So we may still need a tempfile_suffix at least as an optional thing for stupid stubborn linters.

    expose lint_mode as a linter setting

    This is an all around good idea.

  4. kaste commented on Feb 26, 2018

    @kaste
    Member

    Okay, just to summarize what I know:

    # exactly three modes
    mode = STDIN | TEMPORARY_FILE | REAL_FILE
    
    # which have different `cmd`s. E.g.
    cmd = 'eslint ${args} --stdin'  # variation cmd = 'eslint --stdin-filename ${file} --'
    cmd = 'eslint ${args} ${temporary_file}'
    cmd = 'eslint ${args} ${real_file}'
    

    But we cannot deduce the mode from 'cmd' unless we introduce an alias ${real_file} for ${file_name}.

    EDITED to make it proposal like, not just a thought

  5. FichteFoll commented on Feb 26, 2018

    @FichteFoll
    ContributorAuthor

    Currently ${tmpfilename} only refers to a tempfile in the temporary file lint mode (and isn't replaced otherwise) and ${file_name} always points to the "real file".
    I presume your proposal is to make ${real_file} represent the current ${file_name} behavior and let ${file_name} auto-adjust based on the lint mode? Sounds good to me. By the way, the variable naming scheme should be unified, so ${file} and ${temporary_file} instead of the current names sound good.

    Maybe support cmd overrides for each mode? The mypy linter could use this since it uses a different command switch to support temporary file linting in a project context. Especially for linters accepting stdin.
    (Note that STDIN and TEMPORARY_FILE are exclusive and the former would be preferred.)

  6. kaste commented on Feb 26, 2018

    @kaste
    Member

    Dude, I forgot that the Sublime variable is actually ${file}. Why didn't you say that as we discussed this in the issue.

    Also: ${temporary_file} or ${tmp_file}?

  7. FichteFoll commented on Feb 26, 2018

    @FichteFoll
    ContributorAuthor

    Either is fine with me, so I guess pick the shorter one? "tmp" is a widely-understood abbreviation. Alternatively, ${temp_file}, which is even more clear?

  8. kaste commented on Feb 27, 2018

    @kaste
    Member

    I'll take ${temp_file}.

  9. braver commented on Mar 3, 2018

    @braver
    Member

    discussion moved to #1073

  10. deleted a comment from kaste on Mar 3, 2018
  11. added this to the milestone on May 17, 2018
  12. removed this from the milestone on Oct 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions